85 lines
3.3 KiB
Lua
85 lines
3.3 KiB
Lua
-- MIT License
|
|
--
|
|
-- Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
-- of this software and associated documentation files (the "Software"), to deal
|
|
-- in the Software without restriction, including without limitation the rights
|
|
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
-- copies of the Software, and to permit persons to whom the Software is
|
|
-- furnished to do so, subject to the following conditions:
|
|
--
|
|
-- The above copyright notice and this permission notice shall be included in all
|
|
-- copies or substantial portions of the Software.
|
|
--
|
|
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
-- SOFTWARE.
|
|
|
|
return {
|
|
|
|
{ -- Linting
|
|
'mfussenegger/nvim-lint',
|
|
event = { 'BufReadPre', 'BufNewFile' },
|
|
config = function()
|
|
local lint = require('lint')
|
|
lint.linters_by_ft = {
|
|
dockerfile = { 'hadolint' },
|
|
json = { 'jsonlint' },
|
|
markdown = { 'markdownlint' },
|
|
python = { 'pylint' },
|
|
terraform = { 'tflint' },
|
|
}
|
|
|
|
-- To allow other plugins to add linters to require('lint').linters_by_ft,
|
|
-- instead set linters_by_ft like this:
|
|
-- lint.linters_by_ft = lint.linters_by_ft or {}
|
|
-- lint.linters_by_ft['markdown'] = { 'markdownlint' }
|
|
--
|
|
-- However, note that this will enable a set of default linters,
|
|
-- 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
|
|
|
|
-- 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()
|
|
-- Only run the linter in buffers that you can modify in order to
|
|
-- avoid superfluous noise, notably within the handy LSP pop-ups that
|
|
-- describe the hovered symbol using Markdown.
|
|
if vim.opt_local.modifiable:get() then
|
|
lint.try_lint()
|
|
end
|
|
end,
|
|
})
|
|
end,
|
|
},
|
|
}
|