2023-09-08 19:49:18 +02:00
|
|
|
local M = {
|
|
|
|
"jbyuki/venn.nvim", -- draw ascii diagrams
|
|
|
|
dependencies = {
|
|
|
|
"anuvyklack/hydra.nvim",
|
|
|
|
},
|
|
|
|
keys = { "<leader>V" },
|
|
|
|
}
|
|
|
|
|
2023-09-08 20:00:42 +02:00
|
|
|
local venn_hint_old = [[
|
2023-09-18 02:15:13 +02:00
|
|
|
^^^Draw arrow^^^ Select region with <C-v>
|
2023-09-08 19:49:18 +02:00
|
|
|
^ ^ _K_ ^ ^ _f_: surround it with box
|
|
|
|
_H_ ^ ^ _L_
|
|
|
|
^ ^ _J_ ^ ^ _<Esc>_
|
|
|
|
]]
|
|
|
|
|
2023-09-08 20:00:42 +02:00
|
|
|
local H = require("my.plugins.hydra").hint
|
|
|
|
|
|
|
|
local venn_hint = H.concat_many_h({
|
2023-09-18 02:15:13 +02:00
|
|
|
H.add_title("Draw arrows", H.directional("H", "J", "K", "L", 3)),
|
2023-09-08 20:00:42 +02:00
|
|
|
H.add_title(
|
|
|
|
"Actions",
|
|
|
|
H.concat_many_w({
|
|
|
|
H.concat_h("<C-v>", ": select region"),
|
|
|
|
H.concat_h(H.pad_right(H.highlight("f"), 5), ": surround with box"),
|
2023-09-18 02:15:13 +02:00
|
|
|
H.concat_h(H.pad_right(H.highlight("<Esc>"), 5), ": quit"),
|
2023-09-08 20:00:42 +02:00
|
|
|
}, { justify = "left" })
|
|
|
|
),
|
|
|
|
}, 3).value
|
|
|
|
|
2023-09-08 19:49:18 +02:00
|
|
|
function M.config()
|
2023-12-21 16:21:14 +01:00
|
|
|
-- local r = "<leader>V"
|
|
|
|
-- vim.keymap.set("n", r .. "H", "<C-v>h:VBox<CR>", { desc = "left" })
|
|
|
|
-- vim.keymap.set("n", r .. "J", "<C-v>j:VBox<CR>", { desc = "down" })
|
|
|
|
-- vim.keymap.set("n", r .. "K", "<C-v>k:VBox<CR>", { desc = "up" })
|
|
|
|
-- vim.keymap.set("n", r .. "L", "<C-v>l:VBox<CR>", { desc = "right" })
|
|
|
|
-- vim.keymap.set("v", r .. "f", ":VBox<CR>", { desc = "box" })
|
2023-09-08 19:49:18 +02:00
|
|
|
|
2023-12-21 16:21:14 +01:00
|
|
|
local Hydra = require("hydra")
|
|
|
|
|
|
|
|
Hydra({
|
|
|
|
name = "Draw Diagram",
|
|
|
|
hint = venn_hint,
|
|
|
|
config = {
|
|
|
|
color = "pink",
|
|
|
|
invoke_on_body = true,
|
|
|
|
hint = {
|
|
|
|
border = "single",
|
|
|
|
},
|
|
|
|
on_enter = function()
|
|
|
|
vim.opt.virtualedit = "all"
|
|
|
|
vim.g.inside_venn = true
|
|
|
|
end,
|
|
|
|
on_exit = function()
|
|
|
|
vim.opt.virtualedit = ""
|
|
|
|
end,
|
|
|
|
desc = "[V]enn mode",
|
|
|
|
},
|
|
|
|
mode = "n",
|
|
|
|
body = "<leader>V",
|
|
|
|
heads = {
|
2024-01-01 21:24:04 +01:00
|
|
|
{ "H", "<C-v>h<esc><cmd>silent VBox<cr>", { silent = true } },
|
|
|
|
{ "J", "<C-v>j<esc><cmd>silent VBox<cr>", { silent = true } },
|
|
|
|
{ "K", "<C-v>k<esc><cmd>silent VBox<cr>", { silent = true } },
|
|
|
|
{ "L", "<C-v>l<esc><cmd>silent VBox<cr>", { silent = true } },
|
2023-12-21 16:21:14 +01:00
|
|
|
{ "f", "<cmd>VBox<cr>", { mode = "v" } },
|
|
|
|
{ "<Esc>", nil, { exit = true } },
|
|
|
|
},
|
|
|
|
})
|
2024-01-01 21:24:04 +01:00
|
|
|
|
|
|
|
-- vim.keymap.set("n", "w", "<C-v>h:VBox<cr>", { silent = true })
|
2023-09-08 19:49:18 +02:00
|
|
|
end
|
|
|
|
|
2023-12-21 16:21:14 +01:00
|
|
|
function M.init()
|
2024-01-01 21:24:04 +01:00
|
|
|
-- require("which-key").register({
|
|
|
|
-- ["<leader>V"] = { name = "[V]enn mode" },
|
|
|
|
-- })
|
2023-12-21 16:21:14 +01:00
|
|
|
end
|
2023-09-08 19:49:18 +02:00
|
|
|
|
2023-12-21 16:21:14 +01:00
|
|
|
return M
|