From 0556e2f742c147dc6b3506b5f9824716234b1f21 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Fri, 5 Aug 2022 23:41:14 +0200 Subject: [PATCH] Add mason-lspconfig plugin start lsp server automatically --- conf/nvim/lua/plugins.lua | 8 +++++--- conf/nvim/lua/plugins/mason.lua | 12 ++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/conf/nvim/lua/plugins.lua b/conf/nvim/lua/plugins.lua index 7d23703..9ee68c4 100644 --- a/conf/nvim/lua/plugins.lua +++ b/conf/nvim/lua/plugins.lua @@ -1,7 +1,7 @@ -- Plugins require "paq" { "savq/paq-nvim"; - + -- status bar 'nvim-lualine/lualine.nvim'; @@ -12,19 +12,21 @@ require "paq" { 'scrooloose/nerdtree'; 'lewis6991/gitsigns.nvim'; - -- need to install g++ package on Debian -- for tree sitter plugins 'nvim-treesitter/nvim-treesitter'; -- LSP installer 'neovim/nvim-lspconfig'; + -- Mason is a GUI to install language servers and lspconfig is a bridge + -- between mason and nvim-lspconfig 'williamboman/mason.nvim'; + 'williamboman/mason-lspconfig.nvim'; -- autocompletion plugin 'hrsh7th/nvim-cmp'; 'hrsh7th/cmp-nvim-lsp'; - + -- vim lint when it is not possible withlsp 'mfussenegger/nvim-lint'; } diff --git a/conf/nvim/lua/plugins/mason.lua b/conf/nvim/lua/plugins/mason.lua index 210ab98..5e8ec57 100644 --- a/conf/nvim/lua/plugins/mason.lua +++ b/conf/nvim/lua/plugins/mason.lua @@ -1 +1,13 @@ local mason = require("mason").setup() +local mason_lspconfig = require("mason-lspconfig").setup() + +require("mason-lspconfig").setup_handlers({ + -- The first entry (without a key) will be the default handler + -- and will be called for each installed server that doesn't have + -- a dedicated handler. + function (server_name) -- default handler (optional) + require("lspconfig")[server_name].setup {} + end, + -- Next, you can provide targeted overrides for specific servers. + -- +})