Error messages being printed when using both rustaceannvim and mfussenegger/nvim-lint #441
-
Have you read the docs and searched existing issues?
Neovim version (nvim -v)v0.10.0 Operating system/versionUp-to-date Arch Linux Output of :checkhealth rustaceanvim==============================================================================
rustaceanvim: require("rustaceanvim.health").check()
Checking for Lua dependencies ~
- OK [mfussenegger/nvim-dap](https://github.com/mfussenegger/nvim-dap) installed.
Checking external dependencies ~
- OK rust-analyzer: found rust-analyzer 1.81.0-nightly (4bc39f0 2024-06-26)
- OK Cargo: found cargo 1.81.0-nightly (4ed7bee47 2024-06-25)
- OK rustc: found rustc 1.81.0-nightly (4bc39f028 2024-06-26)
- OK debug adapter: found codelldb
Checking config ~
- OK No errors found in config.
Checking for conflicting plugins ~
- OK No conflicting plugins detected.
Checking for tree-sitter parser ~
- OK tree-sitter parser for Rust detected. How to reproduce the issuecargo new bug
nvim bug/src/main.rs
Below the println add:
let b = HashMap::<usize, usize>::new();
Save file.
Put cursor on HashMap.
:RustLsp codeAction
Highlight import if it isn't already.
Press Enter Expected behaviourNo error message is printed. Actual behaviourThe code action succeeds, but error messages are printed. E5108: Error executing lua: ...aceanvim/lua/rustaceanvim/commands/code_action_group.lua:90: BufEnter Autocommands for "": Vim(append):Error running markdownlint: ENOENT: no such file or directory The minimal config used to reproduce this issue.vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()
require("lazy.minit").repro({
spec = {
{
"mrcjkb/rustaceanvim",
version = "^4",
init = function()
-- Configure rustaceanvim here
vim.g.rustaceanvim = {}
end,
lazy = false,
},
{
"mfussenegger/nvim-lint",
event = { "BufReadPre", "BufNewFile" },
config = function()
local lint = require("lint")
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
group = lint_augroup,
callback = function()
require("lint").try_lint()
end,
})
end,
},
},
}) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Handling of BufReadPre event seems to be the culprit. |
Beta Was this translation helpful? Give feedback.
-
Hey 👋 This isn't a rustaceanvim bug. The issue is that you're running The function should probably check if the file exists on the filesystem before trying to run the linter (although some linter configurations may be capable of passing the buffer content). Or, you could work around it by checking if the file is readonly in your callback. Example for Linux: if not vim.bo[0].readonly then
require("lint").try_lint()
end |
Beta Was this translation helpful? Give feedback.
Hey 👋
This isn't a rustaceanvim bug.
The issue is that you're running
require("lint").try_lint()
on a markdown buffer (the code action group selector) that's not a file on the filesystem; which can often be the case in Neovim (another example is fugitive blob buffers).
The function should probably check if the file exists on the filesystem before trying to run the linter (although some linter configurations may be capable of passing the buffer content).
Or, you could work around it by checking if the file is readonly in your callback.
Example for Linux: