mirror of
https://github.com/Cian-H/my_nvim_config.git
synced 2025-12-22 20:21:57 +00:00
99 lines
4.2 KiB
Lua
99 lines
4.2 KiB
Lua
return { -- LSP Config should be a standalone function, hence this module
|
|
{ -- LSP Configuration & Plugins
|
|
"neovim/nvim-lspconfig",
|
|
dependencies = {
|
|
-- Automatically install LSPs and related tools to stdpath for neovim
|
|
"williamboman/mason.nvim",
|
|
"williamboman/mason-lspconfig.nvim",
|
|
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
|
{ "j-hui/fidget.nvim", opts = {} }, -- Useful status updates for LSP.
|
|
{ "folke/neodev.nvim", opts = {} },
|
|
},
|
|
config = function()
|
|
require("mason").setup({
|
|
PATH = "append",
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd("LspAttach", {
|
|
group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }),
|
|
callback = function(event)
|
|
local map = function(keys, func, desc)
|
|
vim.keymap.set(
|
|
"n",
|
|
keys,
|
|
func,
|
|
{ buffer = event.buf, desc = "LSP: " .. desc }
|
|
)
|
|
end
|
|
map("gd", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition")
|
|
map("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences")
|
|
map(
|
|
"gI",
|
|
require("telescope.builtin").lsp_implementations,
|
|
"[G]oto [I]mplementation"
|
|
)
|
|
map(
|
|
"<leader>D",
|
|
require("telescope.builtin").lsp_type_definitions,
|
|
"Type [D]efinition"
|
|
)
|
|
map(
|
|
"<leader>gs",
|
|
require("telescope.builtin").lsp_document_symbols,
|
|
"[G]oto [S]ymbols"
|
|
)
|
|
map(
|
|
"<leader>ws",
|
|
require("telescope.builtin").lsp_dynamic_workspace_symbols,
|
|
"[W]orkspace [S]ymbols"
|
|
)
|
|
map("<leader>rn", vim.lsp.buf.rename, "[R]e[n]ame")
|
|
map("<leader>ca", vim.lsp.buf.code_action, "[C]ode [A]ction")
|
|
map("K", vim.lsp.buf.hover, "Hover Documentation")
|
|
map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
|
|
|
|
local client = vim.lsp.get_client_by_id(event.data.client_id)
|
|
if client and client.server_capabilities.documentHighlightProvider then
|
|
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
|
|
buffer = event.buf,
|
|
callback = vim.lsp.buf.document_highlight,
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
|
|
buffer = event.buf,
|
|
callback = vim.lsp.buf.clear_references,
|
|
})
|
|
end
|
|
end,
|
|
})
|
|
|
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
local servers = {
|
|
lua_ls = {
|
|
settings = { Lua = { completion = { callSnippet = "Replace" } } },
|
|
},
|
|
}
|
|
|
|
require("mason").setup()
|
|
local ensure_installed = vim.tbl_keys(servers or {})
|
|
require("mason-tool-installer").setup({ ensure_installed = ensure_installed })
|
|
require("mason-lspconfig").setup({
|
|
handlers = {
|
|
function(server_name)
|
|
local server = servers[server_name] or {}
|
|
server.capabilities = vim.tbl_deep_extend(
|
|
"force",
|
|
{},
|
|
capabilities,
|
|
server.capabilities or {}
|
|
)
|
|
require("lspconfig")[server_name].setup(server)
|
|
end,
|
|
},
|
|
})
|
|
end,
|
|
},
|
|
{ "fladson/vim-kitty", ft = "kitty" },
|
|
{ "scallop-lang/vim-scallop", ft = "scallop" },
|
|
}
|