How can I ignore "~/.cargo/registry/src..." in "vim.diagnostic.setqflist()"? #22167
Replies: 1 comment
-
|
So the practical fix is to filter diagnostics on the Neovim side before converting them to quickfix items. Example: local function rust_workspace_diagnostics_qf()
local cargo_registry = vim.fs.normalize(vim.fn.expand("~/.cargo/registry/src"))
local diagnostics = vim.tbl_filter(function(diagnostic)
local name = vim.api.nvim_buf_get_name(diagnostic.bufnr)
if name == "" then
return true
end
local path = vim.fs.normalize(name)
return not vim.startswith(path, cargo_registry)
end, vim.diagnostic.get(nil))
vim.fn.setqflist(vim.diagnostic.toqflist(diagnostics), "r")
vim.cmd.copen()
end
vim.keymap.set("n", "<leader>q", rust_workspace_diagnostics_qf)If you only want diagnostics for the current project, an even stricter version is to keep only paths under The reason your current config does not help is that diagnostics from |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Triggering this
vim.diagnostic.setqflist()shows all diagnostics including directories/source files that are not inside my source directory... is there a way to exclude these?I am using
rustaceanvimand have this config:Running

:LspInfoshows this.Beta Was this translation helpful? Give feedback.
All reactions