✨ 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

+17 -10
View File
@@ -59,18 +59,25 @@ blink.setup({
score_offset = 100,
},
spell = {
name = 'spell',
module = 'blink.compat.source',
max_items = 10,
score_offset = -20,
name = 'Spell',
module = 'blink-cmp-spell',
opts = {
keep_all_entries = true, -- don't filter it
-- enable_in_context = function()
-- return require("cmp.config.context").in_treesitter_capture "spell"
-- end,
preselect_correct_word = false,
-- EXAMPLE: Only enable source in `@spell` captures, and disable it
-- in `@nospell` captures.
enable_in_context = function()
local curpos = vim.api.nvim_win_get_cursor(0)
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' },
yaml = { 'prettier' },
sh = { 'shfmt' },
elixir = { 'mix' },
-- ruby = { "rubocop" }, -- optional
},
-- Autoformat on save
@@ -28,7 +26,7 @@ conform.setup({
-- Setup mason-conform
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({
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'),
event = { 'BufReadPre', 'BufNewFile' },
},
{
'mfussenegger/nvim-lint',
dependencies = { 'rshkarin/mason-nvim-lint' },
config = load_config('lang.nvim-lint'),
event = { 'BufReadPost', 'BufNewFile' },
},
{
'saghen/blink.cmp',
dependencies = {
'rafamadriz/friendly-snippets',
'Kaiser-Yang/blink-cmp-avante',
'windwp/nvim-ts-autotag',
'f3fora/cmp-spell',
'ribru17/blink-cmp-spell',
{
'L3MON4D3/LuaSnip',
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',
event = { 'BufReadPre', 'BufNewFile' },
@@ -442,8 +453,20 @@ local treesitter_parsers = {
'yaml',
}
local null_ls_sources = {
local linter_sources = {
'shellcheck',
'write_good',
'markdownlint',
'eslint_d',
'hadolint',
'actionlint',
'vint',
}
local formatter_sources = {
'prettier',
'shfmt',
'stylua',
}
local lsp_servers = {
@@ -453,7 +476,7 @@ local lsp_servers = {
'vimls',
'lua_ls',
'qmlls',
'tailwindcss', -- Add Tailwind CSS LSP
'tailwindcss',
}
if util.is_present('npm') then
@@ -461,11 +484,6 @@ if util.is_present('npm') then
table.insert(lsp_servers, 'ts_ls')
end
if util.is_present('gem') then
table.insert(lsp_servers, 'solargraph')
table.insert(lsp_servers, 'rubocop')
end
if util.is_present('go') then
table.insert(lsp_servers, 'gopls')
end
@@ -484,22 +502,20 @@ if util.is_present('pip') then
table.insert(lsp_servers, 'pylsp')
end
if util.is_present('mix') then
table.insert(lsp_servers, 'elixirls')
end
if util.is_present('cargo') then
table.insert(lsp_servers, 'rust_analyzer')
end
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', {}))
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', {}))
return {
plugins = plugins,
lsp_servers = lsp_servers,
null_ls_sources = null_ls_sources,
formatter_sources = formatter_sources,
linter_sources = linter_sources,
ts_parsers = treesitter_parsers,
}
+3
View File
@@ -5,6 +5,7 @@
"base46": { "branch": "v3.0", "commit": "cee12a263602cc97652d3dd55f0fc5e171012967" },
"blink-cmp-avante": { "branch": "master", "commit": "4f494c6e124acbe31a8f5d58effa0c14aa38a6d5" },
"blink-cmp-copilot": { "branch": "main", "commit": "439cff78780c033aa23cf061d7315314b347e3c1" },
"blink-cmp-spell": { "branch": "master", "commit": "2bd0e0d5e7735c047e72b6918a0458f3e8fadaba" },
"blink.cmp": { "branch": "main", "commit": "bae4bae0eedd1fa55f34b685862e94a222d5c6f8" },
"ccc.nvim": { "branch": "main", "commit": "9d1a256e006decc574789dfc7d628ca11644d4c2" },
"codesnap.nvim": { "branch": "main", "commit": "be6d6b9a3b5e6999edbda76b16dace03d9bfcd3d" },
@@ -23,6 +24,7 @@
"markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" },
"mason-conform.nvim": { "branch": "main", "commit": "f3b96fa2217fcb1513301eefbe10ea0e765e33eb" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "bb3a17efc797c34c054463174e5522442576ebd8" },
"mason-nvim-lint": { "branch": "main", "commit": "767b8ccdddaa977bec8987fd7507b9865a279235" },
"mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" },
"mdx.nvim": { "branch": "main", "commit": "464a74be368dce212cff02f6305845dc7f209ab3" },
"mini.ai": { "branch": "main", "commit": "e139eb1101beb0250fea322f8c07a42f0f175688" },
@@ -34,6 +36,7 @@
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
"nvim-dap": { "branch": "master", "commit": "99807078c5089ed30e0547aa4b52c5867933f426" },
"nvim-dbee": { "branch": "master", "commit": "9656fc59841291e9dbd2f3b50b1cb4c77d9fea79" },
"nvim-lint": { "branch": "master", "commit": "9c6207559297b24f0b7c32829f8e45f7d65b991f" },
"nvim-lspconfig": { "branch": "master", "commit": "4d3b3bb8815fbe37bcaf3dbdb12a22382bc11ebe" },
"nvim-spectre": { "branch": "master", "commit": "72f56f7585903cd7bf92c665351aa585e150af0f" },
"nvim-spider": { "branch": "main", "commit": "6da0307421bc4be6fe02815faabde51007c4ea1a" },