@@ -28,33 +28,37 @@ local add_location = function(matching_snippet_files, source_format, snippet_pat
2828end
2929
3030-- @param matching_snippet_files table<SnippetLocation>
31- local find_matching_snippet_files =
32- function (matching_snippet_files , source_format , source_path , exclude_paths )
33- local extension = snippet_engines [source_format ].extension
34- -- ./ indicates to look for files in the runtimepath
35- local rt_path = source_path :match (" %./(.*)" )
36- if rt_path then
37- -- Turn path into Lua pattern
38- local rt_path_pattern = vim .pesc (rt_path )
39- local rtp_files = vim .api .nvim_get_runtime_file (" */*" .. extension , true )
40- for _ , name in ipairs (rtp_files ) do
41- -- Do not include paths that match exclude_paths: this would lead to reconverting
42- -- the same snippets in consecutive runs if the paths are also set as output paths
43- -- Name can either be a directory or a file name so make sure it is a file
44- if name :match (rt_path_pattern ) and not match_any (name , exclude_paths ) and io .file_exists (name ) then
45- add_location (matching_snippet_files , source_format , name )
46- end
47- end
48- else
49- local files = io .scan_dir (vim .fn .expand (source_path ), extension , {
50- -- Should probably be made configurable
51- recursive = source_format == " yasnippet" ,
52- })
53- for _ , file in ipairs (files ) do
54- add_location (matching_snippet_files , source_format , file )
31+ local find_matching_snippet_files = function (
32+ matching_snippet_files ,
33+ source_format ,
34+ source_path ,
35+ exclude_paths
36+ )
37+ local extension = snippet_engines [source_format ].extension
38+ -- ./ indicates to look for files in the runtimepath
39+ local rt_path = source_path :match (" %./(.*)" )
40+ if rt_path then
41+ -- Turn path into Lua pattern
42+ local rt_path_pattern = vim .pesc (rt_path )
43+ local rtp_files = vim .api .nvim_get_runtime_file (" */*" .. extension , true )
44+ for _ , name in ipairs (rtp_files ) do
45+ -- Do not include paths that match exclude_paths: this would lead to reconverting
46+ -- the same snippets in consecutive runs if the paths are also set as output paths
47+ -- Name can either be a directory or a file name so make sure it is a file
48+ if name :match (rt_path_pattern ) and not match_any (name , exclude_paths ) and io .file_exists (name ) then
49+ add_location (matching_snippet_files , source_format , name )
5550 end
5651 end
52+ else
53+ local files = io .scan_dir (vim .fn .expand (source_path ), extension , {
54+ -- Should probably be made configurable
55+ recursive = source_format == " yasnippet" ,
56+ })
57+ for _ , file in ipairs (files ) do
58+ add_location (matching_snippet_files , source_format , file )
59+ end
5760 end
61+ end
5862
5963-- Searches for a set of snippet files on the user's system with a given extension
6064-- that matches the source format.
0 commit comments