mirror of
https://github.com/Ascyii/telekasten.nvim.git
synced 2026-01-01 06:14:23 -05:00
feat(rename): prefill when renaming (closes #218)
This commit is contained in:
@@ -1695,7 +1695,7 @@ end
|
|||||||
local function RenameNote()
|
local function RenameNote()
|
||||||
local oldfile = Pinfo:new({ filepath = vim.fn.expand("%:p"), M.Cfg })
|
local oldfile = Pinfo:new({ filepath = vim.fn.expand("%:p"), M.Cfg })
|
||||||
|
|
||||||
tkutils.prompt_title(M.Cfg.extension, function(newname)
|
tkutils.prompt_title(M.Cfg.extension, oldfile.title, function(newname)
|
||||||
local newpath = newname:match("(.*/)") or ""
|
local newpath = newname:match("(.*/)") or ""
|
||||||
newpath = M.Cfg.home .. "/" .. newpath
|
newpath = M.Cfg.home .. "/" .. newpath
|
||||||
|
|
||||||
@@ -2089,7 +2089,7 @@ local function CreateNoteSelectTemplate(opts)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
tkutils.prompt_title(M.Cfg.extension, function(title)
|
tkutils.prompt_title(M.Cfg.extension, nil, function(title)
|
||||||
on_create_with_template(opts, title)
|
on_create_with_template(opts, title)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@@ -2162,7 +2162,7 @@ local function CreateNote(opts)
|
|||||||
return CreateNoteSelectTemplate(opts)
|
return CreateNoteSelectTemplate(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
tkutils.prompt_title(M.Cfg.extension, function(title)
|
tkutils.prompt_title(M.Cfg.extension, nil, function(title)
|
||||||
on_create(opts, title)
|
on_create(opts, title)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,12 +6,14 @@ local function strip_extension(str, ext)
|
|||||||
return str:gsub("(" .. ext:gsub("%.", "%%.") .. ")$", "")
|
return str:gsub("(" .. ext:gsub("%.", "%%.") .. ")$", "")
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.prompt_title(ext, callback)
|
function M.prompt_title(ext, defaultFile, callback)
|
||||||
local canceledStr = "__INPUT_CANCELLED__"
|
local canceledStr = "__INPUT_CANCELLED__"
|
||||||
|
|
||||||
vim.ui.input({
|
vim.ui.input({
|
||||||
prompt = "Title: ",
|
prompt = "Title: ",
|
||||||
cancelreturn = canceledStr,
|
cancelreturn = canceledStr,
|
||||||
|
completion = "file",
|
||||||
|
default = defaultFile
|
||||||
}, function(title)
|
}, function(title)
|
||||||
if not title then
|
if not title then
|
||||||
title = ""
|
title = ""
|
||||||
|
|||||||
Reference in New Issue
Block a user