✨ feat: add nvim-lint for code linting and update auto-install config

This commit is contained in:
sankalp committed 2025-07-25 14:27:36 +05:45
1 parent 1cc51f2774
commit 5c803c0175
6 files changed
+92 -33

No files matched your search

+8 -4
View File
@@ -18,7 +18,7 @@ Handcrafted Neovim setup for the ultimate CLI dev experience.
- **Pretty colors**: Comes with treesitter and onedark preconfigured with full transparency support - **Pretty colors**: Comes with treesitter and onedark preconfigured with full transparency support
- **Tmux integration**: Works with your tmux configurations out of the box - **Tmux integration**: Works with your tmux configurations out of the box
- **Dev tools**: Comes with debugging, testing, database and REPL support, pick and choose - **Dev tools**: Comes with debugging, testing, database and REPL support, pick and choose
- **Auto install**: All necessary LSPs, Null LS sources, Treesitter Parsers etc. are auto installed - **Auto install**: All necessary LSPs, Formatter, Linters, Treesitter Parsers etc. are auto installed
- **User module**: Configure keycodex according to your needs by using the `user` module! - **User module**: Configure keycodex according to your needs by using the `user` module!
- and some more - and some more
@@ -70,8 +70,11 @@ local user = {
user_lsp_servers = { user_lsp_servers = {
-- Auto installed LSPs defined by user -- Auto installed LSPs defined by user
}, },
user_null_ls_sources = { user_formatter_sources = {
-- Auto installed Null LS sources defined by user -- Auto installed formatter sources defined by user
},
user_linter_sources = {
-- Auto installed lintere sources defined by user
}, },
user_treesitter_parsers = { user_treesitter_parsers = {
-- Auto installed Treesitter parsers defined by user -- Auto installed Treesitter parsers defined by user
@@ -120,4 +123,5 @@ You can check out the [plugins list file](./lua/plugins/list.lua) file to see th
## 🙏 Acknowledgments ## 🙏 Acknowledgments
This project builds upon [nvim2k](https://github.com/2KAbhishek/nvim2k) by [2KAbhishek](https://github.com/2KAbhishek/), enhancing it with additional features and optimizations. This project builds upon [nvim2k](https://github.com/2KAbhishek/nvim2k) by [2KAbhishek](https://github.com/2KAbhishek/), enhancing it with additional features and optimizations.
+17 -10
View File
@@ -59,18 +59,25 @@ blink.setup({
score_offset = 100, score_offset = 100,
}, },
spell = { spell = {
name = 'spell', name = 'Spell',
module = 'blink.compat.source', module = 'blink-cmp-spell',
max_items = 10,
score_offset = -20,
opts = { opts = {
keep_all_entries = true, -- don't filter it -- EXAMPLE: Only enable source in `@spell` captures, and disable it
-- enable_in_context = function() -- in `@nospell` captures.
-- return require("cmp.config.context").in_treesitter_capture "spell" enable_in_context = function()
-- end, local curpos = vim.api.nvim_win_get_cursor(0)
preselect_correct_word = false, local captures = vim.treesitter.get_captures_at_pos(0, curpos[1] - 1, curpos[2] - 1)
local in_spell_capture = false
for _, cap in ipairs(captures) do
if cap.capture == 'spell' then
in_spell_capture = true
elseif cap.capture == 'nospell' then
return false
end
end
return in_spell_capture
end,
}, },
kind = 'Spell',
}, },
}, },
}, },
+1 -3
View File
@@ -15,8 +15,6 @@ conform.setup({
json = { 'prettier' }, json = { 'prettier' },
yaml = { 'prettier' }, yaml = { 'prettier' },
sh = { 'shfmt' }, sh = { 'shfmt' },
elixir = { 'mix' },
-- ruby = { "rubocop" }, -- optional
}, },
-- Autoformat on save -- Autoformat on save
@@ -28,7 +26,7 @@ conform.setup({
-- Setup mason-conform -- Setup mason-conform
local auto_install = require('lib.util').get_user_config('auto_install', true) local auto_install = require('lib.util').get_user_config('auto_install', true)
local installed_formatters = require('plugins.list').null_ls_sources or {} local installed_formatters = require('plugins.list').formatter_sources or {}
require('mason-conform').setup({ require('mason-conform').setup({
ensure_installed = installed_formatters, ensure_installed = installed_formatters,
+31
View File
@@ -0,0 +1,31 @@
local lint = require('lint')
-- Filetype to linters mapping
lint.linters_by_ft = {
javascript = { 'eslint_d' },
typescript = { 'eslint_d' },
javascriptreact = { 'eslint_d' },
typescriptreact = { 'eslint_d' },
dockerfile = { 'hadolint' },
vim = { 'vint' },
markdown = { 'write_good', 'markdownlint' },
text = { 'write_good' },
sh = { 'shellcheck' },
yaml = { 'actionlint' },
}
-- Trigger linting on save and buffer events
vim.api.nvim_create_autocmd({ 'BufWritePost', 'BufReadPost', 'InsertLeave' }, {
callback = function()
lint.try_lint()
end,
})
-- Setup mason-nvim-lint to auto-install linters
local auto_install = require('lib.util').get_user_config('auto_install', true)
local installed_linters = require('plugins.list').linter_sources or {}
require('mason-nvim-lint').setup({
ensure_installed = installed_linters,
automatic_installation = auto_install,
})
+32 -16
View File
@@ -130,14 +130,18 @@ local plugins = {
config = load_config('lang.conform'), config = load_config('lang.conform'),
event = { 'BufReadPre', 'BufNewFile' }, event = { 'BufReadPre', 'BufNewFile' },
}, },
{
'mfussenegger/nvim-lint',
dependencies = { 'rshkarin/mason-nvim-lint' },
config = load_config('lang.nvim-lint'),
event = { 'BufReadPost', 'BufNewFile' },
},
{ {
'saghen/blink.cmp', 'saghen/blink.cmp',
dependencies = { dependencies = {
'rafamadriz/friendly-snippets', 'rafamadriz/friendly-snippets',
'Kaiser-Yang/blink-cmp-avante', 'Kaiser-Yang/blink-cmp-avante',
'windwp/nvim-ts-autotag', 'ribru17/blink-cmp-spell',
'f3fora/cmp-spell',
{ {
'L3MON4D3/LuaSnip', 'L3MON4D3/LuaSnip',
config = function() config = function()
@@ -245,6 +249,13 @@ local plugins = {
}, },
}, },
}, },
{
'windwp/nvim-ts-autotag',
event = { 'BufReadPre', 'BufNewFile' },
config = function()
require('nvim-ts-autotag').setup()
end,
},
{ {
'gbprod/substitute.nvim', 'gbprod/substitute.nvim',
event = { 'BufReadPre', 'BufNewFile' }, event = { 'BufReadPre', 'BufNewFile' },
@@ -442,8 +453,20 @@ local treesitter_parsers = {
'yaml', 'yaml',
} }
local null_ls_sources = { local linter_sources = {
'shellcheck', 'shellcheck',
'write_good',
'markdownlint',
'eslint_d',
'hadolint',
'actionlint',
'vint',
}
local formatter_sources = {
'prettier',
'shfmt',
'stylua',
} }
local lsp_servers = { local lsp_servers = {
@@ -453,7 +476,7 @@ local lsp_servers = {
'vimls', 'vimls',
'lua_ls', 'lua_ls',
'qmlls', 'qmlls',
'tailwindcss', -- Add Tailwind CSS LSP 'tailwindcss',
} }
if util.is_present('npm') then if util.is_present('npm') then
@@ -461,11 +484,6 @@ if util.is_present('npm') then
table.insert(lsp_servers, 'ts_ls') table.insert(lsp_servers, 'ts_ls')
end end
if util.is_present('gem') then
table.insert(lsp_servers, 'solargraph')
table.insert(lsp_servers, 'rubocop')
end
if util.is_present('go') then if util.is_present('go') then
table.insert(lsp_servers, 'gopls') table.insert(lsp_servers, 'gopls')
end end
@@ -484,22 +502,20 @@ if util.is_present('pip') then
table.insert(lsp_servers, 'pylsp') table.insert(lsp_servers, 'pylsp')
end end
if util.is_present('mix') then
table.insert(lsp_servers, 'elixirls')
end
if util.is_present('cargo') then if util.is_present('cargo') then
table.insert(lsp_servers, 'rust_analyzer') table.insert(lsp_servers, 'rust_analyzer')
end end
plugins = vim.tbl_extend('force', plugins, util.get_user_config('user_plugins', {})) plugins = vim.tbl_extend('force', plugins, util.get_user_config('user_plugins', {}))
lsp_servers = vim.tbl_extend('force', lsp_servers, util.get_user_config('user_lsp_servers', {})) lsp_servers = vim.tbl_extend('force', lsp_servers, util.get_user_config('user_lsp_servers', {}))
null_ls_sources = vim.tbl_extend('force', null_ls_sources, util.get_user_config('user_null_ls_sources', {})) formatter_sources = vim.tbl_extend('force', formatter_sources, util.get_user_config('user_formatter_sources', {}))
linter_sources = vim.tbl_extend('force', linter_sources, util.get_user_config('user_linter_sources', {}))
treesitter_parsers = vim.tbl_extend('force', treesitter_parsers, util.get_user_config('user_tresitter_parsers', {})) treesitter_parsers = vim.tbl_extend('force', treesitter_parsers, util.get_user_config('user_tresitter_parsers', {}))
return { return {
plugins = plugins, plugins = plugins,
lsp_servers = lsp_servers, lsp_servers = lsp_servers,
null_ls_sources = null_ls_sources, formatter_sources = formatter_sources,
linter_sources = linter_sources,
ts_parsers = treesitter_parsers, ts_parsers = treesitter_parsers,
} }
+3
View File
@@ -5,6 +5,7 @@
"base46": { "branch": "v3.0", "commit": "cee12a263602cc97652d3dd55f0fc5e171012967" }, "base46": { "branch": "v3.0", "commit": "cee12a263602cc97652d3dd55f0fc5e171012967" },
"blink-cmp-avante": { "branch": "master", "commit": "4f494c6e124acbe31a8f5d58effa0c14aa38a6d5" }, "blink-cmp-avante": { "branch": "master", "commit": "4f494c6e124acbe31a8f5d58effa0c14aa38a6d5" },
"blink-cmp-copilot": { "branch": "main", "commit": "439cff78780c033aa23cf061d7315314b347e3c1" }, "blink-cmp-copilot": { "branch": "main", "commit": "439cff78780c033aa23cf061d7315314b347e3c1" },
"blink-cmp-spell": { "branch": "master", "commit": "2bd0e0d5e7735c047e72b6918a0458f3e8fadaba" },
"blink.cmp": { "branch": "main", "commit": "bae4bae0eedd1fa55f34b685862e94a222d5c6f8" }, "blink.cmp": { "branch": "main", "commit": "bae4bae0eedd1fa55f34b685862e94a222d5c6f8" },
"ccc.nvim": { "branch": "main", "commit": "9d1a256e006decc574789dfc7d628ca11644d4c2" }, "ccc.nvim": { "branch": "main", "commit": "9d1a256e006decc574789dfc7d628ca11644d4c2" },
"codesnap.nvim": { "branch": "main", "commit": "be6d6b9a3b5e6999edbda76b16dace03d9bfcd3d" }, "codesnap.nvim": { "branch": "main", "commit": "be6d6b9a3b5e6999edbda76b16dace03d9bfcd3d" },
@@ -23,6 +24,7 @@
"markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" },
"mason-conform.nvim": { "branch": "main", "commit": "f3b96fa2217fcb1513301eefbe10ea0e765e33eb" }, "mason-conform.nvim": { "branch": "main", "commit": "f3b96fa2217fcb1513301eefbe10ea0e765e33eb" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "bb3a17efc797c34c054463174e5522442576ebd8" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "bb3a17efc797c34c054463174e5522442576ebd8" },
"mason-nvim-lint": { "branch": "main", "commit": "767b8ccdddaa977bec8987fd7507b9865a279235" },
"mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" },
"mdx.nvim": { "branch": "main", "commit": "464a74be368dce212cff02f6305845dc7f209ab3" }, "mdx.nvim": { "branch": "main", "commit": "464a74be368dce212cff02f6305845dc7f209ab3" },
"mini.ai": { "branch": "main", "commit": "e139eb1101beb0250fea322f8c07a42f0f175688" }, "mini.ai": { "branch": "main", "commit": "e139eb1101beb0250fea322f8c07a42f0f175688" },
@@ -34,6 +36,7 @@
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
"nvim-dap": { "branch": "master", "commit": "99807078c5089ed30e0547aa4b52c5867933f426" }, "nvim-dap": { "branch": "master", "commit": "99807078c5089ed30e0547aa4b52c5867933f426" },
"nvim-dbee": { "branch": "master", "commit": "9656fc59841291e9dbd2f3b50b1cb4c77d9fea79" }, "nvim-dbee": { "branch": "master", "commit": "9656fc59841291e9dbd2f3b50b1cb4c77d9fea79" },
"nvim-lint": { "branch": "master", "commit": "9c6207559297b24f0b7c32829f8e45f7d65b991f" },
"nvim-lspconfig": { "branch": "master", "commit": "4d3b3bb8815fbe37bcaf3dbdb12a22382bc11ebe" }, "nvim-lspconfig": { "branch": "master", "commit": "4d3b3bb8815fbe37bcaf3dbdb12a22382bc11ebe" },
"nvim-spectre": { "branch": "master", "commit": "72f56f7585903cd7bf92c665351aa585e150af0f" }, "nvim-spectre": { "branch": "master", "commit": "72f56f7585903cd7bf92c665351aa585e150af0f" },
"nvim-spider": { "branch": "main", "commit": "6da0307421bc4be6fe02815faabde51007c4ea1a" }, "nvim-spider": { "branch": "main", "commit": "6da0307421bc4be6fe02815faabde51007c4ea1a" },