From 12b8d4239d041ec21ca68e3a31bbbf11d9659419 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Fri, 10 Mar 2023 20:37:31 +0900 Subject: [PATCH] Lsp settings --- modules/home/nvim/lua/plugins/lsp.lua | 110 ++++++++++++++++++++++---- 1 file changed, 94 insertions(+), 16 deletions(-) diff --git a/modules/home/nvim/lua/plugins/lsp.lua b/modules/home/nvim/lua/plugins/lsp.lua index ad307df..5db7bd5 100644 --- a/modules/home/nvim/lua/plugins/lsp.lua +++ b/modules/home/nvim/lua/plugins/lsp.lua @@ -83,6 +83,83 @@ return { lsp_keymaps(buffer) lsp_highlight_document(client) + 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 + local ok, navic = pcall(require, "nvim-navic") if ok then navic.attach(client, buffer) @@ -90,7 +167,7 @@ return { end local lsp_capabilities = require('cmp_nvim_lsp').default_capabilities() - -- local lspconfig = require("lspconfig") + local lspconfig = require("lspconfig") return { excluded_servers = { @@ -122,24 +199,25 @@ return { }, }, tsserver = { - -- root_dir = lspconfig.util.root_pattern("yarn.lock", "package-lock.json", ".git"), - -- single_file_support = false, + root_dir = lspconfig.util.root_pattern("yarn.lock", "package-lock.json", ".git"), + single_file_support = false, }, omnisharp = { handlers = { - ["textDocument/definition"] = require('omnisharp_extended').handler, + ["textDocument/definition"] = require('omnisharp_extended').handler, }, enable_editorconfig_support = true, enable_roslyn_analyzers = true, organize_imports_on_format = true, enable_import_completion = true, cmd_env = { - ["OMNISHARP_RoslynExtensionsOptions:enableDecompilationSupport"] = true, - ["OMNISHARP_msbuild:EnablePackageAutoRestore"] = true, + ["OMNISHARP_RoslynExtensionsOptions:enableDecompilationSupport"] = true, + ["OMNISHARP_msbuild:EnablePackageAutoRestore"] = true, }, }, robotframework_ls = { - cmd = { "nix-shell", "-p", "python3", "--command", "cd /tmp && python3 -m venv venv && . venv/bin/activate && pip install robotframework_lsp RESTInstance && robotframework_ls" }, + cmd = { "nix-shell", "-p", "python3", "--command", + "cd /tmp && python3 -m venv venv && . venv/bin/activate && pip install robotframework_lsp RESTInstance && robotframework_ls" }, settings = { robot = { codeFormatter = "robotidy", @@ -148,7 +226,7 @@ return { }, nil_ls = { settings = { - ["nil"] = { + ["nil"] = { formatting = { command = { "nix-shell", "-p", "alejandra", "--run", "alejandra -" }, }, @@ -260,13 +338,13 @@ return { end, }, mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), - [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), - [""] = cmp.mapping.scroll_docs( -4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.abort(), - [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), + [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. }), sources = cmp.config.sources({ { name = "nvim_lsp" }, @@ -318,7 +396,7 @@ return { -- This relies on the presence of _opts that contains the metadata of the package. This could break. args = function(opt) local def_args = type(pkg._opts.args) == "function" and pkg._opts.args(opt) or pkg._opts.args - return { "-p", nixpkg, "--run", table.concat({pkg._opts.command, unpack(def_args)}, " ") } + return { "-p", nixpkg, "--run", table.concat({ pkg._opts.command, unpack(def_args) }, " ") } end, }) end