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:
Marty Oehme 2024-06-27 17:20:35 +02:00
parent 9ded34f73c
commit e6497a2241
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
3 changed files with 22 additions and 3 deletions

View file

@ -39,6 +39,7 @@
"jupytext.nvim": { "branch": "main", "commit": "c8baf3ad344c59b3abd461ecc17fc16ec44d0f7b" }, "jupytext.nvim": { "branch": "main", "commit": "c8baf3ad344c59b3abd461ecc17fc16ec44d0f7b" },
"lazy.nvim": { "branch": "main", "commit": "c501b429cf995c645454539b924aaefae45bb9eb" }, "lazy.nvim": { "branch": "main", "commit": "c501b429cf995c645454539b924aaefae45bb9eb" },
"lsp-setup.nvim": { "branch": "main", "commit": "6e4e977512ce426d8b52c27f3b6e6aefc73e1452" }, "lsp-setup.nvim": { "branch": "main", "commit": "6e4e977512ce426d8b52c27f3b6e6aefc73e1452" },
"ltex_extra.nvim": { "branch": "dev", "commit": "57192d7ae5ba8cef3c10e90f2cd62d4a7cdaab69" },
"lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" }, "lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" },
"luarocks.nvim": { "branch": "main", "commit": "1db9093915eb16ba2473cfb8d343ace5ee04130a" }, "luarocks.nvim": { "branch": "main", "commit": "1db9093915eb16ba2473cfb8d343ace5ee04130a" },
"markmap.nvim": { "branch": "main", "commit": "5fb6755cf5434511cc23a4936c9eb76b9142fba5" }, "markmap.nvim": { "branch": "main", "commit": "5fb6755cf5434511cc23a4936c9eb76b9142fba5" },

View file

@ -20,7 +20,7 @@ local servers = {
eslint = {}, eslint = {},
gopls = {}, gopls = {},
julials = {}, julials = {},
ltex = {}, ltex = { autostart = false },
lua_ls = { lua_ls = {
settings = { settings = {
Lua = { Lua = {
@ -201,3 +201,23 @@ if require("core.util").is_available("arduino") then
on_new_config = require("arduino").on_new_config, on_new_config = require("arduino").on_new_config,
}) })
end 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,
})

View file

@ -182,8 +182,6 @@ local prose_plugs = {
{ {
"barreiroleo/ltex_extra.nvim", "barreiroleo/ltex_extra.nvim",
branch = "dev", branch = "dev",
ft = writing_ft,
opts = {},
}, },
} }