Override diagnostic severity for a specific source #494
-
There is a way to override the diagnostic severity for a specific source ? For example, I tried to use cspell source. It works great but reports all unknown words like lowecase names as errors, and this might produce a really disturbing massive redish output in source code. The solution would be to have the diagnostics reported by cspell source (including those false positive errors) to be reported as information or hint diagnostic. So it could be really great to have the possibility to transform the diagnostic severity for a specific source. Maybe this is already the case ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Unfortunately we don't handle this case currently. Broadly speaking, we don't have a way for users to customize what sources do with their output. It's something I want to think about more, but short of making built-ins into a class (which is sensible, but would break existing configs) I can't think of a good solution right now. In the meantime, we could expose |
Beta Was this translation helpful? Give feedback.
-
This has been solved now. In my case I wanted to override the diagnostic severity of cspell, going from error to hint. local null_ls = require("null-ls")
null_ls.setup({
sources = {
null_ls.builtins.diagnostics.cspell.with({
-- Force the severity to be HINT
diagnostics_postprocess = function(diagnostic)
diagnostic.severity = vim.diagnostic.severity.HINT
end,
}),
}
}) Credit: |
Beta Was this translation helpful? Give feedback.
Unfortunately we don't handle this case currently. Broadly speaking, we don't have a way for users to customize what sources do with their output. It's something I want to think about more, but short of making built-ins into a class (which is sensible, but would break existing configs) I can't think of a good solution right now.
In the meantime, we could expose
default_severity
as an option. At the moment, all unspecified severities fall back toerror
, which is what you are seeing withcspell
, but we could allow users to configure it. Would that help?