From 35f310e0a9d31b24a08f6dcf35611e81393d3574 Mon Sep 17 00:00:00 2001 From: punkfairie Date: Sun, 5 Jan 2025 11:25:37 -0800 Subject: [PATCH] feat: Add linters --- nix/neovim-overlay.nix | 2 ++ nvim/lua/plugins/linting/nvim-lint.lua | 27 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/nix/neovim-overlay.nix b/nix/neovim-overlay.nix index 7ee15b2..033b531 100644 --- a/nix/neovim-overlay.nix +++ b/nix/neovim-overlay.nix @@ -147,6 +147,8 @@ with final.pkgs.lib; let # Linters biome shellcheck + statix + yamllint # Formatters alejandra diff --git a/nvim/lua/plugins/linting/nvim-lint.lua b/nvim/lua/plugins/linting/nvim-lint.lua index b46a80e..90d01fd 100644 --- a/nvim/lua/plugins/linting/nvim-lint.lua +++ b/nvim/lua/plugins/linting/nvim-lint.lua @@ -5,9 +5,36 @@ return { local lint = require('lint') lint.linters_by_ft = { + bash = { 'shellcheck' }, fish = { 'fish' }, + nix = { 'statix' }, + scss = { 'stylelint' }, + sh = { 'shellcheck' }, + yaml = { 'yamllint' }, } + local linters = { + shellcheck = { + args = { + '-x', + }, + }, + } + + for name, linter in pairs(linters) do + if type(linter) == 'table' and type(lint.linters[name]) == 'table' then + lint.linters[name] = + vim.tbl_deep_extend('force', lint.linters[name], linter) + + if type(linter.prepend_args) == 'table' then + lint.linters[name].args = lint.linters[name].args or {} + vim.list_extend(lint.linters[name].args, linter.prepend_args) + end + else + lint.linters[name] = linter + end + end + vim.api.nvim_create_autocmd( { 'BufWritePost', 'BufReadPost', 'InsertLeave' }, {