File tree 1 file changed +27
-1
lines changed
1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change 133
133
'' ;
134
134
type = types . listOf loaderSubmodule ;
135
135
} ;
136
+
137
+ filetypeExtend = mkOption {
138
+ default = { } ;
139
+ type = with types ; attrsOf ( listOf str ) ;
140
+ example = {
141
+ lua = [
142
+ "c"
143
+ "cpp"
144
+ ] ;
145
+ } ;
146
+ description = ''
147
+ Wrapper for the `filetype_extend` function.
148
+ Keys are filetypes (`filetype`) and values are list of filetypes (`["ft1" "ft2" "ft3"]`).
149
+
150
+ Tells luasnip that for a buffer with `ft=filetype`, snippets from `extend_filetypes` should
151
+ be searched as well.
152
+
153
+ For example, `filetypeExtend.lua = ["c" "cpp"]` would search and expand c and cpp snippets
154
+ for lua files.
155
+ '' ;
156
+ } ;
136
157
} ;
137
158
138
159
config =
164
185
''
165
186
) )
166
187
] ;
188
+
189
+ filetypeExtendConfig = mapAttrsToList ( n : v : ''
190
+ require("luasnip").extend_filetypes("${ n } ", ${ helpers . toLuaObject v } )
191
+ '' ) cfg . filetypeExtend ;
192
+
167
193
extraConfig = [
168
194
''
169
195
require("luasnip").config.setup(${ helpers . toLuaObject cfg . settings } )
173
199
mkIf cfg . enable {
174
200
extraPlugins = [ cfg . package ] ;
175
201
extraLuaPackages = ps : [ ps . jsregexp ] ;
176
- extraConfigLua = concatStringsSep "\n " ( extraConfig ++ loaderConfig ) ;
202
+ extraConfigLua = concatStringsSep "\n " ( extraConfig ++ loaderConfig ++ filetypeExtendConfig ) ;
177
203
} ;
178
204
}
You can’t perform that action at this time.
0 commit comments