From 64943d014420cd76927b65ee4c983abb242aaf4b Mon Sep 17 00:00:00 2001 From: tastytea Date: Sat, 13 Aug 2022 01:06:08 +0200 Subject: [PATCH] nvim: refine MY_get_project_root() --- .config/nvim/lua/my/functions.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.config/nvim/lua/my/functions.lua b/.config/nvim/lua/my/functions.lua index 8b888ae..90f1c49 100644 --- a/.config/nvim/lua/my/functions.lua +++ b/.config/nvim/lua/my/functions.lua @@ -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