neovim

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

commit a598a2ec975c34421025abb96c2b75d513b7d248
parent 221ab3a121d05b1b3ec049060352c35381f56243
Author: Tomas Nemec <nemi@skaut.cz>
Date:   Mon, 29 Nov 2021 13:14:13 +0100

update

Diffstat:
Mlua/tms/lsp/init.lua | 18+++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/lua/tms/lsp/init.lua b/lua/tms/lsp/init.lua @@ -31,11 +31,15 @@ end local attach_callbacks = {} -local custom_attach = function(client, bufnr) +local on_attach = function(client, bufnr) local lsp = vim.lsp lsp.handlers['textDocument/hover'] = lsp.with(lsp.handlers.hover, {border = 'single'}) lsp.handlers['textDocument/signatureHelp'] = lsp.with(lsp.handlers.signature_help, {border = 'single'}) - for _, cb in ipairs(attach_callbacks) do cb(client, bufnr) end + for _, cb in ipairs(attach_callbacks) do + if cb.test(client, bufnr) then -- + cb.fn(client, bufnr) + end + end keybind(bufnr) end @@ -51,13 +55,14 @@ end local add_server = function(name) local lspc = require('lspconfig') local opts = {} - opts.on_attach = custom_attach + opts.on_attach = on_attach opts.capabilities = capabilities() opts = servers.setup(name, opts) lspc[name].setup(opts) end M.setup = function() + attach_callbacks = {} -- LSP Installer local lsp_installer = require('nvim-lsp-installer') lsp_installer.on_server_ready(function(server) @@ -68,7 +73,7 @@ M.setup = function() local opts = {} opts = servers.setup(server.name, opts) - opts.on_attach = custom_attach + opts.on_attach = on_attach opts.capabilities = capabilities() if server.name == 'sumneko_lua' then @@ -87,6 +92,9 @@ M.setup = function() end M.add = function(name) add_server(name) end -M.add_attach = function(cb) table.insert(attach_callbacks, cb) end +M.add_attach = function(t) + if not t.test then t.test = function() return true end end + table.insert(attach_callbacks, t) +end return M