diff options
author | Famiu Haque <famiuhaque@proton.me> | 2024-04-05 14:48:13 +0600 |
---|---|---|
committer | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2024-12-28 11:40:39 +0100 |
commit | 518070731003e30ea7eee96e76ccdf7b950c90da (patch) | |
tree | 71f361f6ef8de2799ba290d112ada0597a0606df /runtime/doc/lua.txt | |
parent | 48c09ed4d9edd92a7c665a62aed04e8597088e60 (diff) | |
download | rneovim-518070731003e30ea7eee96e76ccdf7b950c90da.tar.gz rneovim-518070731003e30ea7eee96e76ccdf7b950c90da.tar.bz2 rneovim-518070731003e30ea7eee96e76ccdf7b950c90da.zip |
feat(lua): add `vim.fs.abspath`
Problem: There is currently no way to check if a given path is absolute or convert a relative path to an absolute path through the Lua stdlib. `vim.fs.joinpath` does not work when the path is absolute. There is also currently no way to resolve `C:foo\bar` style paths in Windows.
Solution: Add `vim.fs.abspath`, which allows converting any path to an absolute path. This also allows checking if current path is absolute by doing `vim.fs.abspath(path) == path`. It also has support for `C:foo\bar` style paths in Windows.
Diffstat (limited to 'runtime/doc/lua.txt')
-rw-r--r-- | runtime/doc/lua.txt | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 711607d14b..a2a83ef229 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -2945,6 +2945,20 @@ Example: >lua < +vim.fs.abspath({path}) *vim.fs.abspath()* + Convert path to an absolute path. A tilde (~) character at the beginning + of the path is expanded to the user's home directory. Does not check if + the path exists, normalize the path, resolve symlinks or hardlinks + (including `.` and `..`), or expand environment variables. If the path is + already absolute, it is returned unchanged. Also converts `\` path + separators to `/`. + + Parameters: ~ + • {path} (`string`) Path + + Return: ~ + (`string`) Absolute path + vim.fs.basename({file}) *vim.fs.basename()* Return the basename of the given path |