mirror of
https://github.com/harivansh-afk/dots.git
synced 2026-04-15 13:03:44 +00:00
Centralize dotfiles from ~ into stow packages: - zsh: .zshrc, .zshenv - git: .gitconfig - nvim: init.lua, lua/, plugin/, after/, lazy-lock.json - tmux: tmux.conf, session-list.sh - karabiner: karabiner.json - ghostty: config.ghostty - claude: CLAUDE.md, settings.json, settings.local.json, statusline.sh, 30 commands
41 lines
1.8 KiB
Lua
41 lines
1.8 KiB
Lua
-- Shared LSP utilities
|
|
local M = {}
|
|
|
|
-- Set up buffer-local keymaps when LSP attaches
|
|
function M.on_attach(client, bufnr)
|
|
local opts = { buffer = bufnr, silent = true }
|
|
|
|
-- Navigation
|
|
vim.keymap.set("n", "gd", vim.lsp.buf.definition, vim.tbl_extend("force", opts, { desc = "Go to definition" }))
|
|
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, vim.tbl_extend("force", opts, { desc = "Go to declaration" }))
|
|
vim.keymap.set("n", "<C-]>", vim.lsp.buf.definition, vim.tbl_extend("force", opts, { desc = "Go to definition" }))
|
|
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, vim.tbl_extend("force", opts, { desc = "Go to implementation" }))
|
|
vim.keymap.set("n", "gr", vim.lsp.buf.references, vim.tbl_extend("force", opts, { desc = "Go to references" }))
|
|
|
|
-- Documentation
|
|
vim.keymap.set("n", "K", vim.lsp.buf.hover, vim.tbl_extend("force", opts, { desc = "Hover documentation" }))
|
|
|
|
-- Refactoring
|
|
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, vim.tbl_extend("force", opts, { desc = "Rename symbol" }))
|
|
vim.keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, vim.tbl_extend("force", opts, { desc = "Code action" }))
|
|
|
|
-- Formatting
|
|
vim.keymap.set("n", "<leader>f", function()
|
|
vim.lsp.buf.format({ async = true })
|
|
end, vim.tbl_extend("force", opts, { desc = "Format buffer" }))
|
|
end
|
|
|
|
-- Return default capabilities for LSP servers
|
|
function M.capabilities()
|
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
|
|
-- If nvim-cmp is available, extend capabilities
|
|
local ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
|
|
if ok then
|
|
capabilities = vim.tbl_deep_extend("force", capabilities, cmp_nvim_lsp.default_capabilities())
|
|
end
|
|
|
|
return capabilities
|
|
end
|
|
|
|
return M
|