From ca8106210509542abf6f256d02b41631f436e75a Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Sun, 17 Oct 2021 12:44:44 +0200 Subject: [PATCH 1/3] [nvim] feat: use nvim_lsp_installer manage lsp servers through nvim's plugin !!! BREAKING: requires npm check https://github.com/williamboman/nvim-lsp-installer.git --- .config/nvim/lua/plugin/lsp_installer.lua | 29 +++++++++++++++++++++++ .config/nvim/lua/plugins.lua | 9 +++++++ 2 files changed, 38 insertions(+) create mode 100644 .config/nvim/lua/plugin/lsp_installer.lua diff --git a/.config/nvim/lua/plugin/lsp_installer.lua b/.config/nvim/lua/plugin/lsp_installer.lua new file mode 100644 index 0000000..fa6fc46 --- /dev/null +++ b/.config/nvim/lua/plugin/lsp_installer.lua @@ -0,0 +1,29 @@ +-- Author : swytch +-- Created : Saturday Sept. 11, 2021 22:12:33 CET +-- License : GPLv3 +-- Description : nvim-lsp-installer plugin config file + +local lsp_installer = require("nvim-lsp-installer") + +lsp_installer.settings { + ui = { + icons = { + server_installed = "✓", + server_pending = "➜", + server_uninstalled = "✗" + } + } +} + +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 + + -- This setup() function is exactly the same as lspconfig's setup function (:help lspconfig-quickstart) + server:setup(opts) + vim.cmd [[ do User LspAttachBuffers ]] +end) diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index dffc26d..5ce4328 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -48,6 +48,15 @@ return require("packer").startup(function() } -- LSP + use { + "williamboman/nvim-lsp-installer", + cmd = { + "LspInstall", + "LspInstallInfo" + }, + config = function() require("plugin.lsp_installer").setup() end + } + use { "neovim/nvim-lspconfig", ft = { "c", "cpp", "lua", "python", "tex"}, From 17f7b0943198cbab26a7f11854633ff9757ea332 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Sun, 17 Oct 2021 12:46:32 +0200 Subject: [PATCH 2/3] [nvim] feat: remove sumneko_lsp submodule !!! BREAKING: install sumneko_lua through nvim --- .config/nvim/lua/lsp/lua.lua | 6 ++++-- .local/share/nvim/lsp/sumneko_lua | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) delete mode 160000 .local/share/nvim/lsp/sumneko_lua diff --git a/.config/nvim/lua/lsp/lua.lua b/.config/nvim/lua/lsp/lua.lua index 892afc2..7e55549 100644 --- a/.config/nvim/lua/lsp/lua.lua +++ b/.config/nvim/lua/lsp/lua.lua @@ -6,8 +6,10 @@ local system_name = "Linux" -- set the path to the sumneko installation; if you previously installed via the now deprecated :LspInstall, use -local sumneko_root_path = globals.lsp_path .. "/sumneko_lua" -local sumneko_binary = sumneko_root_path.."/bin/"..system_name.."/lua-language-server" +local sumneko_root_path = vim.fn.stdpath("data") .. + "/lsp_servers/sumneko_lua/extension/server" +local sumneko_binary = sumneko_root_path .. "/bin/" .. system_name .. + "/lua-language-server" require'lspconfig'.sumneko_lua.setup { cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"}; diff --git a/.local/share/nvim/lsp/sumneko_lua b/.local/share/nvim/lsp/sumneko_lua deleted file mode 160000 index c876e0d..0000000 --- a/.local/share/nvim/lsp/sumneko_lua +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c876e0da1c0c2d01db9cb0c6f2914659318e0460 From 6bd3c20f7d2df141934b53de7c3c25d4e4b76387 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Sun, 17 Oct 2021 12:49:55 +0200 Subject: [PATCH 3/3] [nvim] feat: auto install lsp servers python, lua, bash, tex --- .config/nvim/lua/plugin/lsp_installer.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.config/nvim/lua/plugin/lsp_installer.lua b/.config/nvim/lua/plugin/lsp_installer.lua index fa6fc46..70e929f 100644 --- a/.config/nvim/lua/plugin/lsp_installer.lua +++ b/.config/nvim/lua/plugin/lsp_installer.lua @@ -15,6 +15,24 @@ lsp_installer.settings { } } +local servers = { + "bashls", + "jedi_language_server", + "texlab", + "sumneko_lua", +} + +for _, name in pairs(servers) do + local ok, server = lsp_installer.get_server(name) + -- Check that the server is supported in nvim-lsp-installer + if ok then + if not server:is_installed() then + print("Installing " .. name) + server:install() + end + end +end + lsp_installer.on_server_ready(function(server) local opts = {}