From 6bef8f32b19778fdfe52f0eb39719425508dcc7b Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Thu, 24 Apr 2025 11:36:39 +0300 Subject: Refactored nvim config to make it easier and less insanely nested --- .config/nvim/lua/plugins/nvim-lint.lua | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .config/nvim/lua/plugins/nvim-lint.lua (limited to '.config/nvim/lua/plugins/nvim-lint.lua') diff --git a/.config/nvim/lua/plugins/nvim-lint.lua b/.config/nvim/lua/plugins/nvim-lint.lua new file mode 100644 index 0000000..7bb3a16 --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-lint.lua @@ -0,0 +1,41 @@ +return { + 'mfussenegger/nvim-lint', + lazy = false, + config = function() + local lint = require('lint') + lint.linters_by_ft = { + -- c = { 'clangtidy' }, + -- cpp = { 'clangtidy' }, + go = { 'golangcilint' }, + -- python = { 'flake8' }, + json = { 'jsonlint' }, + bash = { 'shellcheck' }, + } + + vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave', 'TextChanged', 'TextChangedI' }, { + group = vim.api.nvim_create_augroup('nvim-lint', { clear = true }), + callback = function() + require('lint').try_lint() + end, + }) + + -- NOTE: most if not all of clangt-idy warnings are + -- also reported by clangd, so this function filters clang-tidy warnings + -- to avoid duplication of warnings + -- local clangtidy_parser = lint.linters.clangtidy.parser + -- lint.linters.clangtidy.parser = function(output, bufnr, linter_cwd) + -- local diagnostics = clangtidy_parser(output, bufnr, linter_cwd) + -- diagnostics = vim.tbl_filter(function(diagnostic) + -- if diagnostic.severity == vim.diagnostic.severity.WARN then + -- return false + -- end + -- if diagnostic.severity == vim.diagnostic.severity.ERROR then + -- return false + -- end + -- + -- return true + -- end, diagnostics) + -- return diagnostics + -- end + end, +} -- cgit v1.3.1