davidgranstrom / scnvim

Neovim frontend for SuperCollider.
GNU General Public License v3.0
197 stars 26 forks source link

[FR]: Return to Normal mode after evaluating a Visual mode block #201

Closed vsandstrom closed 1 year ago

vsandstrom commented 1 year ago

Is your feature request related to a problem? Please describe.

I have the habit of evaluating code using Visual mode a lot, debugging and trying chunks of code inside a scope.

In previous "non-lua" scnvim the cursor always returned to normal mode after that action.

Describe the solution you'd like

To make a visual send mapping perhaps, or to make it default to return to normal mode.

Describe alternatives you've considered

I tried adding an if-clause at the end of the in the editor.lua file in the "send_selection"-function, checking if visual mode. Inside was a command that should do an \ button press.

Additional context

I have not seen a keymapping config of scnvim where something is mapped to 'v', is this the correct way to map a visual binding?

davidgranstrom commented 1 year ago

@vsandstrom I think this might do the trick:

local map = scnvim.map

map(function()
  require'scnvim.editor'.send_selection()
  vim.cmd([[exe "normal! \<Esc>"]])
end, 'x')
vsandstrom commented 1 year ago

Thanks! works great. I tried to add the vim.cmd line to the send_selection function, should not hurt to explicitly return to normal after a block eval. Thanks!