Feat: replace lsp-install by mason and add ltex

This commit is contained in:
Bertrand Benjamin 2022-10-17 17:51:22 +02:00
parent 6b23fdf858
commit c21c9096c9
4 changed files with 26 additions and 24 deletions

View File

@ -3,6 +3,14 @@ if not null_ls_status_ok then
return
end
local mason_null_ls_status_ok, mason_null_ls = pcall(require, "mason-null-ls")
if not null_ls_status_ok then
return
end
require("mason-null-ls").setup({
})
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting
local formatting = null_ls.builtins.formatting
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics
@ -18,6 +26,3 @@ null_ls.setup {
diagnostics.yamllint,
},
}
local map = vim.api.nvim_set_keymap
map('n', '<leader>f', '<cmd>lua vim.lsp.buf.formatting_sync()<cr>', {})

View File

@ -3,7 +3,7 @@ if (not status) then return end
ts.setup {
-- One of "all", "maintained" (parsers with maintainers), or a list of languages
ensure_installed = {"python", "css", "html", "lua", "javascript", "vue", "c", "markdown", "rst"},
ensure_installed = {"python", "css", "html", "lua", "javascript", "vue", "c", "markdown", "rst", "cpp"},
highlight = {
enable = true,
additional_vim_regex_highlighting = false,

View File

@ -1,20 +1,5 @@
local lsp_installer = require("nvim-lsp-installer")
-- Register a handler that will be called for each installed server when it's ready (i.e. when installation is finished
-- or if the server is already installed).
lsp_installer.on_server_ready(function(server)
local opts = {}
-- (optional) Customize the options passed to the server
-- if server.name == "tsserver" then
-- opts.root_dir = function() ... end
-- end
-- This setup() function will take the provided server configuration and decorate it with the necessary properties
-- before passing it onwards to lspconfig.
-- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
server:setup(opts)
end)
require("mason").setup()
require("mason-lspconfig").setup()
local nvim_lsp = require('lspconfig')
-- Use an on_attach function to only map the following keys
@ -46,7 +31,7 @@ local on_attach = function(client, bufnr)
buf_set_keymap('n', '<leader>dp', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
-- Get diagnostic on local list
buf_set_keymap('n', '<leader>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
buf_set_keymap("n", "<leader>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
buf_set_keymap("n", "<leader>f", "<cmd>lua vim.lsp.buf.format()<CR>", opts)
buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
@ -81,3 +66,11 @@ nvim_lsp.vuels.setup{
client.resolved_capabilities.document_formatting = true
end;
}
nvim_lsp.ltex.setup{
settings = {
ltex = {
language = "fr",
}
}
}

View File

@ -60,10 +60,11 @@ return packer.startup(function(use)
use 'tpope/vim-repeat'
use {
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
'neovim/nvim-lspconfig',
requires = {
"hrsh7th/cmp-nvim-lsp",
'williamboman/nvim-lsp-installer',
}
}
use {
@ -85,7 +86,10 @@ return packer.startup(function(use)
-- for formatters and linters
use {
"jose-elias-alvarez/null-ls.nvim",
config = [[require('config.null-ls')]]
config = [[require('config.null-ls')]],
requires = {
"jayp0521/mason-null-ls.nvim"
}
}