Restructure and disable linters the proper way

This commit is contained in:
Imbus 2024-08-10 05:49:17 +02:00
parent 6e17346720
commit 3daccea308

View file

@ -1,55 +1,50 @@
return { return {
'mfussenegger/nvim-lint',
event = { 'BufReadPre', 'BufNewFile' },
config = function()
local lint = require 'lint'
lint.linters_by_ft = {}
{ -- Linting -- To allow other plugins to add linters to require('lint').linters_by_ft,
'mfussenegger/nvim-lint', -- instead set linters_by_ft like this:
event = { 'BufReadPre', 'BufNewFile' }, -- lint.linters_by_ft = lint.linters_by_ft or {}
config = function() -- lint.linters_by_ft['markdown'] = { 'markdownlint' }
local lint = require 'lint' --
lint.linters_by_ft = { -- However, note that this will enable a set of default linters,
markdown = { 'markdownlint' }, -- which will cause errors unless these tools are available:
} -- {
-- clojure = { "clj-kondo" },
-- dockerfile = { "hadolint" },
-- inko = { "inko" },
-- janet = { "janet" },
-- json = { "jsonlint" },
-- markdown = { "vale" },
-- rst = { "vale" },
-- ruby = { "ruby" },
-- terraform = { "tflint" },
-- text = { "vale" }
-- }
--
-- You can disable the default linters by setting their filetypes to nil:
-- lint.linters_by_ft['clojure'] = nil
-- lint.linters_by_ft['dockerfile'] = nil
-- lint.linters_by_ft['inko'] = nil
-- lint.linters_by_ft['janet'] = nil
-- lint.linters_by_ft['json'] = nil
-- lint.linters_by_ft['markdown'] = nil
-- lint.linters_by_ft['rst'] = nil
-- lint.linters_by_ft['ruby'] = nil
-- lint.linters_by_ft['terraform'] = nil
-- lint.linters_by_ft['text'] = nil
-- To allow other plugins to add linters to require('lint').linters_by_ft, -- Create autocommand which carries out the actual linting
-- instead set linters_by_ft like this: -- on the specified events.
-- lint.linters_by_ft = lint.linters_by_ft or {} local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true })
-- lint.linters_by_ft['markdown'] = { 'markdownlint' } vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, {
-- group = lint_augroup,
-- However, note that this will enable a set of default linters, callback = function()
-- which will cause errors unless these tools are available: lint.try_lint()
-- { end,
-- clojure = { "clj-kondo" }, })
-- dockerfile = { "hadolint" }, end,
-- inko = { "inko" },
-- janet = { "janet" },
-- json = { "jsonlint" },
-- markdown = { "vale" },
-- rst = { "vale" },
-- ruby = { "ruby" },
-- terraform = { "tflint" },
-- text = { "vale" }
-- }
--
-- You can disable the default linters by setting their filetypes to nil:
-- lint.linters_by_ft['clojure'] = nil
-- lint.linters_by_ft['dockerfile'] = nil
-- lint.linters_by_ft['inko'] = nil
-- lint.linters_by_ft['janet'] = nil
-- lint.linters_by_ft['json'] = nil
lint.linters_by_ft['markdown'] = nil
-- lint.linters_by_ft['rst'] = nil
-- lint.linters_by_ft['ruby'] = nil
-- lint.linters_by_ft['terraform'] = nil
-- lint.linters_by_ft['text'] = nil
-- Create autocommand which carries out the actual linting
-- on the specified events.
local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true })
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, {
group = lint_augroup,
callback = function()
lint.try_lint()
end,
})
end,
},
} }