1
0
Fork 0

nvim: refine MY_get_project_root()

This commit is contained in:
tastytea 2022-08-13 01:06:08 +02:00
parent feb385b694
commit 64943d0144
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
1 changed files with 1 additions and 3 deletions

View File

@ -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