-
-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(note-taking): Add venn-nvim (#901)
* feat(venn-nvim): Draw ASCII diagrams easily in Neovim * Use astrocore set_mapping api to set mappings * refactor(venn-nvim): integrate with AstroCore and improve keymap setup * docs(venn-nvim): Move repository up --------- Co-authored-by: Micah Halter <[email protected]> Co-authored-by: Uzair Aftab <[email protected]>
- Loading branch information
1 parent
62ab36a
commit 6bb14a2
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# venn.nvim | ||
|
||
Draw ASCII diagrams in Neovim with ease. | ||
|
||
**Repository:** <https://github.com/jbyuki/venn.nvim> | ||
|
||
1. Enable venn mode with `:ToggleVenn` | ||
- note this enable vim virtual edit mode which allows editing anywhere in the window | ||
2. now click any place and write down the texts | ||
3. use visual block [Ctrl-v] mode to wrap around the text and press f to draw the box | ||
4. connect the boxes using HJKL towards the next box to connect | ||
|
||
``` | ||
┌───┐ | ||
┌────────│ A │──────────┐ | ||
│ └───┘ │ | ||
│ │ | ||
▼ ┌───┐ ▼ | ||
B───────►│ C │ D | ||
└─┬─┘ │ | ||
│ │ | ||
┌─┴─┐ │ | ||
│ E │◄─────────┘ | ||
└───┘ | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
return { | ||
"jbyuki/venn.nvim", | ||
cmd = "VBox", | ||
dependencies = { | ||
"AstroNvim/astrocore", | ||
---@type AstroCoreOpts | ||
opts = { | ||
commands = { | ||
ToggleVenn = { | ||
function() | ||
local mappings = { | ||
n = { -- draw a line on HJKL keystokes | ||
H = "<C-v>h:VBox<CR>", | ||
J = "<C-v>j:VBox<CR>", | ||
K = "<C-v>k:VBox<CR>", | ||
L = "<C-v>l:VBox<CR>", | ||
}, | ||
v = { -- draw a box by pressing "f" with visual selection | ||
f = ":VBox<CR>", | ||
}, | ||
} | ||
if vim.b.venn_enabled then | ||
vim.opt_local.virtualedit = "" | ||
for mode, map in pairs(mappings) do | ||
for lhs, _ in pairs(map) do | ||
vim.keymap.del(mode, lhs, { buffer = true }) | ||
end | ||
end | ||
vim.b.venn_enabled = nil | ||
else | ||
vim.b.venn_enabled = true | ||
vim.opt_local.virtualedit = "all" | ||
require("astrocore").set_mappings(mappings, { buffer = true }) | ||
end | ||
vim.notify(("Venn Diagramming Mode: %s"):format(vim.b.venn_enabled and "Enabled" or "Disabled")) | ||
end, | ||
desc = "Toggle venn diagramming mode", | ||
}, | ||
}, | ||
mappings = { n = { ["<Leader>v"] = { function() vim.cmd.ToggleVenn() end, desc = "Toggle venn diagramming" } } }, | ||
}, | ||
}, | ||
} |