Skip to content

Commit

Permalink
feat: add linting Neovim configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
vicnett committed Nov 17, 2024
1 parent cfc4ea8 commit 8d4aa4e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions vim/lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"mini.icons": { "branch": "main", "commit": "a2742459f0ee32806c2438ca06b4d8b331f3f4d4" },
"nvim-cmp": { "branch": "main", "commit": "983453e32cb35533a119725883c04436d16c0120" },
"nvim-highlight-colors": { "branch": "main", "commit": "e967e2ba13fd4ca731b41d0e5cc1ac2edcd6e25e" },
"nvim-lint": { "branch": "master", "commit": "36da8dd0ddc4f88e0beae234c20e75397326f143" },
"nvim-lspconfig": { "branch": "master", "commit": "056f569f71e4b726323b799b9cfacc53653bceb3" },
"nvim-solarized-lua": { "branch": "master", "commit": "d69a263c97cbc765ca442d682b3283aefd61d4ac" },
"nvim-treesitter": { "branch": "master", "commit": "cfc6f2c117aaaa82f19bcce44deec2c194d900ab" },
Expand Down
33 changes: 33 additions & 0 deletions vim/lua/plugins/lint.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
return {
{
"mfussenegger/nvim-lint",
event = { "BufReadPre", "BufNewFile" },
config = function()
local lint = require("lint")
lint.linters_by_ft = {
dockerfile = { "hadolint" },
json = { "jsonlint" },
markdown = { "markdownlint" },
terraform = { "tflint" },
}

-- 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,
},
}
1 change: 1 addition & 0 deletions vim/lua/plugins/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ return {
"stylua", -- Lua
--linters
"flake8", -- Python
"hadolint", -- Dockerfile
"jsonlint", -- Json
"markdownlint", -- Markdown
"tflint", -- Terraform
Expand Down

0 comments on commit 8d4aa4e

Please sign in to comment.