init.lua/after/plugin/lsp.lua

101 lines
2.4 KiB
Lua
Raw Permalink Normal View History

2024-02-11 17:31:06 +05:30
require("lspkind").init({
mode = "symbol_text",
})
2024-03-29 18:35:29 +05:30
require("lsp_lines").setup()
vim.diagnostic.config({
virtual_text = false,
})
2024-02-13 23:39:14 +05:30
local vim_lsp_capabilities = vim.lsp.protocol.make_client_capabilities()
2024-02-13 23:39:26 +05:30
vim_lsp_capabilities.textDocument.completion.completionItem.snippetSupport = true
2024-02-11 22:46:31 +05:30
local lsp_capabilities = vim.tbl_deep_extend(
"force",
require("cmp_nvim_lsp").default_capabilities(),
2024-02-13 23:39:14 +05:30
vim_lsp_capabilities,
2024-02-11 22:46:31 +05:30
{ workspace = { didChangeConfiguration = { dynamicRegistration = true } } }
)
2024-02-11 14:02:09 +05:30
local lspconfig = require("lspconfig")
2024-02-14 22:01:42 +05:30
lspconfig.bashls.setup({
capabilities = lsp_capabilities,
})
2024-02-24 19:22:46 +05:30
lspconfig.cssls.setup({
capabilities = lsp_capabilities,
})
lspconfig.cssmodules_ls.setup({
capabilities = lsp_capabilities,
})
2024-02-13 23:39:14 +05:30
lspconfig.gopls.setup({
capabilities = lsp_capabilities,
})
2024-02-13 23:39:26 +05:30
lspconfig.jsonls.setup({
capabilities = lsp_capabilities,
})
2024-02-11 14:02:09 +05:30
lspconfig.lua_ls.setup({
2024-02-11 22:46:31 +05:30
capabilities = lsp_capabilities,
2024-02-11 14:02:09 +05:30
on_init = function(client)
local path = client.workspace_folders[1].name
2024-03-29 18:35:29 +05:30
if vim.uv.fs_stat(path .. "/.luarc.json") and not vim.uv.fs_stat(path .. "/.luarc.jsonc") then
2024-03-10 09:50:49 +05:30
return
2024-02-11 14:02:09 +05:30
end
2024-03-10 09:50:49 +05:30
client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, {
runtime = {
version = "LuaJIT",
},
workspace = {
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME,
},
},
})
2024-02-11 14:02:09 +05:30
end,
2024-03-10 09:50:49 +05:30
settings = {
Lua = {},
},
2024-02-11 14:02:09 +05:30
})
2024-06-09 18:19:41 +05:30
lspconfig.nil_ls.setup({
2024-02-11 22:46:31 +05:30
capabilities = lsp_capabilities,
})
2024-04-21 18:34:22 +05:30
lspconfig.ruby_lsp.setup({
2024-02-14 22:01:42 +05:30
capabilities = lsp_capabilities,
})
2024-03-29 18:35:29 +05:30
lspconfig.rust_analyzer.setup({
2024-02-24 19:22:54 +05:30
capabilities = lsp_capabilities,
})
lspconfig.volar.setup({
capabilities = lsp_capabilities,
2024-03-29 18:35:29 +05:30
filetypes = { "typescript", "javascript", "javascriptreact", "typescriptreact", "vue", "json" },
2024-02-24 19:22:54 +05:30
})
2024-02-11 22:46:31 +05:30
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,
2024-02-11 17:31:06 +05:30
})
2024-03-10 09:50:49 +05:30
-- refer https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md