File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change 133133 '' ;
134134 type = types . listOf loaderSubmodule ;
135135 } ;
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+ } ;
136157 } ;
137158
138159 config =
164185 ''
165186 ) )
166187 ] ;
188+
189+ filetypeExtendConfig = mapAttrsToList ( n : v : ''
190+ require("luasnip").extend_filetypes("${ n } ", ${ helpers . toLuaObject v } )
191+ '' ) cfg . filetypeExtend ;
192+
167193 extraConfig = [
168194 ''
169195 require("luasnip").config.setup(${ helpers . toLuaObject cfg . settings } )
173199 mkIf cfg . enable {
174200 extraPlugins = [ cfg . package ] ;
175201 extraLuaPackages = ps : [ ps . jsregexp ] ;
176- extraConfigLua = concatStringsSep "\n " ( extraConfig ++ loaderConfig ) ;
202+ extraConfigLua = concatStringsSep "\n " ( extraConfig ++ loaderConfig ++ filetypeExtendConfig ) ;
177203 } ;
178204}
You can’t perform that action at this time.
0 commit comments