neovim

Personal neovim configuration files
git clone git://gtms.dev:neovim
Log | Files | Refs

commit aec38929dc87ec537a3d7ffa981ded3df5a7fc1d
parent aa46651b351dc85fc20bf52ffb7988ddc8196067
Author: Tomas Nemec <owl@gtms.dev>
Date:   Tue,  6 Jun 2023 00:10:28 +0200

update

Diffstat:
Mafter/plugin/lsp.lua | 23+++++++++++------------
Mafter/plugin/refactoring.lua | 18+++++++++---------
Mlua/tms/lsp/request.lua | 2+-
Mlua/tms/lsp/servers.lua | 18+++++++++++++++---
4 files changed, 36 insertions(+), 25 deletions(-)

diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua @@ -10,20 +10,19 @@ vim.api.nvim_create_autocmd('LspAttach', { group = lsp_group, callback = function(args) local buf = args.buf - local client = vim.lsp.get_client_by_id(args.data.client_id) - local cap = client.server_capabilities local lb = vim.lsp.buf + local client = vim.lsp.get_client_by_id(args.data.client_id) local opt = function(desc) return { buffer = buf, desc = desc } end - cap.semanticTokensProvider = nil + -- cap.semanticTokensProvider = nil - if cap.hoverProvider then + if client.supports_method('textDocument/hover') then vim.keymap.set('n', 'K', lb.hover, opt 'LSP Hover') end - if cap.definitionProvider then + if client.supports_method('textDocument/definition') then vim.keymap.set('n', 'gd', lb.definition, opt 'LSP Definition') vim.keymap.set('n', 'gD', '<cmd>vsplit | lua vim.lsp.buf.definition()<cr>', opt('LSP definition in vsplit')) end @@ -31,28 +30,28 @@ vim.api.nvim_create_autocmd('LspAttach', { -- if cap.typeDefinitionProvider then -- vim.keymap.set('n', 'gT', lb.type_definition, opt('LSP Type Definition')) -- end - if cap.implementationProvider then + if client.supports_method('textDocument/implementation') then vim.keymap.set('n', 'gm', lb.implementation, opt('LSP Implementation')) end - if cap.signatureHelpProvider then + if client.supports_method('textDocument/signatureHelp') then vim.keymap.set('n', '<c-p>', lb.signature_help, opt('LSP Signature Help')) vim.keymap.set('i', '<c-p>', lb.signature_help, opt('LSP Signature Help')) end - if cap.referencesProvider then + if client.supports_method('textDocument/references') then vim.keymap.set('n', 'gr', lb.references, opt('LSP References')) end - if cap.codeActionProvider then + if client.supports_method('textDocument/codeAction') then vim.keymap.set({ 'n', 'v' }, 'ga', lb.code_action, opt('LSP Code Actions')) end - if cap.documentHighlightProvider then + if client.supports_method('textDocument/documentHighlight') then vim.keymap.set('n', '<leader>k', lb.document_highlight, opt('LSP Highlight')) vim.api.nvim_create_autocmd('CursorMoved', { group = lsp_group, buffer = buf, callback = vim.lsp.buf.clear_references }) end - if cap.renameProvider then + if client.supports_method('textDocument/rename') then vim.keymap.set('n', 'cd', lb.rename, opt('LSP Rename (change definition')) end - if cap.typeHierarchyProvider then + if client.supports_method('textDocument/prepareTypeHierarchy') then vim.keymap.set('n', 'gh', function() require('tms.lsp.request').type_hierarchy('subtypes') end, opt('LSP Subtypes')) diff --git a/after/plugin/refactoring.lua b/after/plugin/refactoring.lua @@ -7,38 +7,38 @@ refactor.setup({ printf_statements = { dart = { 'print("%s");' } } }) vim.keymap.set('n', '<space>re', function() require('refactoring').refactor('Extract Function') -end, { silent = true }) +end, { silent = true, desc = 'Refactor Extract Function' }) vim.keymap.set('v', '<space>rf', function() require('refactoring').refactor('Extract Function To File') -end, { silent = true }) +end, { silent = true, desc = 'Refactor Extract Function To File' }) vim.keymap.set('n', '<space>rv', function() require('refactoring').refactor('Extract Variable') -end, { silent = true }) +end, { silent = true, desc = 'Refactor Extract Variable' }) vim.keymap.set('n', '<space>ri', function() require('refactoring').refactor('Inline Variable') -end, { silent = true }) +end, { silent = true, desc = 'Refactor Inline Variable' }) vim.keymap.set('v', '<space>rr', function() require('refactoring').select_refactor() -end, { silent = true }) +end, { silent = true, desc = 'Refactor Select Refactor' }) vim.keymap.set('n', '<space>rp', function() require('refactoring').debug.printf({ below = false }) -end, {}) +end, { desc = 'Refactor Debug PrintF' }) -- Remap in normal mode and passing { normal = true } will automatically find the variable under the cursor and print it vim.keymap.set('n', '<space>rv', function() require('refactoring').debug.print_var({ normal = true }) -end, {}) +end, { desc = 'Refactor Debug Print Var' }) -- Remap in visual mode will print whatever is in the visual selection vim.keymap.set('v', '<space>rv', function() require('refactoring').debug.print_var({}) -end, {}) +end, { desc = 'Refactor Debug Print Var' }) -- Cleanup function: this remap should be made in normal mode vim.keymap.set('n', '<space>rc', function() require('refactoring').debug.cleanup({}) -end, {}) +end, { desc = 'Refactor Debug Cleanup' }) diff --git a/lua/tms/lsp/request.lua b/lua/tms/lsp/request.lua @@ -55,7 +55,7 @@ function M.type_hierarchy(method) client.request(method, { item = type_hierarchy_item }, nil, ctx.bufnr) else vim.notify(string.format('Client with id=%d disappeared during type hierarchy request', ctx.client_id), - vim.log.levels.WARN) + vim.log.levels.WARN) end end) end diff --git a/lua/tms/lsp/servers.lua b/lua/tms/lsp/servers.lua @@ -4,7 +4,8 @@ local M = {} function M.jsonls(opts) if pcall(require, 'schemastore') then opts.settings = { - json = { -- + json = { + -- schemas = require('schemastore').json.schemas(), validate = { enable = true }, }, @@ -16,7 +17,8 @@ end function M.yamlls(opts) opts.settings = { - yaml = { -- + yaml = { + -- schemas = require('schemastore').json.schemas(), validate = { enable = true }, }, @@ -37,7 +39,8 @@ function M.lua_ls(opts) Lua = { -- runtime = { version = 'LuaJIT' }, - diagnostics = { -- + diagnostics = { + -- globals = { 'vim' }, disable = { 'missing-parameter' }, }, @@ -70,6 +73,15 @@ function M.dartls(opts) opts = dart_tools_lsp.make_opts(opts) opts.settings.dart.lineLength = 120 end + + opts.capabilities.textDocument.definition.dnamicRegistration = false + opts.capabilities.textDocument.formatting.dynamicRegistration = false + opts.capabilities.textDocument.rangeFormatting.dynamicRegistration = false + opts.capabilities.textDocument.hover.dynamicRegistration = false + opts.capabilities.textDocument.rename.dynamicRegistration = false + opts.capabilities.textDocument.codeAction.dynamicRegistration = false + opts.capabilities.workspace.didChangeWatchedFiles.dynamicRegistration = false + return opts end