Closed tomhampshire closed 4 months ago
Cross-post with https://github.com/LazyVim/LazyVim/issues/2589 as there may be a mechanism that will help
I might be missing something here, but the readme shows how to configure an autocmd to run the linter (which I'm guessing would provide the behavior you want?):
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
callback = function()
require("lint").try_lint()
end,
})
You could change BufWritePost
to whatever event you like or even filter by filetypes with pattern = something
which might be useful if struggling with slow linters.
Hope that helps!
Hi - thanks for the suggestion.
Where I don't see where this would work is (please correct me if I'm wrong), for example, I want to run ruff (a fast Python linter) on InsertLeave
and mypy/pylint (both slow linters) on BufWritePost
and BufReadPost
Oh my bad I did not understand you correctly! Unfortunately I can't think of a way to tell the plugin what lint to run on what event, sorry. That being said I'm not a maintainer or anything, I was just passing by. Maybe someone more clever than me can think of something!
example, I want to run ruff (a fast Python linter) on InsertLeave and mypy/pylint (both slow linters) on BufWritePost and BufReadPost
You can setup different autocmds which call try_lint
with different linter names
Great - thanks! This would be good information for the readme
Some linters (e.g. mypy, pylint) are very slow, however, it is useful to have linting messages from these whilst coding. With null-ls, it was possible to specify when linters were run (e.g. onsave only, on exit insert mode, etc). Is this possible with nvim-lint?