From 8512bbf2cf70f81e95647e50b3c3b9dbc9c8cb0f Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 5 Feb 2024 15:42:59 +0100 Subject: [PATCH 1/2] nvim: Add existing zettel link insertion mappings Added mapping to insert a link to an existing Zettel with `ni` (note insert), either from normal mode which creates the complete link, or from visual selection mode which surrounds the current selection (as visible link text) with the link. New zettel links still use my own implementation so I have full control over their naming scheme. --- nvim/.config/nvim/lua/plugins/prose.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/nvim/.config/nvim/lua/plugins/prose.lua b/nvim/.config/nvim/lua/plugins/prose.lua index 4a0334d..7bc7715 100644 --- a/nvim/.config/nvim/lua/plugins/prose.lua +++ b/nvim/.config/nvim/lua/plugins/prose.lua @@ -130,6 +130,19 @@ local prose_plugs = { end, desc = "index page", }, + { + "ni", + function() + require("zk.commands").get("ZkInsertLink")() + end, + desc = "insert link", + }, + { + "ni", + ":'<,'>ZkInsertLinkAtSelection", + mode = "v", + desc = "insert link", + }, }, }, From fbceea242d9ffb058c664d2ab640e4b34167c1bc Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 7 Feb 2024 22:29:03 +0100 Subject: [PATCH 2/2] nvim: Fully switch to zk-nvim Removed my own plugin in favor of zk-nvim integration. --- nvim/.config/nvim/after/ftplugin/markdown.lua | 14 ++-- nvim/.config/nvim/lazy-lock.json | 1 - nvim/.config/nvim/lua/plugins/prose.lua | 65 ++++--------------- 3 files changed, 23 insertions(+), 57 deletions(-) diff --git a/nvim/.config/nvim/after/ftplugin/markdown.lua b/nvim/.config/nvim/after/ftplugin/markdown.lua index b15a268..739dcf6 100644 --- a/nvim/.config/nvim/after/ftplugin/markdown.lua +++ b/nvim/.config/nvim/after/ftplugin/markdown.lua @@ -1,6 +1,10 @@ local map = vim.keymap.set -require('which-key').register({ ["c" ] = { name = "+md-code"}}) -require('which-key').register({ ["e" ] = { name = "+criticmarkup"}}) +require("which-key").register({ ["c"] = { name = "+md-code" } }) +require("which-key").register({ ["e"] = { name = "+criticmarkup" } }) + +if require("zk.util").notebook_root(vim.fn.expand("%:p")) ~= nil then + map("n", "", "lua vim.lsp.buf.definition()", { silent = true }) +end -- edit code cells with full lsp access map("n", "ce", "FeMaco", { silent = true, desc = "edit code block" }) @@ -19,7 +23,7 @@ map("n", "cO", "O```python```k", { desc = "Insert quar map("n", "cp", "MarkdownPreviewToggle", { desc = "show md preview" }) -- create mindmaps directly from markdown! requires external executable -if (vim.fn.executable("markmap")) then - map("n", "cm", "MarkmapOpen", { desc = "open md mindmap" }) - map("n", "cM", "MarkmapWatch", { desc = "watch for md mindmap" }) +if vim.fn.executable("markmap") then + map("n", "cm", "MarkmapOpen", { desc = "open md mindmap" }) + map("n", "cM", "MarkmapWatch", { desc = "watch for md mindmap" }) end diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index e940094..f28ea72 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -87,6 +87,5 @@ "which-key.nvim": { "branch": "main", "commit": "ce741eb559c924d72e3a67d2189ad3771a231414" }, "wrapping.nvim": { "branch": "master", "commit": "5e87f1424c86c50d3bc205830aa56ed1cad45467" }, "zen-mode.nvim": { "branch": "main", "commit": "cb73b8bd0ef9d765b942db09dc762c603a89ae44" }, - "zettelkasten.nvim": { "branch": "main", "commit": "0e77624689b470410f5355b613d45219c9350264" }, "zk-nvim": { "branch": "main", "commit": "fb0962b75a680561f94cae0588b8da92ea8d2fae" } } \ No newline at end of file diff --git a/nvim/.config/nvim/lua/plugins/prose.lua b/nvim/.config/nvim/lua/plugins/prose.lua index 7bc7715..a5dcc7a 100644 --- a/nvim/.config/nvim/lua/plugins/prose.lua +++ b/nvim/.config/nvim/lua/plugins/prose.lua @@ -65,6 +65,11 @@ local prose_plugs = { prefix({ ["n"] = { name = "+notes" } }) prefix({ ["n"] = { name = "+note" } }) prefix({ ["n"] = { name = "+note", mode = "v" } }) + + require("zk.commands").add("ZkOrphans", function(opts) + opts = vim.tbl_extend("force", { orphan = true }, opts or {}) + require("zk").edit(opts, { title = "Zk Orphans" }) + end) end require("zk").setup({ picker = "telescope" }) end, @@ -82,67 +87,25 @@ local prose_plugs = { "ZkNewFromTitleSelection", "ZkNotes", "ZkTags", + "ZkOrphans", }, keys = { + { "ni", "edit ~/documents/notes/index.md", desc = "open index", silent = true }, { "nn", "ZkNotes { sort = { 'modified' } }", desc = "note list" }, { "nf", "ZkNotes { sort = { 'modified' }, match = { vim.fn.input('Search: ') } }", desc = "note search", }, + { "nf", "ZkMatch", desc = "find note from selection", mode = "v" }, { "nt", "ZkTags", desc = "note tags" }, - { "nc", "ZkCd", desc = "notes directory" }, - { "nl", "ZkLinks", desc = "note links" }, - { "nb", "ZkLinks", desc = "note backlinks" }, + { "nc", "ZkCd", desc = "notedir cd" }, + { "no", "ZkNotes { sort = { 'modified' } }", desc = "orphans list" }, + { "nl", "ZkLinks", desc = "note links" }, + { "nb", "ZkBacklinks", desc = "note backlinks" }, { "nn", "ZkNew { title = vim.fn.input('Title: ') }", desc = "new note" }, - { "nn", ":ZkNewFromTitleSelection", desc = "title from selection", mode = "v" }, - { "nN", ":ZkNewFromContentSelection", desc = "content from selection", mode = "v" }, - { "nf", ":ZkMatch", desc = "find note from selection", mode = "v" }, - }, - }, - -- 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 = { - { - "", - function() - require("zettelkasten").link_follow() - end, - silent = true, - }, - { - "", - function() - require("zettelkasten").link_follow(true) - end, - mode = "v", - }, - { - "ni", - function() - require("zk.commands").get("ZkCd")() - require("zettelkasten").index_open() - end, - desc = "index page", - }, - { - "ni", - function() - require("zk.commands").get("ZkInsertLink")() - end, - desc = "insert link", - }, - { - "ni", - ":'<,'>ZkInsertLinkAtSelection", - mode = "v", - desc = "insert link", - }, + { "nn", "ZkNewFromTitleSelection", desc = "new note from selection", mode = "v" }, + { "nN", "ZkNewFromContentSelection", desc = "content from selection", mode = "v" }, }, },