Add filename_space_subst config option (#198)

* add filename_space_subst configuration option

* add docs for new filename_space_subst

* fix template refactor bug
This commit is contained in:
skovati
2023-01-07 21:05:14 +00:00
committed by GitHub
parent 00026d6295
commit 7a6e89131e
3 changed files with 26 additions and 3 deletions

View File

@@ -74,6 +74,9 @@ local function defaultConfig(home)
-- UUID separator
uuid_sep = "-",
-- if not nil, replaces any spaces in the title when it is used in filename generation
filename_space_subst = nil,
-- following a link to a non-existing note will create it
follow_creates_nonexisting = true,
dailies_create_nonexisting = true,
@@ -224,6 +227,10 @@ local function get_uuid(opts)
end
local function generate_note_filename(uuid, title)
if M.Cfg.filename_space_subst ~= nil then
title = escape(title):gsub(" ", M.Cfg.filename_space_subst)
end
local pp = Path:new(title)
local p_splits = pp:_split()
local filename = p_splits[#p_splits]
@@ -649,9 +656,9 @@ local function linesubst(line, title, dates, uuid)
end
local substs = vim.tbl_extend("error", dates, {
shorttitle,
uuid,
title,
shorttitle = shorttitle,
uuid = uuid,
title = title,
})
for k, v in pairs(substs) do