diff --git a/lua/zettelkasten/init.lua b/lua/zettelkasten/init.lua index bfbeef2..194a75f 100644 --- a/lua/zettelkasten/init.lua +++ b/lua/zettelkasten/init.lua @@ -58,7 +58,7 @@ end -- table. -- Recurses into subdirectories if recursive argument is true. function ZK.get_zettel_list(path, recursive) - return ls.get_anchors_and_paths(path, recursive or false) + return ls.get_anchors_and_paths(path, recursive or false, ZK.options) end return { diff --git a/lua/zettelkasten/list.lua b/lua/zettelkasten/list.lua index 223ac90..28cd7e4 100644 --- a/lua/zettelkasten/list.lua +++ b/lua/zettelkasten/list.lua @@ -8,10 +8,12 @@ end -- TODO transform paths: -- * to absolute value (e.g. ~ to home, scandir needs absolute) -- * to ensure / at the end (or no /) gets taken into account -function ls.get_anchors_and_paths(path, recursive) +function ls.get_anchors_and_paths(path, recursive, options) + options = options or {} -- TODO check for duplicates and warn user local zettel = {} - local anchorreg = '^.*/?([%d][%d][%d][%d][%d][%d][%d][%d][%d][%d])[^/]*.md$' + local anchorreg = '^.*/?([%d][%d][%d][%d][%d][%d][%d][%d][%d][%d])[^/]*%' .. + (options.zettel_extension or '.md') .. '$' local handle = vim.loop.fs_scandir(path) while handle do