From e22fab6563ab2802dc4631714453da174e23b8de Mon Sep 17 00:00:00 2001 From: Ariel D'Alessandro Date: Wed, 27 Oct 2021 08:15:28 +0200 Subject: update lsp install library due being deprecated --- plugin/lsp.vim | 70 ++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 27 deletions(-) (limited to 'plugin') diff --git a/plugin/lsp.vim b/plugin/lsp.vim index 7905181..0c5b6fe 100644 --- a/plugin/lsp.vim +++ b/plugin/lsp.vim @@ -62,32 +62,48 @@ local function on_attach() vim.api.nvim_set_keymap('n', 'K', ':lua vim.lsp.buf.hover()', {noremap = true}) end -local function setup_servers() - require'lspinstall'.setup() - local servers = require'lspinstall'.installed_servers() - for _, server in pairs(servers) do - if server == 'lua' then - require'lspconfig'.lua.setup { - on_attach=on_attach, - settings = { - Lua = { - diagnostics = { - globals = { 'vim' } - } - } - }, - } - else - require'lspconfig'[server].setup{ on_attach=on_attach } - end - end -end - -setup_servers() - -require'lspinstall'.post_install_hook = function () - setup_servers() - vim.cmd("bufdo e") -end +local lsp_installer = require("nvim-lsp-installer") + +lsp_installer.on_server_ready(function(server) + local opts = {} + + -- (optional) Customize the options passed to the server + -- if server.name == "tsserver" then + -- opts.root_dir = function() ... end + -- end + opts.on_attach = on_attach + + -- This setup() function is exactly the same as lspconfig's setup function (:help lspconfig-quickstart) + server:setup(opts) + vim.cmd [[ do User LspAttachBuffers ]] +end) + +-- local function setup_servers() +-- require'lspinstall'.setup() +-- local servers = require'lspinstall'.installed_servers() +-- for _, server in pairs(servers) do +-- if server == 'lua' then +-- require'lspconfig'.lua.setup { +-- on_attach=on_attach, +-- settings = { +-- Lua = { +-- diagnostics = { +-- globals = { 'vim' } +-- } +-- } +-- }, +-- } +-- else +-- require'lspconfig'[server].setup{ on_attach=on_attach } +-- end +-- end +-- end + +-- setup_servers() + +-- require'lspinstall'.post_install_hook = function () +-- setup_servers() +-- vim.cmd("bufdo e") +-- end EOF -- cgit v1.2.3