confugure lsps

This commit is contained in:
Adithya 2024-02-11 22:46:31 +05:30
parent f9be2d3a85
commit d878293de1
Signed by: adtya
GPG key ID: 48FC9915FFD326D0

View file

@ -2,11 +2,17 @@ require("lspkind").init({
mode = "symbol_text", mode = "symbol_text",
}) })
local capabilities = require("cmp_nvim_lsp").default_capabilities() local lsp_capabilities = vim.tbl_deep_extend(
"force",
require("cmp_nvim_lsp").default_capabilities(),
vim.lsp.protocol.make_client_capabilities(),
{ workspace = { didChangeConfiguration = { dynamicRegistration = true } } }
)
local lspconfig = require("lspconfig") local lspconfig = require("lspconfig")
lspconfig.lua_ls.setup({ lspconfig.lua_ls.setup({
capabilities = capabilities, capabilities = lsp_capabilities,
on_init = function(client) on_init = function(client)
local path = client.workspace_folders[1].name local path = client.workspace_folders[1].name
if not vim.loop.fs_stat(path .. "/.luarc.json") and not vim.loop.fs_stat(path .. "/.luarc.jsonc") then if not vim.loop.fs_stat(path .. "/.luarc.json") and not vim.loop.fs_stat(path .. "/.luarc.jsonc") then
@ -30,5 +36,25 @@ lspconfig.lua_ls.setup({
}) })
lspconfig.nixd.setup({ lspconfig.nixd.setup({
capabilities = capabilities, capabilities = lsp_capabilities,
})
lspconfig.gopls.setup({
capabilities = lsp_capabilities,
})
vim.keymap.set("n", "<F2>", vim.diagnostic.goto_prev)
vim.keymap.set("n", "<F3>", vim.diagnostic.goto_next)
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(ev)
vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc"
local opts = { buffer = ev.vuf }
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
end,
}) })