diff --git a/lua/plugins/notes.lua b/lua/plugins/notes.lua index 77edfc8..ea19f7e 100644 --- a/lua/plugins/notes.lua +++ b/lua/plugins/notes.lua @@ -1,57 +1,98 @@ -require("zk").setup() -require("mkdnflow").setup({}) +require("zk").setup({ picker = "telescope" }) +require("mkdnflow").setup({ + mappings = { + MkdnEnter = { { "n", "v" }, "" }, + MkdnTab = false, + MkdnSTab = false, + MkdnNextLink = { "n", "" }, + MkdnPrevLink = { "n", "" }, + MkdnNextHeading = { "n", "]]" }, + MkdnPrevHeading = { "n", "[[" }, + MkdnGoBack = { "n", "" }, + MkdnGoForward = { "n", "" }, + MkdnCreateLink = false, -- see MkdnEnter + MkdnCreateLinkFromClipboard = { { "n", "v" }, "p" }, -- see MkdnEnter + MkdnFollowLink = false, -- see MkdnEnter + MkdnDestroyLink = { "n", "" }, + MkdnTagSpan = { "v", "" }, + MkdnMoveSource = { "n", "" }, + MkdnYankAnchorLink = { "n", "ya" }, + MkdnYankFileAnchorLink = { "n", "yfa" }, + MkdnIncreaseHeading = { "n", "+" }, + MkdnDecreaseHeading = { "n", "-" }, + MkdnToggleToDo = { { "n", "v" }, "" }, + MkdnNewListItem = false, + MkdnNewListItemBelowInsert = { "n", "o" }, + MkdnNewListItemAboveInsert = { "n", "O" }, + MkdnExtendList = false, + -- MkdnUpdateNumbering = { "n", "nn" }, + MkdnUpdateNumbering = false, + MkdnTableNextCell = { "i", "" }, + MkdnTablePrevCell = { "i", "" }, + MkdnTableNextRow = false, + MkdnTablePrevRow = { "i", "" }, + MkdnTableNewRowBelow = { "n", "ir" }, + MkdnTableNewRowAbove = { "n", "iR" }, + MkdnTableNewColAfter = { "n", "ic" }, + MkdnTableNewColBefore = { "n", "iC" }, + MkdnFoldSection = { "n", "f" }, + MkdnUnfoldSection = { "n", "F" }, + }, +}) + require("clipboard-image").setup({ - default = { - img_dir = { "%:p:h", "img" }, - img_name = function() - vim.fn.inputsave() - local name = vim.fn.input("Name: ") - vim.fn.inputrestore() - return name - end, - }, + default = { + img_dir = { "%:p:h", "img" }, + img_name = function() + vim.fn.inputsave() + local name = vim.fn.input("Name: ") + vim.fn.inputrestore() + return name + end, + }, }) + require("telescope").load_extension("zk") local wk = require("which-key") wk.register({ - n = { - n = { - function() - vim.ui.input({ prompt = "Note title: " }, function(input) - require("zk.commands").get("ZkNew")({ title = input }) - end) - end, - "Create new note", - }, - d = { - function() - require("zk.commands").get("ZkNew")({ dir = "journal" }) - end, - "Create or edit daily note", - }, - f = { - function() - require("zk.commands").get("ZkNotes")() - end, - "Find note", - }, - i = { - function() - require("zk.commands").get("ZkIndex")() - end, - "Index notes", - }, - t = { - function() - require("zk.commands").get("ZkTag")() - end, - "Search by tag", - }, - }, + n = { + n = { + function() + vim.ui.input({ prompt = "Note title: " }, function(input) + require("zk.commands").get("ZkNew")({ title = input }) + end) + end, + "Create new note", + }, + d = { + function() + require("zk.commands").get("ZkNew")({ dir = "journal" }) + end, + "Create or edit daily note", + }, + f = { + function() + require("zk.commands").get("ZkNotes")() + end, + "Find note", + }, + i = { + function() + require("zk.commands").get("ZkIndex")() + end, + "Index notes", + }, + t = { + function() + require("zk.commands").get("ZkTag")() + end, + "Search by tag", + }, + }, }, { - prefix = "", + prefix = "", }) local augroup = vim.api.nvim_create_augroup("MarkdownZk", {}) @@ -60,79 +101,79 @@ local patt = { ZK_NOTEBOOK_DIR .. "/*.md" } vim.api.nvim_clear_autocmds({ group = augroup }) vim.api.nvim_create_autocmd("BufEnter", { - group = augroup, - pattern = patt, - callback = function(bufnr) - vim.cmd("lcd %:p:h") + group = augroup, + pattern = patt, + callback = function(bufnr) + vim.cmd("lcd %:p:h") - wk.register({ - t = { - function() - require("zk.commands").get("ZkNewFromTitleSelection")() - end, - "New note (selected as title)", - }, - c = { - function() - require("zk.commands").get("ZkNewFromContentSelection")() - end, - "New note (selected as content)", - }, - m = { - function() - require("zk.commands").get("ZkMatch")() - end, - "Find note match", - }, - i = { - function() - require("zk").pick_notes(nil, nil, function(notes) - local vstartr, vstartc = unpack(vim.api.nvim_win_get_cursor(0)) - local _, vendr, vendc, _ = unpack(vim.fn.getpos("v")) + wk.register({ + t = { + function() + require("zk.commands").get("ZkNewFromTitleSelection")() + end, + "New note (selected as title)", + }, + c = { + function() + require("zk.commands").get("ZkNewFromContentSelection")() + end, + "New note (selected as content)", + }, + m = { + function() + require("zk.commands").get("ZkMatch")() + end, + "Find note match", + }, + i = { + function() + require("zk").pick_notes(nil, nil, function(notes) + local vstartr, vstartc = unpack(vim.api.nvim_win_get_cursor(0)) + local _, vendr, vendc, _ = unpack(vim.fn.getpos("v")) - local link = "[" .. notes[1].title .. "](" .. notes[1].path .. ")" - print(vstartr, vstartc, vendr, vendc, vstartc + #link) + local link = "[" .. notes[1].title .. "](" .. notes[1].path .. ")" + print(vstartr, vstartc, vendr, vendc, vstartc + #link) - vim.api.nvim_buf_set_text(0, vstartr - 1, vstartc - 2, vendr - 1, vendc, { link }) - vim.api.nvim_win_set_cursor(0, { vendr, vstartc + #link - 3 }) - end) - end, - "Insert note link", - }, - }, { - mode = "v", - bufnr = bufnr, - prefix = "", - }) + vim.api.nvim_buf_set_text(0, vstartr - 1, vstartc - 2, vendr - 1, vendc, { link }) + vim.api.nvim_win_set_cursor(0, { vendr, vstartc + #link - 3 }) + end) + end, + "Insert note link", + }, + }, { + mode = "v", + bufnr = bufnr, + prefix = "", + }) - wk.register({ - b = { - function() - require("zk.commands").get("ZkBacklinks")() - end, - "Show note backlinks", - }, - l = { - function() - require("zk.commands").get("ZkLinks")() - end, - "Show note links", - }, - i = { - function() - require("zk").pick_notes(nil, nil, function(notes) - local cur = vim.api.nvim_win_get_cursor(0) - local link = "[" .. notes[1].title .. "](" .. notes[1].path .. ")" - vim.api.nvim_buf_set_text(0, cur[1] - 1, cur[2], cur[1] - 1, cur[2], { link }) - vim.api.nvim_win_set_cursor(0, { cur[1], cur[2] + #link }) - end) - end, - "Insert note link", - }, - }, { - mode = "n", - bufnr = bufnr, - prefix = "", - }) - end, + wk.register({ + b = { + function() + require("zk.commands").get("ZkBacklinks")() + end, + "Show note backlinks", + }, + l = { + function() + require("zk.commands").get("ZkLinks")() + end, + "Show note links", + }, + i = { + function() + require("zk").pick_notes(nil, nil, function(notes) + local cur = vim.api.nvim_win_get_cursor(0) + local link = "[" .. notes[1].title .. "](" .. notes[1].path .. ")" + vim.api.nvim_buf_set_text(0, cur[1] - 1, cur[2], cur[1] - 1, cur[2], { link }) + vim.api.nvim_win_set_cursor(0, { cur[1], cur[2] + #link }) + end) + end, + "Insert note link", + }, + }, { + mode = "n", + bufnr = bufnr, + prefix = "", + }) + end, })