aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lua/denote-fzf-lua.lua25
1 files changed, 14 insertions, 11 deletions
diff --git a/lua/denote-fzf-lua.lua b/lua/denote-fzf-lua.lua
index 508730e..c2999bb 100644
--- a/lua/denote-fzf-lua.lua
+++ b/lua/denote-fzf-lua.lua
@@ -12,17 +12,16 @@ local function list_denote_files(dir)
while #stack > 0 do
local current = table.remove(stack)
- local ok, entries = pcall(vim.fn.readdir, current)
- if ok then
- for _, entry in ipairs(entries) do
- local full = current .. "/" .. entry
- local stat = vim.loop.fs_stat(full)
- if stat then
- if stat.type == "directory" then
- table.insert(stack, full)
- elseif stat.type == "file" and entry:match("^%d%d%d%d%d%d%d%dT%d%d%d%d%d%d") then
- table.insert(results, full)
- end
+ local ok, handle = pcall(vim.loop.fs_scandir, current)
+ if ok and handle then
+ while true do
+ local name, typ = vim.loop.fs_scandir_next(handle)
+ if not name then break end
+ local full = current .. "/" .. name
+ if typ == "directory" then
+ table.insert(stack, full)
+ elseif (typ == "file" or typ == "link") and name:match("^%d%d%d%d%d%d%d%dT%d%d%d%d%d%d") then
+ table.insert(results, full)
end
end
end
@@ -168,6 +167,10 @@ end
function M.search_files(options)
local files = list_denote_files(options.dir)
+ if #files == 0 then
+ vim.notify("denote-fzf-lua: no Denote files found in " .. options.dir, vim.log.levels.WARN)
+ return
+ end
local lines = format_denote_table(files)
local opts = {}