feat: allow auto-open of journal entries (#125)

This commit is contained in:
lambtho
2022-05-07 09:01:05 +00:00
committed by GitHub
parent c0925f0d30
commit c3da9a528a
2 changed files with 57 additions and 40 deletions

View File

@@ -254,6 +254,9 @@ require('telekasten').setup({
dailies_create_nonexisting = true,
weeklies_create_nonexisting = true,
-- skip telescope prompt for goto_today and goto_thisweek
journal_auto_open = false,
-- template for new notes (new_note, follow_link)
-- set to `nil` or do not specify if you do not want a template
template_new_note = home .. '/' .. 'templates/new_note.md',
@@ -362,6 +365,7 @@ END
| `follow_creates_nonexisting` | following a link to a non-existing note will create it | true |
| `dailies_create_nonexisting` | following a link to a non-existing daily note will create it | true |
| `weekly_create_nonexisting` | following a link to a non-existing weekly note will create it | true |
| `journal_auto_open` | skip telekscope picker and automatically open the note with goto_today and goto_thisweek | false |
| `template_new_note` | markdown template for new notes | ~/zettelkasten/templates/new_note.md |
| | set to `nil` if you want none | |
| `template_new_daily` | markdown template for new daily notes | ~/zettelkasten/templates/daily.md |

View File

@@ -89,6 +89,9 @@ M.Cfg = {
dailies_create_nonexisting = true,
weeklies_create_nonexisting = true,
-- skip telescope prompt for goto_today and goto_thisweek
journal_auto_open = false,
-- templates for new notes
-- template_new_note = home .. "/" .. "templates/new_note.md",
-- template_new_daily = home .. "/" .. "templates/daily_tk.md",
@@ -1712,6 +1715,7 @@ local function GotoDate(opts)
or M.Cfg.insert_after_inserting
opts.close_after_yanking = opts.close_after_yanking
or M.Cfg.close_after_yanking
opts.journal_auto_open = opts.journal_auto_open or M.Cfg.journal_auto_open
local word = opts.date or os.date(dateformats.date)
@@ -1735,6 +1739,9 @@ local function GotoDate(opts)
opts.erase_file = fname
end
if opts.journal_auto_open then
vim.cmd("e " .. fname)
else
find_files_sorted({
prompt_title = "Goto day",
cwd = M.Cfg.dailies,
@@ -1760,6 +1767,7 @@ local function GotoDate(opts)
return true
end,
})
end
end
--
@@ -2551,6 +2559,7 @@ local function GotoThisWeek(opts)
or M.Cfg.insert_after_inserting
opts.close_after_yanking = opts.close_after_yanking
or M.Cfg.close_after_yanking
opts.journal_auto_open = opts.journal_auto_open or M.Cfg.journal_auto_open
if not global_dir_check() then
return
@@ -2572,6 +2581,9 @@ local function GotoThisWeek(opts)
opts.erase_file = fname
end
if opts.journal_auto_open then
vim.cmd("e " .. fname)
else
find_files_sorted({
prompt_title = "Goto this week:",
cwd = M.Cfg.weeklies,
@@ -2588,6 +2600,7 @@ local function GotoThisWeek(opts)
return true
end,
})
end
end
--