Skip to content

Commit b1d3f64

Browse files
feat: add plugin for linting
1 parent b83b2b0 commit b1d3f64

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

init.lua

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ require('lazy').setup {
585585
local ensure_installed = vim.tbl_keys(servers or {})
586586
vim.list_extend(ensure_installed, {
587587
'stylua', -- Used to format lua code
588+
'markdownlint', -- Used to lint markdown
588589
})
589590
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
590591

@@ -623,6 +624,47 @@ require('lazy').setup {
623624
},
624625
},
625626

627+
{ -- Linting
628+
'mfussenegger/nvim-lint',
629+
event = { 'BufReadPre', 'BufNewFile' },
630+
config = function()
631+
local lint = require 'lint'
632+
lint.linters_by_ft = {
633+
markdown = { 'markdownlint' },
634+
}
635+
636+
-- To allow other plugins to add linters to require('lint').linters_by_ft,
637+
-- comment out the above and instead use this:
638+
-- lint.linters_by_ft = lint.linters_by_ft or {}
639+
--
640+
-- However, note that this will enable a set of default linters,
641+
-- which will cause errors unless these tools are available:
642+
-- {
643+
-- clojure = { "clj-kondo" },
644+
-- dockerfile = { "hadolint" },
645+
-- go = { "golangcilint" },
646+
-- inko = { "inko" },
647+
-- janet = { "janet" },
648+
-- json = { "jsonlint" },
649+
-- markdown = { "vale" },
650+
-- rst = { "vale" },
651+
-- ruby = { "ruby" },
652+
-- terraform = { "tflint" },
653+
-- text = { "vale" }
654+
-- }
655+
656+
-- Create autocommand which carries out the actual linting
657+
-- on the specified events.
658+
local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true })
659+
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, {
660+
group = lint_augroup,
661+
callback = function()
662+
require('lint').try_lint()
663+
end,
664+
})
665+
end,
666+
},
667+
626668
{ -- Autocompletion
627669
'hrsh7th/nvim-cmp',
628670
event = 'InsertEnter',

0 commit comments

Comments
 (0)