From 22b70a06390950c31c3f86f48a8f727ed8253f9a Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 5 Feb 2024 14:55:09 +0100 Subject: [PATCH] nvim: Enter notes dir when calling zettel index When switching the current buffer to the Zettelkasten index page (`ni`), we now also switch the working directory to the corresponding notes directory. --- nvim/.config/nvim/lua/plugins/prose.lua | 4 ++++ nvim/.config/sh/alias.d/neovim.sh | 9 +++++++++ sh/.config/sh/alias | 20 +++++++------------- 3 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 nvim/.config/sh/alias.d/neovim.sh diff --git a/nvim/.config/nvim/lua/plugins/prose.lua b/nvim/.config/nvim/lua/plugins/prose.lua index 4f3e4fb..4a0334d 100644 --- a/nvim/.config/nvim/lua/plugins/prose.lua +++ b/nvim/.config/nvim/lua/plugins/prose.lua @@ -103,6 +103,9 @@ local prose_plugs = { -- simple static markdown linking and link following using zettel IDs { "marty-oehme/zettelkasten.nvim", + dependencies = { + "mickael-menu/zk-nvim", -- for the CD when opening index + }, ft = writing_ft, keys = { { @@ -122,6 +125,7 @@ local prose_plugs = { { "ni", function() + require("zk.commands").get("ZkCd")() require("zettelkasten").index_open() end, desc = "index page", diff --git a/nvim/.config/sh/alias.d/neovim.sh b/nvim/.config/sh/alias.d/neovim.sh new file mode 100644 index 0000000..da610fd --- /dev/null +++ b/nvim/.config/sh/alias.d/neovim.sh @@ -0,0 +1,9 @@ +# v shorthand for neovim +if exist nvim; then + alias v="nvim" + alias vim="nvim" + + # open notes with my vim zettelkasten plugin + # TODO better implementation conditional on zk & zettelkasten existing + alias vn='nvim +"lua require \"zk.commands\".get(\"ZkCd\")()" +"lua require \"zettelkasten\".index_open()"' +fi diff --git a/sh/.config/sh/alias b/sh/.config/sh/alias index 5b628a5..4af2790 100644 --- a/sh/.config/sh/alias +++ b/sh/.config/sh/alias @@ -7,20 +7,14 @@ exist() { type "$1" >/dev/null 2>&1; } # Avoid aliases which I did not create -- unalias EVERYTHING unalias -a -# v shorthand for neovim -if exist nvim; then - alias v="nvim" - alias vim="nvim" - alias vs="nvim -c 'ScratchPad'" # open an empty 'scratchpad' which simply disappears after use - alias vw="nvim -c \"lua require 'zettelkasten'.index_open()\"" # open to personal wiki -elif exist vim; then - alias v="vim" -else - alias v="vi" - alias vim="vi" +if alias v >/dev/null 2>&1; then + if exist vim; then + alias v="vim" + else + alias v="vi" + alias vim="vi" + fi fi -# open notes with my vim zettelkasten plugin -alias vn='v +"lua require \"zettelkasten\".index_open()"' # exit shell mimicks vim alias :q="exit"