mirror of
https://github.com/chipsenkbeil/distant.git
synced 2024-11-05 12:00:36 +00:00
Include neovim example
This commit is contained in:
parent
cb3f808a6c
commit
349c5382eb
@ -59,6 +59,24 @@ read_dir(session, { path = "path/to/dir" }, function(success, result)
|
||||
print(result)
|
||||
end
|
||||
end)
|
||||
|
||||
-- For neovim, there exists a helper function that converts async functions
|
||||
-- into functions that take callbacks, executing the asynchronous logic
|
||||
-- using neovim's event loop powered by libuv
|
||||
local read_dir = distant.utils.nvim_wrap_async(session.read_dir_async)
|
||||
read_dir(session, { path = "path/to/dir" }, function(success, result)
|
||||
-- success: Returns true if ok and false if err
|
||||
-- result: If success is true, then is the resulting value,
|
||||
-- otherwise is the error
|
||||
print("Success", success)
|
||||
if success then
|
||||
for _, entry in ipairs(result.entries) do
|
||||
print("Entry", entry.file_type, entry.path, entry.depth)
|
||||
end
|
||||
else
|
||||
print(result)
|
||||
end
|
||||
end)
|
||||
```
|
||||
|
||||
## Tests
|
||||
|
Loading…
Reference in New Issue
Block a user