mirror of
https://github.com/harivansh-afk/nvim.git
synced 2026-04-15 08:03:44 +00:00
gutentags -> lsp
This commit is contained in:
parent
6e8e6e28dc
commit
6da7199231
4 changed files with 53 additions and 160 deletions
34
after/plugin/lsp.lua
Normal file
34
after/plugin/lsp.lua
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
local lsp_config = require("config.lsp")
|
||||
|
||||
vim.lsp.config("*", {
|
||||
capabilities = lsp_config.capabilities(),
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
|
||||
callback = function(ev)
|
||||
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
if client then
|
||||
lsp_config.on_attach(client, ev.buf)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
for _, server in ipairs({
|
||||
"lua_ls",
|
||||
"pyright",
|
||||
"ts_ls",
|
||||
"rust_analyzer",
|
||||
"gopls",
|
||||
"clangd",
|
||||
"bashls",
|
||||
"jsonls",
|
||||
"html",
|
||||
"cssls",
|
||||
}) do
|
||||
local ok, config = pcall(require, "lsp." .. server)
|
||||
if ok then
|
||||
vim.lsp.config(server, config)
|
||||
end
|
||||
vim.lsp.enable(server)
|
||||
end
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
{
|
||||
"Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
|
||||
"dashboard-nvim": { "branch": "master", "commit": "0775e567b6c0be96d01a61795f7b64c1758262f6" },
|
||||
"diffs.nvim": { "branch": "main", "commit": "52013d007d9edb9eff75c7cd820fc289d561c6fc" },
|
||||
"diffs.nvim": { "branch": "main", "commit": "4ce1e1786a9bd724fda5ab4aba528b64a790b11f" },
|
||||
"flash.nvim": { "branch": "main", "commit": "fcea7ff883235d9024dc41e638f164a450c14ca2" },
|
||||
"fzf-lua": { "branch": "main", "commit": "ec3fe3d9587005a995a00d55ea424bfc924eaf3e" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "1ce96a464fdbc24208e24c117e2021794259005d" },
|
||||
"fzf-lua": { "branch": "main", "commit": "fb8c50ba62a0daa433b7ac2b78834f318322b879" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "31217271a7314c343606acb4072a94a039a19fb5" },
|
||||
"gruvbox.nvim": { "branch": "main", "commit": "a472496e1a4465a2dd574389dcf6cdb29af9bf1b" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
|
||||
"lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" },
|
||||
|
|
@ -22,6 +22,5 @@
|
|||
"snacks.nvim": { "branch": "main", "commit": "fe7cfe9800a182274d0f868a74b7263b8c0c020b" },
|
||||
"supermaven-nvim": { "branch": "main", "commit": "07d20fce48a5629686aefb0a7cd4b25e33947d50" },
|
||||
"vim-fugitive": { "branch": "master", "commit": "61b51c09b7c9ce04e821f6cf76ea4f6f903e3cf4" },
|
||||
"vim-gutentags": { "branch": "master", "commit": "aa47c5e29c37c52176c44e61c780032dfacef3dd" },
|
||||
"which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,95 +0,0 @@
|
|||
return {
|
||||
{
|
||||
"ludovicchabant/vim-gutentags",
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
-- Store tags in a cache directory to keep project clean
|
||||
vim.g.gutentags_cache_dir = vim.fn.expand("~/.cache/nvim/ctags")
|
||||
|
||||
-- Enable both ctags and LSP to work together
|
||||
vim.g.gutentags_modules = { "ctags" }
|
||||
|
||||
-- Configure ctags generation
|
||||
vim.g.gutentags_ctags_extra_args = {
|
||||
"--tag-relative=yes",
|
||||
"--fields=+ailmnS",
|
||||
"--languages=Python,JavaScript,TypeScript,Go,Rust,C,C++,Lua",
|
||||
"--python-kinds=-i", -- Exclude imports
|
||||
}
|
||||
|
||||
-- Don't generate tags for these directories
|
||||
vim.g.gutentags_ctags_exclude = {
|
||||
"*.git",
|
||||
"*.svg",
|
||||
"*.hg",
|
||||
"*/tests/*",
|
||||
"build",
|
||||
"dist",
|
||||
"*sites/*/files/*",
|
||||
"bin",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"cache",
|
||||
"compiled",
|
||||
"docs",
|
||||
"example",
|
||||
"bundle",
|
||||
"vendor",
|
||||
"*.md",
|
||||
"*-lock.json",
|
||||
"*.lock",
|
||||
"*bundle*.js",
|
||||
"*build*.js",
|
||||
".*rc*",
|
||||
"*.json",
|
||||
"*.min.*",
|
||||
"*.map",
|
||||
"*.bak",
|
||||
"*.zip",
|
||||
"*.pyc",
|
||||
"*.class",
|
||||
"*.sln",
|
||||
"*.Master",
|
||||
"*.csproj",
|
||||
"*.tmp",
|
||||
"*.csproj.user",
|
||||
"*.cache",
|
||||
"*.pdb",
|
||||
"tags*",
|
||||
"cscope.*",
|
||||
"*.css",
|
||||
"*.less",
|
||||
"*.scss",
|
||||
"*.exe",
|
||||
"*.dll",
|
||||
"*.mp3",
|
||||
"*.ogg",
|
||||
"*.flac",
|
||||
"*.swp",
|
||||
"*.swo",
|
||||
"*.bmp",
|
||||
"*.gif",
|
||||
"*.ico",
|
||||
"*.jpg",
|
||||
"*.png",
|
||||
"*.rar",
|
||||
"*.zip",
|
||||
"*.tar",
|
||||
"*.tar.gz",
|
||||
"*.tar.xz",
|
||||
"*.tar.bz2",
|
||||
"*.pdf",
|
||||
"*.doc",
|
||||
"*.docx",
|
||||
"*.ppt",
|
||||
"*.pptx",
|
||||
"__pycache__",
|
||||
".venv",
|
||||
"venv",
|
||||
}
|
||||
|
||||
-- Create cache directory if it doesn't exist
|
||||
vim.fn.mkdir(vim.fn.expand("~/.cache/nvim/ctags"), "p")
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
@ -1,66 +1,21 @@
|
|||
return {
|
||||
{ "neovim/nvim-lspconfig", lazy = false },
|
||||
{ "williamboman/mason.nvim", lazy = false, opts = {} },
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
"williamboman/mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
lazy = false,
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"lua_ls",
|
||||
"pyright",
|
||||
"rust_analyzer",
|
||||
"gopls",
|
||||
"clangd",
|
||||
"bashls",
|
||||
"jsonls",
|
||||
"html",
|
||||
"cssls",
|
||||
},
|
||||
},
|
||||
config = function()
|
||||
local lsp_config = require("config.lsp")
|
||||
|
||||
-- Set up Mason for auto-installation
|
||||
require("mason").setup()
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = {
|
||||
"lua_ls",
|
||||
"pyright",
|
||||
"ts_ls",
|
||||
"rust_analyzer",
|
||||
"gopls",
|
||||
"clangd",
|
||||
"bashls",
|
||||
"jsonls",
|
||||
"html",
|
||||
"cssls",
|
||||
},
|
||||
automatic_installation = true,
|
||||
})
|
||||
|
||||
local lspconfig = require("lspconfig")
|
||||
local capabilities = lsp_config.capabilities()
|
||||
|
||||
-- LspAttach autocmd for keymaps
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
|
||||
callback = function(ev)
|
||||
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
if client then
|
||||
lsp_config.on_attach(client, ev.buf)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Helper to load per-server config from lua/lsp/ if it exists
|
||||
local function get_server_config(server_name)
|
||||
local ok, server_config = pcall(require, "lsp." .. server_name)
|
||||
if ok then
|
||||
return server_config
|
||||
end
|
||||
return {}
|
||||
end
|
||||
|
||||
-- Auto-setup all installed servers
|
||||
require("mason-lspconfig").setup_handlers({
|
||||
-- Default handler for all servers
|
||||
function(server_name)
|
||||
local server_config = get_server_config(server_name)
|
||||
local config = vim.tbl_deep_extend("force", {
|
||||
capabilities = capabilities,
|
||||
}, server_config)
|
||||
|
||||
lspconfig[server_name].setup(config)
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue