Skip to content

Commit

Permalink
chore(neorg): modfiy commands
Browse files Browse the repository at this point in the history
  • Loading branch information
ttak0422 committed Jan 15, 2025
1 parent 518569a commit 94be411
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 20 deletions.
2 changes: 2 additions & 0 deletions fnl/after/norg.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
(vim.opt_local.iskeyword:append ["$" "/"])

(let [map vim.keymap.set
cmd (fn [c] (.. :<cmd> c :<cr>))
opts (fn [d] {:noremap false :silent true :buffer true :desc d})
N [[:u
(fn []
Expand All @@ -28,6 +29,7 @@
[:<LocalLeader>nn
"<Plug>(neorg.dirman.new-note)"
(opts " Create a new note")]
[:<LocalLeader>no (cmd "Neorg toc") (opts " TOC")]
[:<LocalLeader>tu
"<Plug>(neorg.qol.todo-items.todo.task-undone)"
(opts " Mark as undone")]
Expand Down
9 changes: 9 additions & 0 deletions fnl/neorg.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
path (require :plenary.path)
dirman (neorg.modules.get_module :core.dirman)
create_command vim.api.nvim_create_user_command
confirm (fn [prompt]
(let [answer (vim.fn.input (.. prompt " (y/N): "))]
(= (answer:lower) :y)))
check_git_dir (fn []
(let [git_dir (path:new (.. (vim.fn.getcwd) :/.git))]
(git_dir:exists)))
Expand All @@ -73,6 +76,12 @@
(out:gsub "%s+" "")
(error "branch not found"))))]
(create_command :NeorgFuzzySearch "Telescope neorg find_linkable" {})
(create_command :NeorgUID
(fn []
(if (confirm "Create Note?")
(let [uid (os.date "%Y%m%d%H%M%S")]
(dirman.create_file (.. :uid/ uid) nil {:title uid}))))
{})
(create_command :NeorgGit
(fn []
(if (check_git_dir)
Expand Down
11 changes: 7 additions & 4 deletions fnl/prelude.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,14 @@
;; undo
[:U (cmd :UndotreeToggle (desc "toggle undotree"))]
;; neorg
[:nn
[:nt
(cmd "Neorg journal today")
(desc "Enter Neorg (today journal)")]
[:no (cmd "Neorg toc") (desc "Show Neorg TOC")]
[:N (cmd :Neorg) (desc "Enter Neorg")]
(desc " Today")]
[:ny
(cmd "Neorg journal yesterday")
(desc " Yesterday")]
[:N (cmd :Neorg) (desc " Enter")]
[:nn (cmd :NeorgUID) (desc " UID")]
[:ngg (cmd :NeorgGit) (desc " Git")]
[:ngb (cmd :NeorgGitBranch) (desc " Git (branch)")]
[:fn
Expand Down
15 changes: 10 additions & 5 deletions lua/autogen/after/norg.lua

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

35 changes: 25 additions & 10 deletions lua/autogen/neorg.lua

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

2 changes: 1 addition & 1 deletion lua/autogen/prelude.lua

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

1 change: 1 addition & 0 deletions main/outliner.nix
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ with pkgs.vimPlugins;
commands = [
"Neorg"
"NeorgFuzzySearch"
"NeorgUID"
"NeorgGit"
"NeorgGitBranch"
];
Expand Down

0 comments on commit 94be411

Please sign in to comment.