at main 2.2 kB view raw
1return { 2 3 { -- Linting 4 'mfussenegger/nvim-lint', 5 event = { 'BufReadPre', 'BufNewFile' }, 6 config = function() 7 local lint = require 'lint' 8 lint.linters_by_ft = { 9 markdown = { 'markdownlint' }, 10 } 11 12 -- To allow other plugins to add linters to require('lint').linters_by_ft, 13 -- instead set linters_by_ft like this: 14 -- lint.linters_by_ft = lint.linters_by_ft or {} 15 -- lint.linters_by_ft['markdown'] = { 'markdownlint' } 16 -- 17 -- However, note that this will enable a set of default linters, 18 -- which will cause errors unless these tools are available: 19 -- { 20 -- clojure = { "clj-kondo" }, 21 -- dockerfile = { "hadolint" }, 22 -- inko = { "inko" }, 23 -- janet = { "janet" }, 24 -- json = { "jsonlint" }, 25 -- markdown = { "vale" }, 26 -- rst = { "vale" }, 27 -- ruby = { "ruby" }, 28 -- terraform = { "tflint" }, 29 -- text = { "vale" } 30 -- } 31 -- 32 -- You can disable the default linters by setting their filetypes to nil: 33 -- lint.linters_by_ft['clojure'] = nil 34 -- lint.linters_by_ft['dockerfile'] = nil 35 -- lint.linters_by_ft['inko'] = nil 36 -- lint.linters_by_ft['janet'] = nil 37 -- lint.linters_by_ft['json'] = nil 38 -- lint.linters_by_ft['markdown'] = nil 39 -- lint.linters_by_ft['rst'] = nil 40 -- lint.linters_by_ft['ruby'] = nil 41 -- lint.linters_by_ft['terraform'] = nil 42 -- lint.linters_by_ft['text'] = nil 43 44 -- Create autocommand which carries out the actual linting 45 -- on the specified events. 46 local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true }) 47 vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, { 48 group = lint_augroup, 49 callback = function() 50 -- Only run the linter in buffers that you can modify in order to 51 -- avoid superfluous noise, notably within the handy LSP pop-ups that 52 -- describe the hovered symbol using Markdown. 53 if vim.opt_local.modifiable:get() then 54 lint.try_lint() 55 end 56 end, 57 }) 58 end, 59 }, 60}