Skip to content

Commit 8e24ca3

Browse files
feat: add linter plugin (#699)
1 parent b81115d commit 8e24ca3

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,7 @@ require('lazy').setup({
831831
--
832832
-- require 'kickstart.plugins.debug',
833833
-- require 'kickstart.plugins.indent_line',
834+
-- require 'kickstart.plugins.lint',
834835

835836
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
836837
-- This is the easiest way to modularize your config.

lua/kickstart/plugins/lint.lua

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
return {
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+
require('lint').try_lint()
51+
end,
52+
})
53+
end,
54+
},
55+
}

0 commit comments

Comments
 (0)