Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(note-taking): Add venn-nvim #901

Merged
merged 4 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions lua/astrocommunity/note-taking/venn-nvim/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# venn.nvim

Draw ASCII diagrams in Neovim with ease.

1. Enable venn mode, :lua Toggle_Venn<cr>
- 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 β”‚β—„β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β””β”€β”€β”€β”˜

**Repository:** <https://github.com/jbyuki/venn.nvim>

39 changes: 39 additions & 0 deletions lua/astrocommunity/note-taking/venn-nvim/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
return {
"jbyuki/venn.nvim",
event = "VeryLazy",
cmd = "VBox",
keys = {
{
"<Leader>vn",
"<Cmd>lua Toggle_venn()<cr>",
{ silent = true },
desc = "Toggle Venn diagram",
},
},
config = function()
function _G.Toggle_venn()
local venn_enabled = vim.inspect(vim.b.venn_enabled)
if venn_enabled == "nil" then
vim.notify("enabled Venn mode", "info", { title = "Venn" })
vim.b.venn_enabled = true
vim.cmd [[setlocal ve=all]]
-- draw a line on HJKL keystokes
vim.api.nvim_buf_set_keymap(0, "n", "J", "<C-v>j:VBox<CR>", { noremap = true })
vim.api.nvim_buf_set_keymap(0, "n", "K", "<C-v>k:VBox<CR>", { noremap = true })
vim.api.nvim_buf_set_keymap(0, "n", "L", "<C-v>l:VBox<CR>", { noremap = true })
vim.api.nvim_buf_set_keymap(0, "n", "H", "<C-v>h:VBox<CR>", { noremap = true })
-- draw a box by pressing "f" with visual selection
vim.api.nvim_buf_set_keymap(0, "v", "f", ":VBox<CR>", { noremap = true })
else
vim.notify("disabled Venn mode", "info", { title = "Venn" })
vim.cmd [[setlocal ve=]]
vim.api.nvim_buf_del_keymap(0, "n", "J")
vim.api.nvim_buf_del_keymap(0, "n", "K")
vim.api.nvim_buf_del_keymap(0, "n", "L")
vim.api.nvim_buf_del_keymap(0, "n", "H")
vim.api.nvim_buf_del_keymap(0, "v", "f")
vim.b.venn_enabled = nil
end
end
end,
Uzaaft marked this conversation as resolved.
Show resolved Hide resolved
}
Loading