nvim: refine MY_get_project_root()
This commit is contained in:
parent
feb385b694
commit
64943d0144
|
@ -1,10 +1,8 @@
|
|||
-- remove trailing whitespace
|
||||
function MY_remove_trailing_whitespace()
|
||||
local curpos = vim.api.nvim_win_get_cursor(0)
|
||||
vim.cmd([[keeppatterns %s/\s\+$//e]])
|
||||
vim.api.nvim_win_set_cursor(0, curpos)
|
||||
end
|
||||
|
||||
vim.api.nvim_create_augroup('config_functions', { clear = true })
|
||||
vim.api.nvim_create_autocmd(
|
||||
{ 'BufWritePre' },
|
||||
|
@ -91,7 +89,7 @@ function MY_get_project_root()
|
|||
local sep = '/'
|
||||
|
||||
repeat
|
||||
path = path:gsub('/[^/]*$', '')
|
||||
path = path:gsub(string.format('%s[^%s]*$', sep, sep), '')
|
||||
for _, marker in ipairs(root_markers) do
|
||||
if io.open(path .. sep .. marker) then
|
||||
return path
|
||||
|
|
Loading…
Reference in New Issue
Block a user