From 9610fcd391034b318bdec25a071fa50b984fa2b7 Mon Sep 17 00:00:00 2001 From: Ethan Rooke Date: Thu, 10 Oct 2024 19:29:41 -0500 Subject: [PATCH] feat: add filename_small_case Add an option to cast the new filename to lowercase. Closes #311. --- doc/telekasten.txt | 13 +++++++++++++ lua/telekasten.lua | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/doc/telekasten.txt b/doc/telekasten.txt index 019a798..fd2eec7 100644 --- a/doc/telekasten.txt +++ b/doc/telekasten.txt @@ -309,6 +309,19 @@ telekasten.setup({opts}) Default: `nil` + *telekasten.settings.filename_small_case* + filename_small_case: ~ + When the note title is used within the filename, i.e. + |new_note_filename| contains 'title', the tile will be + made lowercase. + + e.g. if set to true, '20230103-My New Note Title.md' would instead + become '20230103-my new note title.md' + + If set to `false`, no substitution will occur. + + Default: `false` + *telekasten.settings.image_link_style* image_link_style: ~ Style of links to insert when pasting an image. diff --git a/lua/telekasten.lua b/lua/telekasten.lua index fec478b..5684006 100644 --- a/lua/telekasten.lua +++ b/lua/telekasten.lua @@ -73,6 +73,8 @@ local function defaultConfig(home) uuid_sep = "-", -- if not nil, replaces any spaces in the title when it is used in filename generation filename_space_subst = nil, + -- if true, make the filename lowercase + filename_small_case = false, -- following a link to a non-existing note will create it follow_creates_nonexisting = true, dailies_create_nonexisting = true, @@ -180,6 +182,10 @@ local function generate_note_filename(uuid, title) title = title:gsub(" ", M.Cfg.filename_space_subst) end + if M.cfg.filename_small_case then + title = string.lower(title) + end + local pp = Path:new(title) local p_splits = pp:_split() local filename = p_splits[#p_splits]