162 lines
5.0 KiB
Lua
162 lines
5.0 KiB
Lua
local M = {}
|
|
|
|
local status_cmp_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
|
|
if not status_cmp_ok then
|
|
return
|
|
end
|
|
|
|
M.capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
M.capabilities.textDocument.completion.completionItem.snippetSupport = true
|
|
M.capabilities = cmp_nvim_lsp.default_capabilities(M.capabilities)
|
|
M.capabilities.offsetEncoding = 'utf-16'
|
|
|
|
M.setup = function()
|
|
local signs = {
|
|
{ name = "DiagnosticSignError", text = "" },
|
|
{ name = "DiagnosticSignWarn", text = "" },
|
|
{ name = "DiagnosticSignHint", text = "" },
|
|
{ name = "DiagnosticSignInfo", text = "" },
|
|
}
|
|
|
|
for _, sign in ipairs(signs) do
|
|
vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
|
|
end
|
|
|
|
local config = {
|
|
virtual_text = false, -- disable virtual text
|
|
signs = {
|
|
active = signs, -- show signs
|
|
},
|
|
update_in_insert = true,
|
|
underline = true,
|
|
severity_sort = true,
|
|
float = {
|
|
focusable = true,
|
|
style = "minimal",
|
|
border = "rounded",
|
|
source = "always",
|
|
header = "",
|
|
prefix = "",
|
|
},
|
|
}
|
|
|
|
vim.diagnostic.config(config)
|
|
|
|
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
|
|
border = "rounded",
|
|
})
|
|
|
|
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
|
|
border = "rounded",
|
|
})
|
|
end
|
|
|
|
local function lsp_keymaps(bufnr)
|
|
local opts = { noremap = true, silent = true }
|
|
local keymap = vim.api.nvim_buf_set_keymap
|
|
keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
|
keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
|
keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
|
keymap(bufnr, "n", "gI", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
|
keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
|
|
keymap(bufnr, "n", "gl", "<cmd>lua vim.diagnostic.open_float()<CR>", opts)
|
|
keymap(bufnr, "n", "<leader>lf", "<cmd>lua vim.lsp.buf.format{ async = true }<cr>", opts)
|
|
keymap(bufnr, "n", "<leader>li", "<cmd>LspInfo<cr>", opts)
|
|
keymap(bufnr, "n", "<leader>lI", "<cmd>LspInstallInfo<cr>", opts)
|
|
keymap(bufnr, "n", "<leader>la", "<cmd>lua vim.lsp.buf.code_action()<cr>", opts)
|
|
keymap(bufnr, "n", "<leader>lj", "<cmd>lua vim.diagnostic.goto_next({buffer=0})<cr>", opts)
|
|
keymap(bufnr, "n", "<leader>lk", "<cmd>lua vim.diagnostic.goto_prev({buffer=0})<cr>", opts)
|
|
keymap(bufnr, "n", "<leader>lr", "<cmd>lua vim.lsp.buf.rename()<cr>", opts)
|
|
keymap(bufnr, "n", "<leader>ls", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
|
keymap(bufnr, "n", "<leader>lq", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
|
|
end
|
|
|
|
M.on_attach = function(client, bufnr)
|
|
|
|
if client.name == "omnisharp" then
|
|
client.server_capabilities.semanticTokensProvider = {
|
|
full = vim.empty_dict(),
|
|
legend = {
|
|
tokenModifiers = { "static_symbol" },
|
|
tokenTypes = {
|
|
"comment",
|
|
"excluded_code",
|
|
"identifier",
|
|
"keyword",
|
|
"keyword_control",
|
|
"number",
|
|
"operator",
|
|
"operator_overloaded",
|
|
"preprocessor_keyword",
|
|
"string",
|
|
"whitespace",
|
|
"text",
|
|
"static_symbol",
|
|
"preprocessor_text",
|
|
"punctuation",
|
|
"string_verbatim",
|
|
"string_escape_character",
|
|
"class_name",
|
|
"delegate_name",
|
|
"enum_name",
|
|
"interface_name",
|
|
"module_name",
|
|
"struct_name",
|
|
"type_parameter_name",
|
|
"field_name",
|
|
"enum_member_name",
|
|
"constant_name",
|
|
"local_name",
|
|
"parameter_name",
|
|
"method_name",
|
|
"extension_method_name",
|
|
"property_name",
|
|
"event_name",
|
|
"namespace_name",
|
|
"label_name",
|
|
"xml_doc_comment_attribute_name",
|
|
"xml_doc_comment_attribute_quotes",
|
|
"xml_doc_comment_attribute_value",
|
|
"xml_doc_comment_cdata_section",
|
|
"xml_doc_comment_comment",
|
|
"xml_doc_comment_delimiter",
|
|
"xml_doc_comment_entity_reference",
|
|
"xml_doc_comment_name",
|
|
"xml_doc_comment_processing_instruction",
|
|
"xml_doc_comment_text",
|
|
"xml_literal_attribute_name",
|
|
"xml_literal_attribute_quotes",
|
|
"xml_literal_attribute_value",
|
|
"xml_literal_cdata_section",
|
|
"xml_literal_comment",
|
|
"xml_literal_delimiter",
|
|
"xml_literal_embedded_expression",
|
|
"xml_literal_entity_reference",
|
|
"xml_literal_name",
|
|
"xml_literal_processing_instruction",
|
|
"xml_literal_text",
|
|
"regex_comment",
|
|
"regex_character_class",
|
|
"regex_anchor",
|
|
"regex_quantifier",
|
|
"regex_grouping",
|
|
"regex_alternation",
|
|
"regex_text",
|
|
"regex_self_escaped_character",
|
|
"regex_other_escape",
|
|
},
|
|
},
|
|
range = true,
|
|
}
|
|
end
|
|
|
|
lsp_keymaps(bufnr)
|
|
local status_ok, illuminate = pcall(require, "illuminate")
|
|
if not status_ok then
|
|
return
|
|
end
|
|
illuminate.on_attach(client)
|
|
end
|
|
|
|
return M
|