diff options
author | crupest <crupest@outlook.com> | 2023-10-02 00:02:38 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2023-10-02 23:29:00 +0800 |
commit | 03404ef38f0763773d5bb77502062cce444898c1 (patch) | |
tree | c2cb7a3d9465ab5054fca4af92f9f643d4c1d758 /configs/nvim/lua/crupest/system/fs.lua | |
parent | 66ceacf580d7d2d7f5893dd4bae993b7f135ae14 (diff) | |
download | crupest-03404ef38f0763773d5bb77502062cce444898c1.tar.gz crupest-03404ef38f0763773d5bb77502062cce444898c1.tar.bz2 crupest-03404ef38f0763773d5bb77502062cce444898c1.zip |
Update nvim configs.
Diffstat (limited to 'configs/nvim/lua/crupest/system/fs.lua')
-rw-r--r-- | configs/nvim/lua/crupest/system/fs.lua | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/configs/nvim/lua/crupest/system/fs.lua b/configs/nvim/lua/crupest/system/fs.lua index b52a822..c879239 100644 --- a/configs/nvim/lua/crupest/system/fs.lua +++ b/configs/nvim/lua/crupest/system/fs.lua @@ -3,11 +3,19 @@ local function clean_path(path) end local function full_path(name) - return vim.fn.fnamemodify(name, ":p:gs?\\?/?") + local path = vim.fn.fnamemodify(name, ":p:gs?\\?/?") + if string.sub(path, string.len(path)) == '/' then + path = string.sub(path, 1, string.len(path) - 1) + end + return path +end + +local function escape_space(str) + return (string.gsub(str, " ", "\\ ")) end local function path_get_dir(path) - return vim.fn.fnamemodify(path, ":p:h:gs?\\?/?") + return vim.fn.fnamemodify(full_path(path), ":h") end local function walk_up(path, func) @@ -78,6 +86,7 @@ end return { clean_path = clean_path, full_path = full_path, + escape_space = escape_space, path_get_dir = path_get_dir, walk_up = walk_up, exist = exist, |