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