From eb855e3c8b96358520ac2a593afa80997ae23335 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Mon, 9 Jan 2023 13:12:48 +0100 Subject: [nvim] use mason for lsp installs and adjust config --- .config/nvim/init.vim | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 9a496bd..43fb173 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -28,8 +28,9 @@ Plug 'gpanders/editorconfig.nvim' Plug 'iamcco/markdown-preview.nvim', {'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']} " if install fails do `:call mkdp#util#install() manually` +Plug 'williamboman/mason.nvim' +Plug 'williamboman/mason-lspconfig.nvim' Plug 'neovim/nvim-lspconfig' -Plug 'williamboman/nvim-lsp-installer' Plug 'hrsh7th/nvim-cmp' Plug 'hrsh7th/cmp-nvim-lsp' Plug 'saadparwaiz1/cmp_luasnip' @@ -173,11 +174,11 @@ local on_attach = function(client, bufnr) buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) buf_set_keymap('n', 'ca', 'lua vim.lsp.buf.code_action()', opts) buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) - buf_set_keymap('n', 'e', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) - buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) - buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) - buf_set_keymap('n', 'q', 'lua vim.lsp.diagnostic.set_loclist()', opts) - buf_set_keymap('n', 'f', 'lua vim.lsp.buf.formatting()', opts) + buf_set_keymap('n', 'e', 'lua vim.diagnostic.open_float()', opts) + buf_set_keymap('n', '[d', 'lua vim.diagnostic.goto_prev()', opts) + buf_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next()', opts) + buf_set_keymap('n', 'q', 'lua vim.diagnostic.setloclist()', opts) + buf_set_keymap('n', 'f', 'lua vim.lsp.buf.format({async = true})', opts) end local capabilities = vim.lsp.protocol.make_client_capabilities() @@ -185,13 +186,16 @@ capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) vim.o.completeopt = 'menuone,noselect' -local lsp_installer = require('nvim-lsp-installer') -lsp_installer.on_server_ready(function(server) - server:setup({ - on_attach = on_attach, - capabilities = capabilities, - }) -end) +require('mason').setup() +require('mason-lspconfig').setup() +require('mason-lspconfig').setup_handlers { + function (server_name) + require ('lspconfig')[server_name].setup { + on_attach = on_attach, + capabilities = capabilities, + } + end +} local cmp = require('cmp') local luasnip = require('luasnip') -- cgit v1.2.3