ltex-ls.nvim
ltex-ls.nvim copied to clipboard
Help with setup
Hi, I have been using ltex with mason and mason-lspconfig.nvim. Now, i want to use this repository to have the (long waited) support for dictionaries, but i don't get it to work. As this is a wrapper on lspconfig i'm confused where to put it, because mason-lspconfig is also a wrapper for lspconfig.
I put require 'ltex-ls'.setup below the mason-lspconfig (require('mason-lspconfig').setup) line. LtexServerStatus says, the server is started but when i run LtexCheckDocument, i don't get any new diagnostics.
Maybe has someone a working template for mason-lspconfig?
Thanks
Hi @juanolon,
did you figure it out by chance?
For me the setup with mason-lspconfig works great when registering the setup function of ltex-ls.nvim as a custom handler using the setup_handlers api. What I have in my config is approximately equivalent to this:
local mason = require 'mason'
local mason_lspconfig = require 'mason-lspconfig'
local lspconfig = require 'lspconfig'
local make_opts = function(server_name)
return vim.tbl_extend('keep', {
on_attach = on_attach, -- custom on_attach (mainly for keymaps)
capabilities = capabilities, -- custom capabilities (for completion)
}, server_opts[server_name] or {}) -- custom configuration per server
end
local default_handler = function(server_name)
server_name = vim.split(server_name, '@')[1]
lspconfig[server_name].setup(make_opts(server_name))
end
mason.setup({...}) -- setup mason as usual
mason_lspconfig.setup()
mason_lspconfig.setup_handlers({
default_handler,
['ltex'] = function()
local server_name = 'ltex'
if pcall(require, 'ltex-ls') then
require('ltex-ls').setup(make_opts(server_name))
else
default_handler(server_name)
end
end,
})