mirror of
https://github.com/Ascyii/telekasten.nvim.git
synced 2026-01-01 06:14:23 -05:00
feat: add filename_small_case (#344)
Add an option to cast the new filename to lowercase. Closes #311.
This commit is contained in:
@@ -309,6 +309,19 @@ telekasten.setup({opts})
|
|||||||
|
|
||||||
Default: `nil`
|
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*
|
*telekasten.settings.image_link_style*
|
||||||
image_link_style: ~
|
image_link_style: ~
|
||||||
Style of links to insert when pasting an image.
|
Style of links to insert when pasting an image.
|
||||||
|
|||||||
@@ -73,6 +73,8 @@ local function defaultConfig(home)
|
|||||||
uuid_sep = "-",
|
uuid_sep = "-",
|
||||||
-- if not nil, replaces any spaces in the title when it is used in filename generation
|
-- if not nil, replaces any spaces in the title when it is used in filename generation
|
||||||
filename_space_subst = nil,
|
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
|
-- following a link to a non-existing note will create it
|
||||||
follow_creates_nonexisting = true,
|
follow_creates_nonexisting = true,
|
||||||
dailies_create_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)
|
title = title:gsub(" ", M.Cfg.filename_space_subst)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if M.cfg.filename_small_case then
|
||||||
|
title = string.lower(title)
|
||||||
|
end
|
||||||
|
|
||||||
local pp = Path:new(title)
|
local pp = Path:new(title)
|
||||||
local p_splits = pp:_split()
|
local p_splits = pp:_split()
|
||||||
local filename = p_splits[#p_splits]
|
local filename = p_splits[#p_splits]
|
||||||
|
|||||||
Reference in New Issue
Block a user