File tree Expand file tree Collapse file tree 1 file changed +1
-21
lines changed
lua/wincent/commandt/private Expand file tree Collapse file tree 1 file changed +1
-21
lines changed Original file line number Diff line number Diff line change 1111--- @param root_markers string[]
1212--- @return string
1313local function find_root (starting_directory , root_markers )
14- -- Make absolute.
15- starting_directory = vim .fn .fnamemodify (starting_directory , ' :p' )
16-
17- -- If it's a directory, :p will add a trailing slash, which we must strip.
18- starting_directory = starting_directory :gsub (' (.-)/$' , ' %1' )
19-
20- local next_path = starting_directory
21- local attempts = 0
22- while attempts < 100 do
23- attempts = attempts + 1
24- for _ , marker in ipairs (root_markers ) do
25- local candidate = next_path .. ' /' .. marker
26- if vim .fn .isdirectory (candidate ) == 1 or vim .fn .filereadable (candidate ) == 1 then
27- return next_path
28- end
29- end
30- next_path = vim .fs .normalize (vim .fs .joinpath (next_path , ' ..' ))
31- end
32-
33- -- Found nothing.
34- return starting_directory
14+ return vim .fs .root (starting_directory , root_markers ) or starting_directory
3515end
3616
3717return find_root
You can’t perform that action at this time.
0 commit comments