summaryrefslogtreecommitdiff
path: root/lua/user/lsp
diff options
context:
space:
mode:
authorLouie S <louie@example.com>2022-11-03 20:18:41 -0700
committerLouie S <louie@example.com>2022-11-03 21:15:14 -0700
commitf3f96306badc6abdaab4a6f0b61b19e4e27dbdb0 (patch)
tree9f28335609b4ded0016c46206b89cd82d9494df3 /lua/user/lsp
parent542922d9c8ddd75d3c594dee9e100593174f997d (diff)
Updated nvim-lsp-installer to mason
Diffstat (limited to 'lua/user/lsp')
-rw-r--r--lua/user/lsp/init.lua2
-rw-r--r--lua/user/lsp/lsp-installer.lua33
-rw-r--r--lua/user/lsp/mason.lua46
3 files changed, 47 insertions, 34 deletions
diff --git a/lua/user/lsp/init.lua b/lua/user/lsp/init.lua
index a62e7aa..16f3b88 100644
--- a/lua/user/lsp/init.lua
+++ b/lua/user/lsp/init.lua
@@ -3,5 +3,5 @@ if not status_ok then
return
end
-require("user.lsp.lsp-installer")
+require("user.lsp.mason")
require("user.lsp.handlers").setup()
diff --git a/lua/user/lsp/lsp-installer.lua b/lua/user/lsp/lsp-installer.lua
deleted file mode 100644
index f539050..0000000
--- a/lua/user/lsp/lsp-installer.lua
+++ /dev/null
@@ -1,33 +0,0 @@
-local status_ok, lsp_installer = pcall(require, "nvim-lsp-installer")
-if not status_ok then
- return
-end
-
--- Register a handler that will be called for all installed servers.
--- Alternatively, you may also register handlers on specific server instances instead (see example below).
-lsp_installer.on_server_ready(function(server)
- local opts = {
- on_attach = require("user.lsp.handlers").on_attach,
- capabilities = require("user.lsp.handlers").capabilities,
- }
-
- if server.name == "jsonls" then
- local jsonls_opts = require("user.lsp.settings.jsonls")
- opts = vim.tbl_deep_extend("force", jsonls_opts, opts)
- 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
-
- if server.name == "pyright" then
- local pyright_opts = require("user.lsp.settings.pyright")
- opts = vim.tbl_deep_extend("force", pyright_opts, opts)
- end
-
- -- This setup() function is exactly the same as lspconfig's setup function.
- -- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
- server:setup(opts)
-end)
-
diff --git a/lua/user/lsp/mason.lua b/lua/user/lsp/mason.lua
new file mode 100644
index 0000000..afd39ec
--- /dev/null
+++ b/lua/user/lsp/mason.lua
@@ -0,0 +1,46 @@
+local m = require("mason-lspconfig")
+
+-- Servers that should always be installed
+local servers = m.get_installed_servers();
+
+local settings = {
+ ui = {
+ border = "none",
+ },
+ log_level = vim.log.levels.INFO,
+ max_concurrent_installers = 4,
+}
+
+require("mason").setup(settings)
+require("mason-lspconfig").setup({
+ ensure_installed = servers,
+ automatic_installation = false,
+})
+
+local lspconfig_status_ok, lspconfig = pcall(require, "lspconfig")
+if not lspconfig_status_ok then
+ return
+end
+
+local opts = {}
+
+-- Register a handler that will be called for all installed servers.
+-- Alternatively, you may also register handlers on specific server instances instead (see example below).
+for _, server in pairs(servers) do
+ opts = {
+ on_attach = require("user.lsp.handlers").on_attach,
+ capabilities = require("user.lsp.handlers").capabilities,
+ }
+
+ server = vim.split(server, "@")[1]
+
+ local require_ok, conf_opts = pcall(require, "user.lsp.settings." .. server)
+ if require_ok then
+ opts = vim.tbl_deep_extend("force", conf_opts, opts)
+ end
+
+ -- This setup() function is exactly the same as lspconfig's setup function.
+ -- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
+ lspconfig[server].setup(opts)
+end
+