From 0703660d49f22376d52a969e8c3cca64480b0f1b Mon Sep 17 00:00:00 2001 From: Aleksa Vuckovic Date: Fri, 24 Feb 2023 03:53:10 +0100 Subject: mason-lspconfig & mason-null-ls --- lua/user/lsp/init.lua | 7 ++++--- lua/user/lsp/mason.lua | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 4 deletions(-) (limited to 'lua/user/lsp') diff --git a/lua/user/lsp/init.lua b/lua/user/lsp/init.lua index 92ae9bf..202cccb 100644 --- a/lua/user/lsp/init.lua +++ b/lua/user/lsp/init.lua @@ -1,7 +1,8 @@ -local status_ok, _ = pcall(require, "lspconfig") -if not status_ok then +require "user.lsp.mason" + +local status, lspconfig = pcall(require, "lspconfig") +if not status then return end -require "user.lsp.mason" require "user.lsp.ccls" diff --git a/lua/user/lsp/mason.lua b/lua/user/lsp/mason.lua index af77151..1b5717d 100644 --- a/lua/user/lsp/mason.lua +++ b/lua/user/lsp/mason.lua @@ -1,4 +1,10 @@ -require("mason").setup({ +local status, mason = pcall(require, "mason") +if not status then + return +end + +-- mason +mason.setup({ ui = { icons = { package_installed = "✓", @@ -7,3 +13,31 @@ require("mason").setup({ } } }) + +-- mason-lspconfig +require("mason-lspconfig").setup { + ensure_installed = { "pylsp", "bashls", "lua_ls", "cmake" }, +} +require("mason-lspconfig").setup_handlers { + function (server_name) + require("lspconfig")[server_name].setup {} + end +} + +-- mason-null-ls +require('mason-null-ls').setup({ + automatic_setup = true, + ensure_installed = { "cpplint" } +}) +require('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