feat(fs): add vim.fs.dirname()

This commit is contained in:
Gregory Anders
2022-05-15 19:53:23 -06:00
parent 67cbaf58c4
commit c5526a27c3
3 changed files with 27 additions and 1 deletions

View File

@@ -21,7 +21,7 @@ local M = {}
---@return (function) Iterator
function M.parents(start)
return function(_, dir)
local parent = vim.fn.fnamemodify(dir, ":h")
local parent = M.dirname(dir)
if parent == dir then
return nil
end
@@ -32,4 +32,12 @@ function M.parents(start)
start
end
--- Return the parent directory of the given file or directory
---
---@param file (string) File or directory
---@return (string) Parent directory of {file}
function M.dirname(file)
return vim.fn.fnamemodify(file, ':h')
end
return M