Fix zettel listing obeying zettel extension option

This commit is contained in:
Marty Oehme 2020-10-29 19:09:13 +01:00
parent e5afcb5e15
commit 441cbcbc63
Signed by: Marty
GPG key ID: B7538B8F50A1C800
2 changed files with 5 additions and 3 deletions

View file

@ -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 {

View file

@ -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