From cb86c87e88b92b13abee55c8bce0cdccb1526df8 Mon Sep 17 00:00:00 2001 From: siduck Date: Wed, 4 May 2022 06:55:36 +0530 Subject: [PATCH] add lsp-installer because its bette than before now! --- lua/plugins/configs/lsp_installer.lua | 36 +++++++++++++++++++++++++++ lua/plugins/configs/lspconfig.lua | 27 ++++++++++++++++++++ lua/plugins/init.lua | 12 ++++++--- 3 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 lua/plugins/configs/lsp_installer.lua diff --git a/lua/plugins/configs/lsp_installer.lua b/lua/plugins/configs/lsp_installer.lua new file mode 100644 index 0000000..4f56305 --- /dev/null +++ b/lua/plugins/configs/lsp_installer.lua @@ -0,0 +1,36 @@ +local present, lsp_installer = pcall(require, "nvim-lsp-installer") + +if not present then + return +end + +local options = { + -- ensure_installed is not needed as automatic_installation is enabled + -- then any lsp server you setup by lspconfig is going to get installed automatically! + + -- ensure_installed = { "lua" }, + automatic_installation = true, + + ui = { + icons = { + server_installed = "", + server_pending = "", + server_uninstalled = "ﮊ", + }, + keymaps = { + toggle_server_expand = "", + install_server = "i", + update_server = "u", + check_server_version = "c", + update_all_servers = "U", + check_outdated_servers = "C", + uninstall_server = "X", + }, + }, + + max_concurrent_installers = 20, +} + +options = require("core.utils").load_override(options, "williamboman/nvim-lsp-installer") + +lsp_installer.setup(options) diff --git a/lua/plugins/configs/lspconfig.lua b/lua/plugins/configs/lspconfig.lua index 8222cde..a676ccf 100644 --- a/lua/plugins/configs/lspconfig.lua +++ b/lua/plugins/configs/lspconfig.lua @@ -1,3 +1,9 @@ +local present, lspconfig = pcall(require, "lspconfig") + +if not present then + return +end + local M = {} require("plugins.configs.others").lsp_handlers() @@ -26,6 +32,27 @@ capabilities.textDocument.completion.completionItem.resolveSupport = { }, } +lspconfig.sumneko_lua.setup { + on_attach = M.on_attach, + capabilities = capabilities, + + settings = { + Lua = { + diagnostics = { + globals = { "vim" }, + }, + workspace = { + library = { + [vim.fn.expand "$VIMRUNTIME/lua"] = true, + [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true, + }, + maxPreload = 100000, + preloadFileSize = 10000, + }, + }, + }, +} + -- requires a file containing user's lspconfigs local addlsp_confs = require("core.utils").load_config().plugins.options.lspconfig.setup_lspconf diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index e0cad34..727b99c 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -93,17 +93,22 @@ local plugins = { -- lsp stuff - ["neovim/nvim-lspconfig"] = { - module = "lspconfig", + ["williamboman/nvim-lsp-installer"] = { opt = true, setup = function() - require("core.utils").packer_lazy_load "nvim-lspconfig" + require("core.utils").packer_lazy_load "nvim-lsp-installer" -- reload the current file so lsp actually starts for it vim.defer_fn(function() vim.cmd 'if &ft == "packer" | echo "" | else | silent! e %' end, 0) end, + }, + + ["neovim/nvim-lspconfig"] = { + after = "nvim-lsp-installer", + module = "lspconfig", config = function() + require "plugins.configs.lsp_installer" require "plugins.configs.lspconfig" end, }, @@ -202,7 +207,6 @@ local plugins = { -- file managing , picker etc ["kyazdani42/nvim-tree.lua"] = { cmd = { "NvimTreeToggle", "NvimTreeFocus" }, - setup = function() require("core.mappings").nvimtree() end,