Coder Social home page Coder Social logo

venn.nvim's People

Contributors

diego-rapoport avatar jbyuki avatar joshzcold avatar matu3ba avatar ofirgall avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

venn.nvim's Issues

Feature request: draw box outside selection

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:

  1. Write the text I want to surround with a box. Usually multiple words in multiple lines.
  2. Get back to the first line and the first word of the line.
  3. Move one left.
  4. Move one up.
  5. Start selection.
  6. Find the last line/word.
  7. Move one right.
  8. Move one down.
  9. Toggle venn.

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.

Initialization function from README fails

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.

Clarify proper usage with `cmdheight=0`

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.

How do you invoke :VBox?

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.

Issues when installing using Plug

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)

Newbie issues with configuring

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

Possible mouse support?

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.

Don't change last visual selection

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?

UTF 8 error when drawing line with arrow

Hello!
First off, I absolutely love the plugin, thank you so much for making it.
When I try to draw a line with an arrow terminating in all directions in any filtetype, I see this error.

Screen Shot 2021-10-29 at 12 57 47 PM

I've tried pasting the ▲ ◄─┼─►▼ characters directly, but that does not cause the same issue.

potential ascii diagram design

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).

Unable to toggle venn

E5108: Error executing lua [string ":lua"]:1: attempt to call global 'Toggle_venn' (a nil value)
stack traceback:
        [string ":lua"]:1: in main chunk

Add a shortcut to init a `paper` file

To create a picture there must be a lot of spaces which can be tedious,

Maybe add a shortcut to new a buffer which have whole page of spaces already, then can just start to draw the content.

Like:
image

fix(README): clarify keymaps be configured by user

  1. Calling keymaps needs (as of writing) global lua functions
  2. sumneko lsp suggests capital letters for global functions
  3. Its unclear why _G.function is used. Does it have performance advantages or do you do metatable stuff with those functions?
  4. A sentence that this is suppsed to be configured by the user.

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?

my code
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)

Support crossings

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.

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

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 } },
  },
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.