mfussenegger / nvim-lint

An asynchronous linter plugin for Neovim complementary to the built-in Language Server Protocol support.
GNU General Public License v3.0
1.76k stars 191 forks source link

Provide Mechanism to Disable Linter in Neo-Tree Buffer #609

Closed driverkt closed 1 week ago

driverkt commented 1 week ago

Say that I want to run a linter for every buffer (all file-types), but there may be buffer types for which I don't want to run it, ie neo-tree.

Is there already a mechanism to handle this? The code example in the docs looks like this:

vim.api.nvim_create_autocmd({ "BufWritePost" }, {
  callback = function()

    -- try_lint without arguments runs the linters defined in `linters_by_ft`
    -- for the current filetype
    require("lint").try_lint()

    -- You can call `try_lint` with a linter name or a list of names to always
    -- run specific linters, independent of the `linters_by_ft` configuration
    require("lint").try_lint("cspell")
  end,
})
mfussenegger commented 1 week ago

You could wrap the try_lint call in a if block where you check the buftype. See :h 'buftype' and :h vim.bo