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

This commit is contained in:
Gregory Anders
2022-05-15 19:55:18 -06:00
parent c5526a27c3
commit b740709431
3 changed files with 30 additions and 0 deletions

View File

@@ -40,4 +40,12 @@ function M.dirname(file)
return vim.fn.fnamemodify(file, ':h')
end
--- Return the basename of the given file or directory
---
---@param file (string) File or directory
---@return (string) Basename of {file}
function M.basename(file)
return vim.fn.fnamemodify(file, ':t')
end
return M