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/keymaps.lua | 2 +- lua/user/lsp/init.lua | 7 ++++--- lua/user/lsp/mason.lua | 36 +++++++++++++++++++++++++++++++++++- lua/user/plugins.lua | 8 +++++--- 4 files changed, 45 insertions(+), 8 deletions(-) diff --git a/lua/user/keymaps.lua b/lua/user/keymaps.lua index bdf1b6a..17f015b 100644 --- a/lua/user/keymaps.lua +++ b/lua/user/keymaps.lua @@ -30,7 +30,7 @@ keymap("n", "", ":bnext", opts) keymap("n", "", ":bprevious", opts) -- NvimTree -keymap("n", "e", ":NvimTreeToggle", opts) +keymap("n", "t", ":NvimTreeToggle", opts) -- Resize with arrows keymap("n", "", ":resize -2", opts) 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() diff --git a/lua/user/plugins.lua b/lua/user/plugins.lua index 227de7f..a3fd1f2 100644 --- a/lua/user/plugins.lua +++ b/lua/user/plugins.lua @@ -39,12 +39,14 @@ return packer.startup(function(use) use "hrsh7th/cmp-cmdline" use "hrsh7th/cmp-nvim-lua" --- snippets - use "L3MON4D3/LuaSnip" --- LSP +-- LSP, linters & formatters use "neovim/nvim-lspconfig" use "williamboman/mason.nvim" + use "williamboman/mason-lspconfig.nvim" + use "nvim-lua/plenary.nvim" + use "jose-elias-alvarez/null-ls.nvim" + use "jay-babu/mason-null-ls.nvim" -- Colorsheme use "morhetz/gruvbox" -- cgit v1.2.3