92 lines
3.1 KiB
Lua
92 lines
3.1 KiB
Lua
return {
|
|
'neovim/nvim-lspconfig',
|
|
dependencies = { 'saghen/blink.cmp', 'ibhagwan/fzf-lua', {
|
|
"nvimdev/lspsaga.nvim",
|
|
event = "LspAttach",
|
|
opts = {
|
|
ui = {
|
|
border = "shadow",
|
|
},
|
|
outline = {
|
|
layout = "float",
|
|
},
|
|
},
|
|
}, },
|
|
|
|
-- example using `opts` for defining servers
|
|
opts = {
|
|
servers = {
|
|
neocmakelsp = {},
|
|
lua_ls = {},
|
|
clangd = {
|
|
cmd = {
|
|
-- "/opt/clangd/bin/clangd",
|
|
"clangd",
|
|
"--compile-commands-dir=build",
|
|
"--all-scopes-completion",
|
|
"--background-index",
|
|
"--clang-tidy",
|
|
"--completion-style=bundled",
|
|
"--experimental-modules-support",
|
|
"--function-arg-placeholders=1",
|
|
"--header-insertion=iwyu",
|
|
"--header-insertion-decorators",
|
|
"--malloc-trim",
|
|
"--pch-storage=memory"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
config = function(_, opts)
|
|
vim.api.nvim_create_autocmd("LspAttach", {
|
|
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
|
|
callback = function(ev)
|
|
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
|
if client and client.server_capabilities.inlayHintProvider then
|
|
vim.lsp.inlay_hint.enable(true)
|
|
end
|
|
end,
|
|
})
|
|
|
|
for server, config in pairs(opts.servers) do
|
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
capabilities.textDocument.foldingRange = {
|
|
dynamicRegistration = false,
|
|
lineFoldingOnly = true,
|
|
}
|
|
config.capabilities = require("blink.cmp").get_lsp_capabilities(capabilities)
|
|
vim.lsp.config(server, config)
|
|
vim.lsp.enable(server)
|
|
end
|
|
|
|
vim.api.nvim_create_user_command("LspInfo", "checkhealth vim.lsp", {
|
|
desc = "Show LSP Info",
|
|
})
|
|
|
|
vim.api.nvim_create_user_command("LspLog", function(_)
|
|
local log_path = vim.lsp.log.get_filename()
|
|
vim.cmd(string.format("edit %s", log_path))
|
|
end, {
|
|
desc = "Show LSP log",
|
|
})
|
|
|
|
vim.api.nvim_create_user_command("LspRestart", "lsp restart", {
|
|
desc = "Restart LSP",
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd("LspProgress", {
|
|
callback = function(ev)
|
|
local value = ev.data.params.value
|
|
vim.api.nvim_echo({ { value.message or "done" } }, false, {
|
|
id = "lsp." .. ev.data.client_id,
|
|
kind = "progress",
|
|
source = "vim.lsp",
|
|
title = value.title,
|
|
status = value.kind ~= "end" and "running" or "success",
|
|
percent = value.percentage,
|
|
})
|
|
end,
|
|
})
|
|
end,
|
|
}
|