mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
plugins/ltex-extra: prefer ltex_plus over ltex
ltex_plus is a maintained fork that recently got supported by ltex-extra https://github.com/barreiroleo/ltex_extra.nvim/pull/66 Enable it unless the user explicitly use ltex
This commit is contained in:
parent
81b327ec5d
commit
0633c9d139
1 changed files with 63 additions and 14 deletions
|
@ -2,9 +2,13 @@
|
|||
lib,
|
||||
helpers,
|
||||
config,
|
||||
options,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
lspCfg = config.plugins.lsp;
|
||||
in
|
||||
lib.nixvim.plugins.mkNeovimPlugin {
|
||||
name = "ltex-extra";
|
||||
packPathName = "ltex_extra.nvim";
|
||||
|
@ -12,6 +16,10 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
|||
|
||||
maintainers = [ maintainers.loicreynier ];
|
||||
|
||||
description = ''
|
||||
This plugin works with both the ltex or ltex_plus language servers and will enable ltex_plus if neither are.
|
||||
'';
|
||||
|
||||
callSetup = false;
|
||||
|
||||
settingsOptions = {
|
||||
|
@ -44,24 +52,65 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
|||
};
|
||||
|
||||
extraConfig = cfg: {
|
||||
warnings = lib.nixvim.mkWarnings "plugins.ltex-extra" {
|
||||
when = !config.plugins.lsp.enable;
|
||||
message = ''
|
||||
You have enabled `ltex-extra` but not the lsp (`plugins.lsp`).
|
||||
You should set `plugins.lsp.enable = true` to make use of the LTeX_extra plugin's features.
|
||||
'';
|
||||
};
|
||||
warnings = lib.nixvim.mkWarnings "plugins.ltex-extra" [
|
||||
{
|
||||
when = !lspCfg.enable;
|
||||
message = ''
|
||||
You have enabled `ltex-extra` but not the lsp (`plugins.lsp`).
|
||||
You should set `plugins.lsp.enable = true` to make use of the LTeX_extra plugin's features.
|
||||
'';
|
||||
}
|
||||
(
|
||||
let
|
||||
expectedDefs = map toString [
|
||||
./.
|
||||
../../lsp/language-servers
|
||||
];
|
||||
isExternal = d: !elem d.file expectedDefs;
|
||||
anyExternal =
|
||||
acc: name: v:
|
||||
let
|
||||
e = findFirst isExternal null v.definitionsWithLocations;
|
||||
in
|
||||
if acc != null then
|
||||
acc
|
||||
else if e == null then
|
||||
null
|
||||
else
|
||||
{
|
||||
inherit name;
|
||||
inherit (e) file;
|
||||
};
|
||||
external = foldlAttrs anyExternal null options.plugins.lsp.servers.ltex;
|
||||
in
|
||||
{
|
||||
# TODO: Added 2025-03-30; remove after 25.05
|
||||
# Warn if servers.ltex seems to be configured outside of ltex-extra
|
||||
when = !lspCfg.servers.ltex.enable && external != null;
|
||||
message = ''
|
||||
in ${external.file}
|
||||
You seem to have configured `plugins.lsp.servers.ltex.${external.name}` for `ltex-extra`.
|
||||
It now uses `plugins.lsp.servers.ltex_plus` by default,
|
||||
either move the configuration or explicitly enable `ltex` with `plugins.lsp.servers.ltex.enable = true`
|
||||
'';
|
||||
}
|
||||
)
|
||||
];
|
||||
|
||||
plugins.lsp = {
|
||||
servers.ltex = {
|
||||
# Enable the ltex language server
|
||||
enable = true;
|
||||
|
||||
onAttach.function = ''
|
||||
plugins.lsp =
|
||||
let
|
||||
attachLua = ''
|
||||
require("ltex_extra").setup(${lib.nixvim.toLuaObject cfg.settings})
|
||||
'';
|
||||
in
|
||||
{
|
||||
servers.ltex.onAttach.function = attachLua;
|
||||
servers.ltex_plus = {
|
||||
# Enable ltex_plus if ltex is not already enabled
|
||||
enable = mkIf (!lspCfg.servers.ltex.enable) (mkDefault true);
|
||||
onAttach.function = attachLua;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
settingsExample = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue