| 
2 | 2 |   lib,  | 
3 | 3 |   helpers,  | 
4 | 4 |   config,  | 
 | 5 | +  options,  | 
5 | 6 |   ...  | 
6 | 7 | }:  | 
7 | 8 | with lib;  | 
 | 9 | +let  | 
 | 10 | +  lspCfg = config.plugins.lsp;  | 
 | 11 | +in  | 
8 | 12 | lib.nixvim.plugins.mkNeovimPlugin {  | 
9 | 13 |   name = "ltex-extra";  | 
10 | 14 |   packPathName = "ltex_extra.nvim";  | 
11 | 15 |   package = "ltex_extra-nvim";  | 
12 | 16 | 
 
  | 
13 | 17 |   maintainers = [ maintainers.loicreynier ];  | 
14 | 18 | 
 
  | 
 | 19 | +  description = ''  | 
 | 20 | +    This plugin works with both the ltex or ltex_plus language servers and will enable ltex_plus if neither are.  | 
 | 21 | +  '';  | 
 | 22 | + | 
15 | 23 |   callSetup = false;  | 
16 | 24 | 
 
  | 
17 | 25 |   settingsOptions = {  | 
@@ -44,24 +52,65 @@ lib.nixvim.plugins.mkNeovimPlugin {  | 
44 | 52 |   };  | 
45 | 53 | 
 
  | 
46 | 54 |   extraConfig = cfg: {  | 
47 |  | -    warnings = lib.nixvim.mkWarnings "plugins.ltex-extra" {  | 
48 |  | -      when = !config.plugins.lsp.enable;  | 
49 |  | -      message = ''  | 
50 |  | -        You have enabled `ltex-extra` but not the lsp (`plugins.lsp`).  | 
51 |  | -        You should set `plugins.lsp.enable = true` to make use of the LTeX_extra plugin's features.  | 
52 |  | -      '';  | 
53 |  | -    };  | 
54 |  | - | 
55 |  | -    plugins.lsp = {  | 
56 |  | -      servers.ltex = {  | 
57 |  | -        # Enable the ltex language server  | 
58 |  | -        enable = true;  | 
 | 55 | +    warnings = lib.nixvim.mkWarnings "plugins.ltex-extra" [  | 
 | 56 | +      {  | 
 | 57 | +        when = !lspCfg.enable;  | 
 | 58 | +        message = ''  | 
 | 59 | +          You have enabled `ltex-extra` but not the lsp (`plugins.lsp`).  | 
 | 60 | +          You should set `plugins.lsp.enable = true` to make use of the LTeX_extra plugin's features.  | 
 | 61 | +        '';  | 
 | 62 | +      }  | 
 | 63 | +      (  | 
 | 64 | +        let  | 
 | 65 | +          expectedDefs = map toString [  | 
 | 66 | +            ./.  | 
 | 67 | +            ../../lsp/language-servers  | 
 | 68 | +          ];  | 
 | 69 | +          isExternal = d: !elem d.file expectedDefs;  | 
 | 70 | +          anyExternal =  | 
 | 71 | +            acc: name: v:  | 
 | 72 | +            let  | 
 | 73 | +              e = findFirst isExternal null v.definitionsWithLocations;  | 
 | 74 | +            in  | 
 | 75 | +            if acc != null then  | 
 | 76 | +              acc  | 
 | 77 | +            else if e == null then  | 
 | 78 | +              null  | 
 | 79 | +            else  | 
 | 80 | +              {  | 
 | 81 | +                inherit name;  | 
 | 82 | +                inherit (e) file;  | 
 | 83 | +              };  | 
 | 84 | +          external = foldlAttrs anyExternal null options.plugins.lsp.servers.ltex;  | 
 | 85 | +        in  | 
 | 86 | +        {  | 
 | 87 | +          # TODO: Added 2025-03-30; remove after 25.05  | 
 | 88 | +          # Warn if servers.ltex seems to be configured outside of ltex-extra  | 
 | 89 | +          when = !lspCfg.servers.ltex.enable && external != null;  | 
 | 90 | +          message = ''  | 
 | 91 | +            in ${external.file}  | 
 | 92 | +            You seem to have configured `plugins.lsp.servers.ltex.${external.name}` for `ltex-extra`.  | 
 | 93 | +            It now uses `plugins.lsp.servers.ltex_plus` by default,  | 
 | 94 | +            either move the configuration or explicitly enable `ltex` with `plugins.lsp.servers.ltex.enable = true`  | 
 | 95 | +          '';  | 
 | 96 | +        }  | 
 | 97 | +      )  | 
 | 98 | +    ];  | 
59 | 99 | 
 
  | 
60 |  | -        onAttach.function = ''  | 
 | 100 | +    plugins.lsp =  | 
 | 101 | +      let  | 
 | 102 | +        attachLua = ''  | 
61 | 103 |           require("ltex_extra").setup(${lib.nixvim.toLuaObject cfg.settings})  | 
62 | 104 |         '';  | 
 | 105 | +      in  | 
 | 106 | +      {  | 
 | 107 | +        servers.ltex.onAttach.function = attachLua;  | 
 | 108 | +        servers.ltex_plus = {  | 
 | 109 | +          # Enable ltex_plus if ltex is not already enabled  | 
 | 110 | +          enable = mkIf (!lspCfg.servers.ltex.enable) (mkDefault true);  | 
 | 111 | +          onAttach.function = attachLua;  | 
 | 112 | +        };  | 
63 | 113 |       };  | 
64 |  | -    };  | 
65 | 114 |   };  | 
66 | 115 | 
 
  | 
67 | 116 |   settingsExample = {  | 
 | 
0 commit comments