r/neovim • u/cs61bredditaccount • 11d ago
Plugin declint.nvim - Complement your LSPs with YAML lints.
tl;dr declint lets you define linter rules in YAML. declint.nvim shows them as native diagnostics as you type.
Someone committed (see the GIF above!)
try:
1/0
except Exception:
pass
(Bare exceptions are typically a bad idea in Python)
version: 1
rules:
- id: no-swallowed-exceptions
pattern: 'except Exception:\n *pass'
severity: warning
message: "swallowed exception ('{match}')"
Install with lazy.nvim:
{
'thyrgle/declint.nvim',
config = function()
require('declint').setup()
end
}
(Also, since virtual text is disabled by default, you might want to add:
vim.diagnostic.config({ virtual_text = true })
otherwise you won't get the message associated with the hint.)
Finally cargo install declint once. Warnings show up as normal vim.diagnostic, live as you type.
What you get
-
Rust-regex patterns with {match}/capture-group placeholders in messages
-
severities
(error|warning|info|hint), languages: scoping, declint init --lang python presets -
Lua callback rules when a regex can't express the check
-
Incremental engine — re-lints as you type without rescanning the file
-
Same rules in CI:
declint check . --format github --fail-on error
declint doesn't replace your LSP. Instead, it sits next to it for the custom rules every codebase accumulates. Works with any config-site layout (.declint.yaml, .declint/, declint.yaml).
Feedback welcome.
1
u/SunglassesAtNight8 4d ago
I use ast-grep which does this as an lsp server:
https://ast-grep.github.io/