mirror of
https://github.com/neovim/neovim.git
synced 2025-12-15 19:05:40 +00:00
feat(fs): add vim.fs.dirname()
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user