summaryrefslogtreecommitdiffstats
path: root/lua/user/core/lsp/mason.lua
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2022-11-23 15:38:16 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2022-11-23 15:38:16 +0100
commit99630ae8233f8a2afb6a89016b24a354b0186a21 (patch)
tree01ccbb1e8843ce1dbc9383579575dc48eef60f2c /lua/user/core/lsp/mason.lua
parent904acb28247999214aefd33a0cd3ddcea99d7dc0 (diff)
downloadvim-99630ae8233f8a2afb6a89016b24a354b0186a21.zip
vim-99630ae8233f8a2afb6a89016b24a354b0186a21.tar.gz
plugins -> subdir core
Diffstat (limited to 'lua/user/core/lsp/mason.lua')
-rw-r--r--lua/user/core/lsp/mason.lua63
1 files changed, 63 insertions, 0 deletions
diff --git a/lua/user/core/lsp/mason.lua b/lua/user/core/lsp/mason.lua
new file mode 100644
index 0000000..9708ec8
--- /dev/null
+++ b/lua/user/core/lsp/mason.lua
@@ -0,0 +1,63 @@
+local mason_ok, mason = pcall(require, "mason")
+if not mason_ok then
+ print "mason init failed"
+ return
+end
+
+local mason_lspconfig_ok, mason_lspconfig = pcall(require, "mason-lspconfig")
+if not mason_lspconfig_ok then
+ print "mason-lspconfig init failed"
+ return
+end
+
+local lspconfig_ok, lspconfig = pcall(require, "lspconfig")
+if not lspconfig_ok then
+ print "lspconfig init failed"
+ return
+end
+
+require('lspconfig.ui.windows').default_options.border = 'rounded'
+
+local servers = {
+ "clangd",
+ "jdtls",
+ "jsonls",
+ "ltex",
+ "rust_analyzer",
+ "solargraph",
+ "sumneko_lua",
+}
+
+mason.setup({
+ ui = {
+ border = "single",
+ icons = {
+ package_installed = "✓",
+ package_pending = "➜",
+ package_uninstalled = "✗"
+ }
+ }
+})
+
+mason_lspconfig.setup({
+ ensure_installed = servers,
+})
+
+mason_lspconfig.setup_handlers({
+ function(server_name)
+ local opts = {
+ on_attach = require("user.core.lsp.handlers").on_attach,
+ capabilities = require("user.core.lsp.handlers").capabilities,
+ falgs = {
+ debounce_text_changes = 5000,
+ },
+ }
+
+ local require_ok, server = pcall(require, "user.core.lsp.settings." .. server_name)
+ if require_ok then
+ opts = vim.tbl_deep_extend("force", server, opts)
+ end
+
+ lspconfig[server_name].setup(opts)
+ end,
+})