nvim: Only start ltex LSP if spellchecking enabled
Since ltex-lsp eats quite a lot of resources and takes a while to start up we don't always want it enabled for every prose file. This commit ensures that it only starts up when spellchecking is enabled for a buffer (through the custom user command `SpellToggle`).
This commit is contained in:
parent
9ded34f73c
commit
e6497a2241
3 changed files with 22 additions and 3 deletions
|
|
@ -20,7 +20,7 @@ local servers = {
|
|||
eslint = {},
|
||||
gopls = {},
|
||||
julials = {},
|
||||
ltex = {},
|
||||
ltex = { autostart = false },
|
||||
lua_ls = {
|
||||
settings = {
|
||||
Lua = {
|
||||
|
|
@ -201,3 +201,23 @@ if require("core.util").is_available("arduino") then
|
|||
on_new_config = require("arduino").on_new_config,
|
||||
})
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "SpellEnable",
|
||||
callback = function()
|
||||
lspconfig.ltex.setup({
|
||||
on_attach = function(client, bufnr)
|
||||
on_attach(client, bufnr)
|
||||
if require("core.util").is_available("ltex_extra") then
|
||||
require("ltex_extra").setup()
|
||||
end
|
||||
end,
|
||||
settings = {
|
||||
ltex = {
|
||||
language = vim.opt.spelllang:get(),
|
||||
},
|
||||
},
|
||||
})
|
||||
vim.cmd("LspStart ltex")
|
||||
end,
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue