diff --git a/nvim/lua/user/lsp/configs.lua b/nvim/lua/user/lsp/configs.lua new file mode 100644 index 0000000..7b8111d --- /dev/null +++ b/nvim/lua/user/lsp/configs.lua @@ -0,0 +1,21 @@ +local lsp_installer = require("nvim-lsp-installer") +local lsp_config = require("lspconfig") + +local servers = { "sumneko_lua" } + +lsp_installer.setup { + ensure_installed = servers +} + + +for _, server in pairs(servers) do + local opts = { + on_attach = require("user.lsp.handlers").on_attach, + capabilities = require("user.lsp.handlers").capabilities, + } + local has_custom_opts, server_custom_opts = pcall(require, "user.lsp.settings." .. server) + if has_custom_opts then + opts = vim.tbl_deep_extend("force", server_custom_opts, opts) + end + lsp_config[server].setup(opts) +end diff --git a/nvim/lua/user/lsp/init.lua b/nvim/lua/user/lsp/init.lua index 6b8480e..1ef786e 100644 --- a/nvim/lua/user/lsp/init.lua +++ b/nvim/lua/user/lsp/init.lua @@ -1,3 +1,4 @@ require "lspconfig" -require "user.lsp.lsp-installer" + +require "user.lsp.configs" require "user.lsp.null-ls" diff --git a/nvim/lua/user/lsp/lsp-installer.lua b/nvim/lua/user/lsp/lsp-installer.lua deleted file mode 100644 index ae132a4..0000000 --- a/nvim/lua/user/lsp/lsp-installer.lua +++ /dev/null @@ -1,25 +0,0 @@ -local lsp_installer = require "nvim-lsp-installer" - --- Register a handler that will be called for each installed server when it's ready (i.e. when installation is finished --- or if the server is already installed). -lsp_installer.on_server_ready(function(server) - local opts = { - on_attach = require("user.lsp.handlers").on_attach, - capabilities = require("user.lsp.handlers").capabilities, - } - - -- (optional) Customize the options passed to the server - -- if server.name == "tsserver" then - -- opts.root_dir = function() ... end - -- end - -- - if server.name == "sumneko_lua" then - local sumneko_opts = require "user.lsp.settings.sumneko_lua" - opts = vim.tbl_deep_extend("force", sumneko_opts, opts) - end - - -- This setup() function will take the provided server configuration and decorate it with the necessary properties - -- before passing it onwards to lspconfig. - -- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md - server:setup(opts) -end)