From e6cf9b4a9d5fc440b8d7a93c30290f20e1685540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Dudr?= Date: Fri, 10 Mar 2023 20:11:56 +0100 Subject: [PATCH] nvim: mason --- dot_config/nvim/after/ftplugin/xml.vim | 1 + dot_config/nvim/ftdetect/dotnet.vim | 1 + dot_config/nvim/lua/configs/packages/dap.lua | 17 +- dot_config/nvim/lua/configs/packages/lsp.lua | 178 ++++++++++-------- dot_config/nvim/lua/configs/packages/misc.lua | 7 +- 5 files changed, 118 insertions(+), 86 deletions(-) create mode 100644 dot_config/nvim/after/ftplugin/xml.vim diff --git a/dot_config/nvim/after/ftplugin/xml.vim b/dot_config/nvim/after/ftplugin/xml.vim new file mode 100644 index 0000000..1b4c30f --- /dev/null +++ b/dot_config/nvim/after/ftplugin/xml.vim @@ -0,0 +1 @@ +setlocal tabstop=2 shiftwidth=2 diff --git a/dot_config/nvim/ftdetect/dotnet.vim b/dot_config/nvim/ftdetect/dotnet.vim index a67d76f..23b65e2 100644 --- a/dot_config/nvim/ftdetect/dotnet.vim +++ b/dot_config/nvim/ftdetect/dotnet.vim @@ -1,3 +1,4 @@ autocmd BufRead,BufNewFile Directory.Build.props set ft=xml autocmd BufRead,BufNewFile Directory.Build.targets set ft=xml +autocmd BufRead,BufNewFile *.axaml set ft=xml autocmd BufRead,BufNewFile *.cake set filetype=cs diff --git a/dot_config/nvim/lua/configs/packages/dap.lua b/dot_config/nvim/lua/configs/packages/dap.lua index 0feacd6..e69ac72 100644 --- a/dot_config/nvim/lua/configs/packages/dap.lua +++ b/dot_config/nvim/lua/configs/packages/dap.lua @@ -1,7 +1,18 @@ return { { 'mfussenegger/nvim-dap', + init = function () + local php = require("mason-registry").get_package('php-debug-adapter') + if not php:is_installed() then + php:install() + end + end, + dependencies = { 'rcarriga/nvim-dap-ui', + 'williamboman/mason.nvim', + + + }, keys = { { '', function() require('dap').step_over() end }, @@ -74,12 +85,6 @@ return { end end, }, - { 'xdebug/vscode-php-debug', - build = { 'npm install && npm run build' }, - config = false, - module = false, - lazy = true, - }, { 'leoluz/nvim-dap-go', ft = 'go', config = true, diff --git a/dot_config/nvim/lua/configs/packages/lsp.lua b/dot_config/nvim/lua/configs/packages/lsp.lua index e63fe12..81159fd 100644 --- a/dot_config/nvim/lua/configs/packages/lsp.lua +++ b/dot_config/nvim/lua/configs/packages/lsp.lua @@ -52,9 +52,9 @@ local function on_attach(args) -- {{{ if client.server_capabilities.codeLensProvider then vim.api.nvim_create_autocmd( { 'BufEnter', 'CursorHold', 'InsertLeave' }, { - callback = vim.lsp.codelens.refresh, - buffer = bufnr, - }) + callback = vim.lsp.codelens.refresh, + buffer = bufnr, + }) end vim.keymap.set('n', 'cl', vim.lsp.codelens.run, mkOpts('LSP Run code lens')) vim.keymap.set('n', 'ci', vim.lsp.buf.implementation, mkOpts('LSP implementation')) @@ -69,8 +69,8 @@ local function on_attach(args) -- {{{ vim.keymap.set('n', 'cr', 'Trouble lsp_references', mkOpts('LSP references')) vim.keymap.set( { 'v', 'n' }, 'F', function() - vim.lsp.buf.format({ async = true, filter = formatting_filter }) - end, + vim.lsp.buf.format({ async = true, filter = formatting_filter }) + end, mkOpts('Lsp Format') ) @@ -82,71 +82,71 @@ local function on_attach(args) -- {{{ client.server_capabilities.semanticTokensProvider.legend = { tokenModifiers = { 'static' }, tokenTypes = { - 'comment', -- "comment", - 'comment', -- "excluded_code", - 'identifier', -- "identifier", - 'keyword', -- "keyword", - 'keyword', -- "keyword_control", - 'number', -- "number", - 'operator', -- "operator", - 'operator', -- "operator_overloaded", - 'preproc', -- "preprocessor_keyword", - 'string', -- "string", - 'whitespace', -- "whitespace", - 'text', -- "text", - 'static', -- "static_symbol", - 'preproc', -- "preprocessor_text", - 'punctuation', -- "punctuation", - 'string.escape', -- "string_verbatim", + 'comment', -- "comment", + 'comment', -- "excluded_code", + 'identifier', -- "identifier", + 'keyword', -- "keyword", + 'keyword', -- "keyword_control", + 'number', -- "number", + 'operator', -- "operator", + 'operator', -- "operator_overloaded", + 'preproc', -- "preprocessor_keyword", + 'string', -- "string", + 'whitespace', -- "whitespace", + 'text', -- "text", + 'static', -- "static_symbol", + 'preproc', -- "preprocessor_text", + 'punctuation', -- "punctuation", + 'string.escape', -- "string_verbatim", 'character.special', -- "string_escape_character", - 'class', -- "class_name", - 'type', -- "delegate_name", - 'enum', -- "enum_name", - 'interface', -- "interface_name", - 'namespace', -- "module_name", - 'struct', -- "struct_name", - 'typeParameter', -- "type_parameter_name", - 'field', -- "field_name", - 'enumMember', -- "enum_member_name", - 'constant', -- "constant_name", - 'variable', -- "local_name", - 'parameter', -- "parameter_name", - 'method', -- "method_name", - 'method', -- "extension_method_name", - 'property', -- "property_name", - 'event', -- "event_name", - 'namespace', -- "namespace_name", - 'label', -- "label_name", - 'text.literal', -- "xml_doc_comment_attribute_name", - 'text.literal', -- "xml_doc_comment_attribute_quotes", - 'text.literal', -- "xml_doc_comment_attribute_value", - 'text.literal', -- "xml_doc_comment_cdata_section", - 'text.literal', -- "xml_doc_comment_comment", - 'text.literal', -- "xml_doc_comment_delimiter", - 'text.literal', -- "xml_doc_comment_entity_reference", - 'text.literal', -- "xml_doc_comment_name", - 'text.literal', -- "xml_doc_comment_processing_instruction", - 'text.literal', -- "xml_doc_comment_text", - 'text.literal', -- "xml_literal_attribute_name", - 'text.literal', -- "xml_literal_attribute_quotes", - 'text.literal', -- "xml_literal_attribute_value", - 'text.literal', -- "xml_literal_cdata_section", - 'text.literal', -- "xml_literal_comment", - 'text.literal', -- "xml_literal_delimiter", - 'text.literal', -- "xml_literal_embedded_expression", - 'text.literal', -- "xml_literal_entity_reference", - 'text.literal', -- "xml_literal_name", - 'text.literal', -- "xml_literal_processing_instruction", - 'text.literal', -- "xml_literal_text", - 'regexp', -- "regex_comment", - 'regexp', -- "regex_character_class", - 'regexp', -- "regex_anchor", - 'regexp', -- "regex_quantifier", - 'regexp', -- "regex_grouping", - 'regexp', -- "regex_alternation", - 'regexp', -- "regex_text", - 'regexp', -- "regex_self_escaped_character", - 'regexp' -- "regex_other_escape", + 'class', -- "class_name", + 'type', -- "delegate_name", + 'enum', -- "enum_name", + 'interface', -- "interface_name", + 'namespace', -- "module_name", + 'struct', -- "struct_name", + 'typeParameter', -- "type_parameter_name", + 'field', -- "field_name", + 'enumMember', -- "enum_member_name", + 'constant', -- "constant_name", + 'variable', -- "local_name", + 'parameter', -- "parameter_name", + 'method', -- "method_name", + 'method', -- "extension_method_name", + 'property', -- "property_name", + 'event', -- "event_name", + 'namespace', -- "namespace_name", + 'label', -- "label_name", + 'text.literal', -- "xml_doc_comment_attribute_name", + 'text.literal', -- "xml_doc_comment_attribute_quotes", + 'text.literal', -- "xml_doc_comment_attribute_value", + 'text.literal', -- "xml_doc_comment_cdata_section", + 'text.literal', -- "xml_doc_comment_comment", + 'text.literal', -- "xml_doc_comment_delimiter", + 'text.literal', -- "xml_doc_comment_entity_reference", + 'text.literal', -- "xml_doc_comment_name", + 'text.literal', -- "xml_doc_comment_processing_instruction", + 'text.literal', -- "xml_doc_comment_text", + 'text.literal', -- "xml_literal_attribute_name", + 'text.literal', -- "xml_literal_attribute_quotes", + 'text.literal', -- "xml_literal_attribute_value", + 'text.literal', -- "xml_literal_cdata_section", + 'text.literal', -- "xml_literal_comment", + 'text.literal', -- "xml_literal_delimiter", + 'text.literal', -- "xml_literal_embedded_expression", + 'text.literal', -- "xml_literal_entity_reference", + 'text.literal', -- "xml_literal_name", + 'text.literal', -- "xml_literal_processing_instruction", + 'text.literal', -- "xml_literal_text", + 'regexp', -- "regex_comment", + 'regexp', -- "regex_character_class", + 'regexp', -- "regex_anchor", + 'regexp', -- "regex_quantifier", + 'regexp', -- "regex_grouping", + 'regexp', -- "regex_alternation", + 'regexp', -- "regex_text", + 'regexp', -- "regex_self_escaped_character", + 'regexp' -- "regex_other_escape", }, } end @@ -164,7 +164,7 @@ local function config() -- Use a loop to conveniently both setup defined servers -- and map buffer local keybindings when the language server attaches local servers = { - powershell_es = { bundle_path = '/home/vladimir/devel/PowerShellEditorServices/module' }, + powershell_es = {}, gopls = {}, clangd = {}, zls = {}, @@ -212,10 +212,10 @@ local function config() handlers = { ['textDocument/publishDiagnostics'] = vim.lsp.with( vim.lsp.diagnostic.on_publish_diagnostics, { - virtual_text = { - severity = vim.diagnostic.severity.ERROR, - }, - } + virtual_text = { + severity = vim.diagnostic.severity.ERROR, + }, + } ), }, root_dir = function(startpath) @@ -260,18 +260,35 @@ local function config() }, -- }}} } + local mlsp = require('mason-lspconfig') + local available = mlsp.get_available_servers() + local ensure = {} local capabilities = require('cmp_nvim_lsp').default_capabilities() for name, conf in pairs(servers) do conf.capabilities = capabilities nvim_lsp[name].setup(conf) + if vim.tbl_contains(available, name) then + ensure[#ensure + 1] = name + end end + + mlsp.setup({ ensure_installed = ensure }) end return { - { 'neovim/nvim-lspconfig', + { + 'neovim/nvim-lspconfig', dependencies = { - { 'j-hui/fidget.nvim', config = true }, - { 'ray-x/lsp_signature.nvim', opts = { hint_prefix = '⥊ ', floating_window = false, hint_scheme = 'Identifier' } }, + { 'j-hui/fidget.nvim', config = true }, + { + 'ray-x/lsp_signature.nvim', + opts = { + hint_prefix = '⥊ ', + floating_window = false, + hint_scheme = 'Identifier' + }, + }, + { 'williamboman/mason-lspconfig.nvim' }, }, keys = { { 'li', 'LspInfo', desc = 'Lsp info' }, @@ -284,4 +301,11 @@ return { { 'Hoffs/omnisharp-extended-lsp.nvim', lazy = true }, { 'b0o/schemastore.nvim', lazy = true }, { 'folke/neodev.nvim', lazy = true }, + { + 'williamboman/mason.nvim', + cmd = 'Mason', + keys = {}, + opts = {}, + config = true, + }, } diff --git a/dot_config/nvim/lua/configs/packages/misc.lua b/dot_config/nvim/lua/configs/packages/misc.lua index 4a7f844..61cec6e 100644 --- a/dot_config/nvim/lua/configs/packages/misc.lua +++ b/dot_config/nvim/lua/configs/packages/misc.lua @@ -87,7 +87,7 @@ return { }, }, - { 'dyng/ctrlsf.vim', cmd = 'CtrlSF' }, + { 'dyng/ctrlsf.vim', cmd = 'CtrlSF' }, { 'andymass/vim-matchup', event = 'BufRead', @@ -113,8 +113,9 @@ return { end, }, - { 'fpob/nette.vim', ft = 'nette' }, - { 'ziglang/zig.vim', ft = 'zig' }, + { 'fpob/nette.vim', ft = 'nette' }, + { 'ziglang/zig.vim', ft = 'zig' }, + { 'chrisbra/csv.vim', ft = 'csv' }, { 'mfussenegger/nvim-jdtls',