Skip to content

Commit

Permalink
Export tab_view
Browse files Browse the repository at this point in the history
  • Loading branch information
hulufei committed Sep 3, 2024
1 parent 6d64f57 commit 244c56f
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 28 deletions.
22 changes: 15 additions & 7 deletions fnl/diary/init.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,21 @@
(local bufs (list-bufs-match-dir path))
(unpack (filter-current-tab-wins (list-wins-with-bufs bufs))))

(fn tab-view [name]
(let [dir? (= (vim.fn.isdirectory name) 1)
dir (if dir? name (vim.fs.dirname name))]
(tab-open
(get-win-match-dir dir)
(when (not dir?)
(vim.cmd.edit name))
(do
(if dir?
(vim.cmd.tabnew)
(vim.cmd.tabnew name))
(vim.cmd.tcd dir)))))

(fn tab-view-diary [filename]
(let [diary (.. config.diary-dir filename)]
(tab-open (get-win-match-dir config.diary-dir)
(vim.cmd.edit diary)
(do
(vim.cmd.tabnew diary)
(vim.cmd.tcd config.diary-dir)))))
(tab-view (.. config.diary-dir filename)))

(fn tab-new-diary []
(let [diary (.. (os.date "%Y-%m-%d") ".md")]
Expand Down Expand Up @@ -148,4 +156,4 @@
(vim.api.nvim_create_user_command :YesterdayOnceMore review-yesterday-once-more {})
(vim.api.nvim_create_user_command :DiaryGenerateLinks write-diary-index {}))

{: setup }
{: setup :tab_view tab-view}
59 changes: 38 additions & 21 deletions lua/diary/init.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 244c56f

Please sign in to comment.