mirror of
https://github.com/harivansh-afk/nvim.git
synced 2026-04-17 12:04:14 +00:00
add auto tagging with gutentags
This commit is contained in:
parent
57407e8ef8
commit
d7236fcfbd
3 changed files with 161 additions and 34 deletions
95
lua/plugins/gutentags.lua
Normal file
95
lua/plugins/gutentags.lua
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
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,
|
||||
},
|
||||
}
|
||||
|
|
@ -8,7 +8,19 @@ return {
|
|||
config = function()
|
||||
require("mason").setup()
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = { "lua_ls", "pyright", "tsserver" },
|
||||
ensure_installed = {
|
||||
"lua_ls", -- Lua
|
||||
"pyright", -- Python
|
||||
"ts_ls", -- TypeScript/JavaScript (tsserver renamed)
|
||||
"rust_analyzer", -- Rust
|
||||
"gopls", -- Go
|
||||
"clangd", -- C/C++
|
||||
"bashls", -- Bash
|
||||
"jsonls", -- JSON
|
||||
"yamlls", -- YAML
|
||||
"html", -- HTML
|
||||
"cssls", -- CSS
|
||||
},
|
||||
automatic_installation = true,
|
||||
})
|
||||
|
||||
|
|
@ -22,6 +34,7 @@ return {
|
|||
local opts = { buffer = ev.buf }
|
||||
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set("n", "<C-]>", vim.lsp.buf.definition, opts) -- Ctrl+] for go to definition
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
||||
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
|
||||
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
|
||||
|
|
@ -33,24 +46,43 @@ return {
|
|||
end,
|
||||
})
|
||||
|
||||
-- Setup language servers
|
||||
lspconfig.lua_ls.setup({
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
-- Auto-setup all installed servers
|
||||
require("mason-lspconfig").setup_handlers({
|
||||
-- Default handler for all servers
|
||||
function(server_name)
|
||||
lspconfig[server_name].setup({
|
||||
capabilities = capabilities,
|
||||
})
|
||||
end,
|
||||
|
||||
-- Custom configuration for specific servers
|
||||
["lua_ls"] = function()
|
||||
lspconfig.lua_ls.setup({
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
})
|
||||
end,
|
||||
|
||||
lspconfig.pyright.setup({
|
||||
capabilities = capabilities,
|
||||
})
|
||||
|
||||
lspconfig.tsserver.setup({
|
||||
capabilities = capabilities,
|
||||
["pyright"] = function()
|
||||
lspconfig.pyright.setup({
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
python = {
|
||||
analysis = {
|
||||
typeCheckingMode = "basic",
|
||||
autoSearchPaths = true,
|
||||
useLibraryCodeForTypes = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue