8
8
with lib ;
9
9
let
10
10
lspCfg = config . plugins . lsp ;
11
+ initPlugin = ''
12
+ require("ltex_extra").setup(${ lib . nixvim . toLuaObject cfg . settings } )
13
+ '' ;
11
14
in
12
15
lib . nixvim . plugins . mkNeovimPlugin {
13
16
name = "ltex-extra" ;
@@ -17,7 +20,8 @@ lib.nixvim.plugins.mkNeovimPlugin {
17
20
maintainers = [ maintainers . loicreynier ] ;
18
21
19
22
description = ''
20
- This plugin works with both the ltex or ltex_plus language servers and will enable ltex_plus if neither are.
23
+ This plugin works with either the ltex or ltex_plus language servers.
24
+ Enabling this plugin will also enable ltex_plus, unless ltex is already enabled.
21
25
'' ;
22
26
23
27
callSetup = false ;
@@ -81,15 +85,29 @@ lib.nixvim.plugins.mkNeovimPlugin {
81
85
inherit name ;
82
86
inherit ( e ) file ;
83
87
} ;
84
- external = foldlAttrs anyExternal null options . plugins . lsp . servers . ltex ;
88
+ srvOpts = options . plugins . lsp . servers ;
89
+ external = foldlAttrs anyExternal null srvOpts . ltex ;
90
+
91
+ activeCfg = o :
92
+ foldlAttrs ( acc : name : val :
93
+ if val == null then acc
94
+ else if isAttrs val then
95
+
96
+ else acc // { ${ name } = val }
97
+ ) { }
98
+ if isAttrs o then
99
+ # redir
100
+ else a == b ;
101
+
102
+ inherit ( lspCfg . servers ) ltex ;
85
103
in
86
104
{
87
105
# TODO: Added 2025-03-30; remove after 25.05
88
106
# Warn if servers.ltex seems to be configured outside of ltex-extra
89
- when = ! lspCfg . servers . ltex . enable && external != null ;
107
+ when = ! ltex . enable && ltex !=
90
108
message = ''
91
109
in ${ external . file }
92
- You seem to have configured `plugins.lsp.servers. ltex.${ external . name } ` for `ltex-extra`.
110
+ You seem to have configured `${ srvOpts . ltex . ${ external . name } } ` for `ltex-extra`.
93
111
It now uses `plugins.lsp.servers.ltex_plus` by default,
94
112
either move the configuration or explicitly enable `ltex` with `plugins.lsp.servers.ltex.enable = true`
95
113
'' ;
@@ -99,16 +117,13 @@ lib.nixvim.plugins.mkNeovimPlugin {
99
117
100
118
plugins . lsp =
101
119
let
102
- attachLua = ''
103
- require("ltex_extra").setup(${ lib . nixvim . toLuaObject cfg . settings } )
104
- '' ;
105
120
in
106
121
{
107
- servers . ltex . onAttach . function = attachLua ;
122
+ servers . ltex . onAttach . function = initPlugin ;
108
123
servers . ltex_plus = {
109
124
# Enable ltex_plus if ltex is not already enabled
110
125
enable = mkIf ( ! lspCfg . servers . ltex . enable ) ( mkDefault true ) ;
111
- onAttach . function = attachLua ;
126
+ onAttach . function = initPlugin ;
112
127
} ;
113
128
} ;
114
129
} ;
0 commit comments