nvim: Fix ltex disabled autostart

Fixes #1ef7570.

We implement our own autostart-aware lsp register function. Any lsp
which has the option {autostart=false} set at their config root will be
not automatically enabled and can instead be enabled on demand.
This commit is contained in:
Marty Oehme 2025-06-07 09:38:37 +02:00
parent 6e6f804c08
commit 63c6c81f6e
Signed by: Marty
GPG key ID: 4E535BC19C61886E
3 changed files with 36 additions and 23 deletions

View file

@ -38,7 +38,7 @@ After all files are linked and you open a new shell session, the `dotlink` alias
[^1]: [^1]:
This alias only works when the dotfiles are cloned into `~/.dotfiles`, mirroring my setup. This alias only works when the dotfiles are cloned into `~/.dotfiles`, mirroring my setup.
This is due to a hard-coded cd into this directory. This is due to a hard-coded cd into this directory.
If your dotfiles lie in another directory and you want to use the dotlink alias, simply change the corresponding line in `bootstrap/.config/sh/alias.d/dotlink.sh` If your dotfiles lie in another directory, and you want to use the dotlink alias, simply change the corresponding line in `bootstrap/.config/sh/alias.d/dotlink.sh`
Both automatic installation paths are presumably somewhat brittle. In any case, I would suggest to manually look through the files for things you want instead of copying and activating everything. Both automatic installation paths are presumably somewhat brittle. In any case, I would suggest to manually look through the files for things you want instead of copying and activating everything.
Dotfiles are too personal to be standardized like that. Dotfiles are too personal to be standardized like that.

View file

@ -56,9 +56,14 @@ local lsp = {
vim.fn.sign_define("DiagnosticSignInfo", { text = "", texthl = "DiagnosticSignInfo" }) vim.fn.sign_define("DiagnosticSignInfo", { text = "", texthl = "DiagnosticSignInfo" })
vim.fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" }) vim.fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" })
local function register(server_name, config) local function register(server_name, config, enabled)
if vim.fn.has("nvim-0.11") == 1 then if vim.fn.has("nvim-0.11") == 1 then
vim.lsp.config(server_name, config) vim.lsp.config(server_name, config)
if enabled == false or vim.lsp.config[server_name]["autostart"] == false then
vim.lsp.enable(server_name, false)
else
vim.lsp.enable(server_name, true)
end
else else
require("lspconfig")[server_name].setup(config) require("lspconfig")[server_name].setup(config)
end end
@ -186,19 +191,28 @@ local lsp = {
vim.api.nvim_create_autocmd("User", { vim.api.nvim_create_autocmd("User", {
pattern = "SpellEnable", pattern = "SpellEnable",
callback = function() callback = function()
register("ltex", { local mapped = {}
on_attach = function(_, _) local lang_map = {
if require("core.util").is_available("ltex_extra") then en_us = "en-US",
require("ltex_extra").setup() en_gb = "en-GB",
de_de = "de-DE",
}
for _, v in ipairs(vim.opt.spelllang:get()) do
table.insert(mapped, lang_map[v])
end end
end, vim.lsp.config("ltex", {
settings = { settings = { ltex = { language = mapped } },
ltex = {
language = vim.o.spelllang,
},
},
}) })
vim.cmd("LspStart ltex") -- single-shot setup: Enable for this buffer
-- but instantly disable again globally
vim.lsp.enable("ltex")
vim.lsp.enable("ltex", false)
end,
})
vim.api.nvim_create_autocmd("User", {
pattern = "SpellDisable",
callback = function()
vim.lsp.enable("ltex", false)
end, end,
}) })
end, end,

View file

@ -3,18 +3,17 @@
The bare minimum terminal configuration for a working system. The bare minimum terminal configuration for a working system.
Contains: Contains:
* an XDG compliant home directory setup - an XDG compliant home directory setup
* several basic environment variables - several basic environment variables
* simple aliases - simple aliases
* an optional fzf default setup - an optional fzf default setup
* X autostart - X autostart
While other modules are largely optional, While other modules are largely optional,
this module is the only one strictly necessary for the system to really work at all. this module is the only one strictly necessary for the system to really work at all.
Additionally contains two scripts on which some other modules build: Additionally contains two scripts on which some other modules build:
* a simple script to detect if applications exist - a simple script to detect if applications exist
(and optionally warn the user if they don't) (and optionally warn the user if they don't)
* and a script to check if internet connectivity exists - and a script to check if internet connectivity exists