aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/lua.txt9
-rw-r--r--runtime/lua/vim/fs.lua8
2 files changed, 17 insertions, 0 deletions
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index cf6d2e7276..bf30700fc0 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -2151,6 +2151,15 @@ set({mode}, {lhs}, {rhs}, {opts}) *vim.keymap.set()*
==============================================================================
Lua module: fs *lua-fs*
+basename({file}) *vim.fs.basename()*
+ Return the basename of the given file or directory
+
+ Parameters: ~
+ {file} (string) File or directory
+
+ Return: ~
+ (string) Basename of {file}
+
dirname({file}) *vim.fs.dirname()*
Return the parent directory of the given file or directory
diff --git a/runtime/lua/vim/fs.lua b/runtime/lua/vim/fs.lua
index a3b7321cc9..29ce394a38 100644
--- a/runtime/lua/vim/fs.lua
+++ b/runtime/lua/vim/fs.lua
@@ -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