From 336b2de4b36ad9eafdef6c5e882bc08a66d7c959 Mon Sep 17 00:00:00 2001 From: Aleksa Vuckovic Date: Sat, 25 Feb 2023 01:17:08 +0100 Subject: pcall now prints error, fixed cmp luasnip --- lua/user/lsp/mason.lua | 84 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 61 insertions(+), 23 deletions(-) (limited to 'lua/user/lsp/mason.lua') diff --git a/lua/user/lsp/mason.lua b/lua/user/lsp/mason.lua index 2c14313..8425934 100644 --- a/lua/user/lsp/mason.lua +++ b/lua/user/lsp/mason.lua @@ -1,43 +1,81 @@ -local status, mason = pcall(require, "mason") -if not status then +local mason_status, mason = pcall(require, "mason") +if not mason_status then + print("lsp/mason.lua: loading mason failed") return end --- mason -mason.setup({ +local mason_lspconfig_status, mason_lspconfig = pcall(require, "mason-lspconfig") +if not mason_lspconfig_status then + print("lsp/mason.lua: loading mason-lspconfig failed") + return +end + +local lspconfig_status, lspconfig = pcall(require, "lspconfig") +if not lspconfig_status then + print("lsp/mason.lua: loading lspconfig failed") + return +end + +local mason_null_ls_status, mason_null_ls = pcall(require, "mason-null-ls") +if not mason_null_ls_status then + print("lsp/mason.lua: loading mason-null-ls failed") + return +end + +local null_ls_status, null_ls = pcall(require, "null-ls") +if not null_ls_status then + print("lsp/mason.lua: loading null-ls failed") + return +end + + +local settings = { ui = { + border = "none", icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗" - } - } -}) + package_installed = "◍", + package_pending = "◍", + package_uninstalled = "◍", + }, + }, + log_level = vim.log.levels.INFO, + max_concurrent_installers = 4, +} --- mason-lspconfig -require("mason-lspconfig").setup { - ensure_installed = { "pylsp", "bashls", "lua_ls", "cmake" }, +local servers = { + "pylsp", "bashls", "lua_ls", "cmake" } -require("mason-lspconfig").setup_handlers { + + +-- mason +mason.setup(settings) + +-- mason-lspconfig +mason_lspconfig.setup({ + ensure_installed = servers, + automatic_installation = true, +}) + +table.insert(servers, "ccls") +mason_lspconfig.setup_handlers { function(server_name) - require("lspconfig")[server_name].setup {} - end + lspconfig[server_name].setup { + on_attach = require("user.lsp.handlers").on_attach, + capabilities = require("user.lsp.handlers").capabilities, + } + end, } -- mason-null-ls -require('mason-null-ls').setup({ +mason_null_ls.setup({ automatic_setup = true, - ensure_installed = {} + ensure_installed = {}, }) -require('mason-null-ls').setup_handlers { +mason_null_ls.setup_handlers { function(source_name, methods) require("mason-null-ls.automatic_setup")(source_name, methods) end, } -- null_ls -local status, null_ls = pcall(require, "null-ls") -if not status then - return -end null_ls.setup() -- cgit v1.2.3