jbyuki / venn.nvim

Draw ASCII diagrams in Neovim
MIT License
919 stars 20 forks source link

fix(README): clarify keymaps be configured by user #9

Closed matu3ba closed 2 years ago

matu3ba commented 2 years ago
  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", "j:VBox", {noremap = true}) vim.api.nvim_buf_set_keymap(0, "n", "K", "k:VBox", {noremap = true}) vim.api.nvim_buf_set_keymap(0, "n", "L", "l:VBox", {noremap = true}) vim.api.nvim_buf_set_keymap(0, "n", "H", "h:VBox", {noremap = true}) -- draw a box by pressing "f" with visual selection vim.api.nvim_buf_set_keymap(0, "v", "f", ":VBox", {noremap = true}) else vim.cmd[[setlocal ve=]] vim.cmd[[mapclear ]] vim.b.venn_enabled = nil end end map('n', 'v', ":lua Toggle_venn()", opts) ```
jbyuki commented 2 years ago
  1. Correct
  2. Sure, let's rename it.
  3. Lua functions are global by default. _G makes it explicit. See here, they use the same convention. There are functionally equivalent.
  4. Sure, let's add it. Any help is welcome really.

Meta: Are you referring to one-small-step-for-vimkind? You can find something here If you want a commented video, I have no plans to really make one, osv is really niche in my opinion.

Meta2: I've never used nvim-luadev. You can use the REPL inside nvim-dap theorically. Although I never use it. With osv, it's possible, but assignements don't work. Usually writing in a file and using luafile % is the best for me. Personnally, I use my other plugin dash.nvim, which ensures me that my neovim does not freeze in case of a lua infinite loop. I would suggest to build your own setup for executing lua because it's so common if you do neovim lua development.