Skip to content

Commit

Permalink
feat: add plugin for linting
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikaverpil committed Mar 5, 2024
1 parent b83b2b0 commit 01e4c06
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ require('lazy').setup {
local ensure_installed = vim.tbl_keys(servers or {})
vim.list_extend(ensure_installed, {
'stylua', -- Used to format lua code
'markdownlint', -- Used to lint markdown
})
require('mason-tool-installer').setup { ensure_installed = ensure_installed }

Expand Down Expand Up @@ -623,6 +624,59 @@ require('lazy').setup {
},
},

{ -- Linting
'mfussenegger/nvim-lint',
event = { 'BufReadPre', 'BufNewFile' },
config = function()
local lint = require 'lint'
lint.linters_by_ft = {
markdown = { 'markdownlint' },
}

-- 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()
require('lint').try_lint()
end,
})
end,
},

{ -- Autocompletion
'hrsh7th/nvim-cmp',
event = 'InsertEnter',
Expand Down

0 comments on commit 01e4c06

Please sign in to comment.