jbyuki / venn.nvim Goto Github PK
View Code? Open in Web Editor NEWDraw ASCII diagrams in Neovim
License: MIT License
Draw ASCII diagrams in Neovim
License: MIT License
Hi! This plugin is amazing. I'm using it in my work daily.
Would it be possible to enable drawing the box outside the selected block?
My usual workflow is like this:
If venn was smart enough to offset the box characters by 1 I wouldn't have to remember to do steps (3), (4), (7), and (8). I often use ASCII notes as a drawboard during brainstorming meetings. Any additional cognitive load makes it harder to keep up with the discussion.
Running inside cmd window with :lua Toggle_venn
fails with
E5107: Error loading lua [string ":lua"]:1: '=' expected near '<eof>'
Subsequent drawing is then not possible with HJKL
.
Running :VBox<CR>
still works though.
I tried to include this into vim (other than neovim), it does not work. Is it doable or any work around that allow me to use this plug in vim? Thank you very much!
It looks like the hydra suggested keybinds print :VBox
to the cmd line even when silent = true
, which make the statusline flicker when cmdheight=0
. I cannot figure out how to use :silent
with a visual mode command, so it would be nice if the readme suggested a way to fix issues like these. It would be nice if there was a documented way to call VBox
directly from lua, for example, without going through the cmdline mechanism.
I am curious how you are "invoking :VBox" after making your selection, I can't quite figure it out. On the bottom right of your gif it shows <20> every time you "invoke". What does that mean?
Thanks, I realize it probably isn't an issue with your library, but with me being somewhat of a newb with neovim. Great tool tho! I'd love to use it.
I've just tried to install this plugin using Plug
and I get the following error,
x venn.nvim:
fatal: invalid reference: master
I thought it's probably pointing to master when the branch is called 'main'. So I installed this plugin using Plug 'jbyuki/venn.nvim', { 'branch': 'main' }
and that worked without errors. But now when I invoke :VBox
I get 'Not an editor command :VBox'. I tried PlugClean
just to make sure nothing was getting left behind when it errors out, but still the same issue. I haven't added your key mappings by the way, but I think the :VBox
command should work regardless, isn't it? Thanks for what looks like a really promising drawing plugin for nvim. (Been using mermaidjs in markdown files, but this will mean I can draw in any file - cheers for that)
Hey, sorry for the issue, can't invoke VBox and when I start up nvim I get these error messages from the config file
Error detected while processing /home/moondialectix/.config/nvim/init.vim:
line 8:
E492: Not an editor command: -- venn.nvim: enable or disable keymappings
line 9:
E121: Undefined variable: _G
line 10:
E492: Not an editor command: local venn_enabled = vim.inspect(vim.b.venn_ena
bled)
line 11:
E121: Undefined variable: venn_enabled
E15: Invalid expression: venn_enabled == "nil" then
line 26:
E580: :endif without :if: end
line 27:
E492: Not an editor command: -- toggle keymappings for venn using v
"nvim_set_keymap('n'," [New File]
Cannot open file "nvim_set_keymap('n',"
"'v'," [New File]
"":lua" [New File]
"Toggle_venn()"," [New File]
"{" [New File]
Cannot open file "{"
"noremap" [New File]
Cannot open file "noremap"
"=" [New File]
Cannot open file "="
"true})" [New File]
Cannot open file "true})"
line 28:
E480: No match: api
This plugin is the ONLY reason I would want to use a mouse in neovim. Is ot even possible to integrate mouse support ? Lets say Shift
and mouse drag for boxes, normal drag for lines etc.
I think it will make things much nicer to use.
It seems venn
changes the last visual selection. For example if I select some visual block and do :VBox
and then gv
then it does not select same same region anymore.
Maybe the last visual selection could be saved before drawing the box and then restored again after?
How can I delete a letter or selection such that the text on the right side remains identical (ie a right shift of the left side by 1 character):
|_1_2_3 123|
to
|_1_2_3123|
or
|_1_2_3 123|
to
|_1_2_3123|
This is a very common operation during drawing, when one wants to insert text leftwards from a drawing or edit it.
Also briefly mentioned in anuvyklack/hydra.nvim#94. Besides overlapping logic for 1, overwrites, 2. + on intersections and arrow logic I suspect the selection logic can probably (hydra has many bugs) be done within hydra.
The idea description, hopefully dense enough.
-- symbols (-,|,^,<,>,/,\)
local venn_hint_ascii = [[
- and | moves^^ Confirmation moves^^^^
^ ^ _K_ ^ ^ ^ ^ _<C-h>_: ◄, _<C-j>_: ▼
_H_ ^ ^ _L_ ^ ^ ^ ^ ^ ^ ^
^ ^ _J_ ^ ^ ^ ^ _<C-k>_: ▲, _<C-l>_: ►
◄ + ▲ = \ ^ ^ ^ ◄ + ◄ / ► + ► = - / -
► + ▲ = / ^ ^ ^ ▲ + ▲ / ▼ + ▼ = | / |
◄ + ▼ = \ ^ ^ ^ other followup symbol
► + ▼ = / ^ ^ ^ + ◄▼▲► = <v^> and ▼ = nop
_F_: surround^^ _f_: surround ^^ ^
+ corners ^ ^^ overwritten corners
_<C-c>_
]]
Capital letters overwrite intersections via +, so going 1 up from
------
^<- cursor
|
yields
------+<- cursor
|
|
and likewise the boxing with F.
C-hjkl are to indicate a direction for overwriting with necessary repeated pressing.
The idea is that hk can be pressed very fast, so there is marginal slowdown and things like >>>>>> can be pressed much faster via > and dot-repeat anyway except for ^, which I think is acceptable with C-v5kr^ stored within a macro taking the count from another register (to be provided).
E5108: Error executing lua [string ":lua"]:1: attempt to call global 'Toggle_venn' (a nil value)
stack traceback:
[string ":lua"]:1: in main chunk
E5108: Error executing lua [string ":lua"]:1: attempt to index a boolean value
stack traceback:
[string ":lua"]:1: in main chunk
im getting this on :VBox
Great plugin 🎉
Maybe there could be another command, eg :VBoxDouble
which uses ═
, ║
etc? Could also be one for thicker ones
Only providing diagonal lines and have a way to insert up and down arrow should be sufficient for most cases.
However having the optional +
in several cases could also simplify drawing.
The ultra interface would be of course a curve plotting from a selection via commands and interpolation of results, but thats quite some complexity.
Meta: Can you make example configs or video for 1.debugger, 2.how to log stuff in lua with plenary, 3. repl things?
Meta2: Is nvim-luadev the best option as lua repl or could this be combined with the debugger somehow?
Toggle_venn = function()
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
map('n', '<leader>v', ":lua Toggle_venn()<cr>", opts)
Currently if you draw a line over another it replaces any existing characters such as:
▲
│
┌──────┐ │ │
│ ├──│───┘
└──────┘ │
▼
which in some cases might be desirable but it would also be great to get the crossing characters such as ┼
.
If #2 is implemented there might be more crossings to consider.
using venn.nvim stop my nvim from working
Same as anuvyklack/hydra.nvim#94.
Not sure, if you feel like providing an addition config in the README. My use case I do expect to frequently come up again was to make the following dense diagram for a state automaton alongside code:
# ┌─────────────────────────┐
# ▼ ▼──────────┐ │
# inactive(1)───▼ │ maybe_active(0)
# ▲ ▼ error_detected(3)───▲
# active(2)─────▲
-- (◄,▼,▲,►) in utf16: (0x25C4,0x25BC,0x25B2,0x25BA)
local venn_hint = [[
Arrow^^^^^^ Select region with <C-v>^^^^^^
^ ^ _K_ ^ ^ _f_: Surround with box ^ ^ ^ ^
_H_ ^ ^ _L_ _<C-h>_: ◄, _<C-j>_: ▼
^ ^ _J_ ^ ^ _<C-k>_: ▲, _<C-l>_: ► _<C-c>_
]]
-- :setlocal ve=all
-- :setlocal ve=none
M.venn_hydra = Hydra {
name = 'Draw Diagram',
hint = venn_hint,
config = {
color = 'pink',
invoke_on_body = true,
hint = {
border = 'rounded',
},
on_enter = function() vim.wo.virtualedit = 'all' end,
},
mode = 'n',
body = '<leader>ve',
heads = {
{ '<C-h>', 'xi<C-v>u25c4<Esc>' }, -- mode = 'i' somehow breaks
{ '<C-j>', 'xi<C-v>u25bc<Esc>' },
{ '<C-k>', 'xi<C-v>u25b2<Esc>' },
{ '<C-l>', 'xi<C-v>u25ba<Esc>' },
{ 'H', '<C-v>h:VBox<CR>' },
{ 'J', '<C-v>j:VBox<CR>' },
{ 'K', '<C-v>k:VBox<CR>' },
{ 'L', '<C-v>l:VBox<CR>' },
{ 'f', ':VBox<CR>', { mode = 'v' } },
{ '<C-c>', nil, { exit = true } },
},
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.