jbyuki / venn.nvim

Draw ASCII diagrams in Neovim
MIT License
967 stars 21 forks source link

better venn drawing via C-hjkl to insert custom ◄▲►▼ #26

Closed matu3ba closed 5 months ago

matu3ba commented 1 year ago

Same as https://github.com/anuvyklack/hydra.nvim/issues/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 } },
  },
}

TODOs:

jbyuki commented 1 year ago

This is nice. If things are not moving from hydra.nvim's side, we could also open a wiki page here to show these different configurations. To be honest, I use venn.nvim very simply so I don't really know but I can imagine other users could benefit from these advanced configurations. We should maybe wait a bit more.

matu3ba commented 5 months ago

@jbyuki Do you think https://github.com/matu3ba/venn.nvim/wiki/Draw-diagrams and https://github.com/matu3ba/venn.nvim/wiki/Move-selection are ok or would you change anything?

jbyuki commented 5 months ago

Thank you for that.

I think it looks good, a small intro could be nice. For someone who is not familiar with it. To make some advertisment for it so to speak. What is the purpose of it, what new functionalities it brings, etc...

We should link in the readme afterwards.

jbyuki commented 5 months ago

Also a link to hydra somewhere for convenience.

matu3ba commented 5 months ago

Closed by #31 in b09c2f36ddf70b498281845109bedcf08a7e0de0.

Thanks for the review and feedback, @jbyuki.