jbyuki/venn.nvim

github github
note-taking plugin
star 224
stars
alert-circle 0
open issues
users 4
subscribers
git-branch 3
forks
CREATED

2021-06-01

UPDATED

2 days ago

packer

require('packer').startup(function()
  use 'jbyuki/venn.nvim'
end)

paq

require "paq" { 
  'jbyuki/venn.nvim'
}

venn.nvim

Draw ASCII diagrams in Neovim.

Installation

Install using your prefered method:

Usage

  • set virtualedit=all or set ve=all. This will allow you to freely move the cursor in the buffer. (see help virtualedit).

  • Enter in Visual Block mode using <C-v>. Select the region where the box should be.

  • Invoke :VBox. This will draw a rectangle. In case, it has a width or a height of 1, it will draw a line.

Key Mapping

You can map :VBox commands to allow different ways of drawing lines.

This function toggles drawing lines on HJKL directional keys to allow for faster diagraming.

-- enable or disable keymappings for venn
function _G.toggle_venn()
    local venn_enabled = vim.inspect(vim.b.venn_enabled) 
    if(venn_enabled == "nil") then
        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.cmd[[setlocal ve=]]
        vim.cmd[[mapclear <buffer>]]
        vim.b.venn_enabled = nil
    end
end
-- toggle keymappings for venn using <leader>v
vim.api.nvim_set_keymap('n', '<leader>v', ":lua toggle_venn()<cr>", { noremap = true})

veenDemo