docs: add tag vim.fs.exists() and document suggested replacement

This commit is contained in:
dundargoc 2024-11-27 15:36:38 +01:00 committed by dundargoc
parent 203e7a43d1
commit 76dcc7029b
2 changed files with 23 additions and 0 deletions

View File

@ -2926,6 +2926,17 @@ vim.keymap.set({mode}, {lhs}, {rhs}, {opts}) *vim.keymap.set()*
==============================================================================
Lua module: vim.fs *vim.fs*
*vim.fs.exists()*
Use |uv.fs_stat()| to check a file's type, and whether it exists.
Example: >lua
if vim.uv.fs_stat(file) then
vim.print("file exists")
end
<
vim.fs.basename({file}) *vim.fs.basename()*
Return the basename of the given path

View File

@ -1,3 +1,15 @@
--- @brief <pre>help
--- *vim.fs.exists()*
--- Use |uv.fs_stat()| to check a file's type, and whether it exists.
---
--- Example:
---
--- >lua
--- if vim.uv.fs_stat(file) then
--- vim.print("file exists")
--- end
--- <
local uv = vim.uv
local M = {}