mirror of
https://github.com/Ascyii/telekasten.nvim.git
synced 2026-01-01 06:14:23 -05:00
Add custom function option for UUID generation (#194)
* add custom function option for UUID generation * add docs for new UUID custom function option
This commit is contained in:
@@ -64,7 +64,12 @@ local function defaultConfig(home)
|
||||
-- "uuid-title" - Prefix title by uuid
|
||||
-- "title-uuid" - Suffix title with uuid
|
||||
new_note_filename = "title",
|
||||
-- file uuid type ("rand" or input for os.date()")
|
||||
|
||||
--[[ file UUID type
|
||||
- "rand"
|
||||
- string input for os.date()
|
||||
- or custom lua function that returns a string
|
||||
--]]
|
||||
uuid_type = "%Y%m%d%H%M",
|
||||
-- UUID separator
|
||||
uuid_sep = "-",
|
||||
@@ -208,10 +213,12 @@ local function get_uuid(opts)
|
||||
opts.uuid_type = opts.uuid_type or M.Cfg.uuid_type
|
||||
|
||||
local uuid
|
||||
if opts.uuid_type ~= "rand" then
|
||||
uuid = os.date(opts.uuid_type)
|
||||
else
|
||||
if opts.uuid_type == "rand" then
|
||||
uuid = random_variable(6)
|
||||
elseif type(opts.uuid_type) == "function" then
|
||||
uuid = opts.uuid_type()
|
||||
else
|
||||
uuid = os.date(opts.uuid_type)
|
||||
end
|
||||
return uuid
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user