dstein64 / nvim-scrollview

A Neovim plugin that displays interactive vertical scrollbars and signs.
MIT License
546 stars 10 forks source link

[question] disabling keybinds #107

Closed ghost closed 1 year ago

ghost commented 1 year ago

hi! this is my favorite scrollbar plugin, however ive got a really annoying issue

i use z in some of my keymaps i.e. to go to the start of the line

however scrollview uses MANY z bindings and ive got no clue how to

1: either remove scrollview binds all together 2: or disable any keybind beginning with z and then setting my own z binds

please help as this is gonna be keeping me from using scrollview, which would be a shame just because of one keybinding

dstein64 commented 1 year ago

Hi @qube-03, I assume you're referring to the following lines in your Neovim config:

https://github.com/qube-03/configs/blob/80daf4aa860d7cb0f3fa0d4de9d0edb0402ed877/.config/nvim/lua/keybinds.lua#L22-L24

nvim-scrollview has a bunch of builtin mappings for key sequences beginning with z, so that scrollbars and signs are refreshed after commands that modify folds.

<nowait> can be used for your mappings to prevent the delay when you press z (see :help :map-Nowait>), effectively disabling the scrollview mappings that are causing the issue for you. For example, kset('n', 'z', '<Home>') from your config would become kset('n', 'z', '<Home>', {nowait = true}).

dstein64 commented 1 year ago

I've updated the code in d2a9d1538741752642bb76ba1274e89d6213e69d so that a key sequence mapping will not be created if one already exists for a prefix of the sequence.

ghost commented 1 year ago

hey, thanks for the kind response

ive tried the nowait thing but until now have had little luck, ill see if i had any errors and will try again, thanks for the example too

(the config in question is wayyy outdated btw, but the same still applies)

ghost commented 1 year ago

just tried the nowait option exactly as you specified, no luck (tried with m this time)

it doesnt matter now though, i changed my binds so it works now

thanks for your efforts!

dstein64 commented 1 year ago

Glad to hear the problem is worked around.

Please let me know if you have any ideas for what the issue is or any steps I can use to reproduce. If I execute the following line, either in a Neovim config file or after starting Neovim, z works as expected (effectively working like <home> in normal mode, with no delay).

lua vim.keymap.set('n', 'z', '<Home>', {nowait = true})
ghost commented 1 year ago

yes it does do that, on the previous version from before this issue though, scrollview would have many bindings with z and so it would delay the actual input, not even { nowait = true } helped then

sadly enough another keybinding i used is m and ive rebound that now to not interfere with scrollview

ghost commented 1 year ago

so from what i can tell, the issue with keybindings interfering still persist, because it didnt detect that i also had m bound,

could be a misconfiguration on my end though

kohane27 commented 1 year ago

I have the same issue:

Error detected while processing function <lambda>120[1]..script /home/username/.local/share/nvim/lazy/nvim-scrollview/autoload/scrollview.vim:
line  507:
E227: mapping already exists for mj
Press ENTER or type command to continue
vim/keymap.lua:0: E227: mapping already exists for mj
Press ENTER or type command to continue
stack traceback:
Press ENTER or type command to continue
^I[C]: in function 'nvim_set_keymap'
Press ENTER or type command to continue
^Ivim/keymap.lua: in function 'set'
Press ENTER or type command to continue
^I...nvim/lazy/nvim-scrollview/lua/scrollview/signs/marks.lua:48: in function <...nvim/lazy/nvim-scrollview/lua/scrollview/signs/marks.lua:15>

I have bound mj as a keybinding and scrollview complains. Any workaround? Thank you!

adrian5 commented 1 year ago

Same here (mg in my case), I'd like to disable any keymap creation by nvim-scrollview, as I don't manually toggle anything when using it.

dstein64 commented 1 year ago

I've re-opened this ticket. I think 01373406b2c83110b24c6759e0b24bd43d194b33 should fix the bug. Is the issue still present after that commit?

adrian5 commented 1 year ago

For me that fixes it. I re-enabled my mg mapping and no more error messages appear. Thanks @dstein64, love how seamless this plugin works, aside from this small hiccup!

dstein64 commented 1 year ago

Glad to hear it's fixed. I'll close this issue for now and re-open if anyone is still having the problem.

kohane27 commented 1 year ago

The latest commit also fixed it for me too. Thank you for your prompt resolution. I appreciate it:)

ghost commented 1 year ago

im not home rn so i cant comment on anything really but thanks a lot for your commitment! ill be happy once i get home

evmorov commented 1 year ago

md doesn't work in Nerdtree now. When I write :map md I get:

n  m           *@:call nerdtree#ui_glue#invokeKeyMap("m")<CR>
x  md          * md<Cmd>ScrollViewRefresh<CR>
n  md          * md<Cmd>ScrollViewRefresh<CR>

How can I turn off nvim-scrollview for md?

dstein64 commented 1 year ago

Thanks for letting me know @evmorov. I'll open a separate issue.

Until a proper fix is implemented, the following workaround can be used (but this will disable signs for marks). These lines would have to be executed before the plugin is loaded (e.g., from a Neovim config file).

VimScript

let g:scrollview_marks_characters = []

Lua

-- Lua method 1: setup() function
require('scrollview').setup({
  ...
  marks_characters = {},
  ...
})

-- Lua method 2: config variable
vim.g.scrollview_marks_characters = {}
evmorov commented 1 year ago

Thanks @dstein64! I confirm that the temporal solution works.

adrian5 commented 1 year ago

md doesn't work in Nerdtree now.

@evmorov Offtopic, but I recommend taking a look at neo-tree as an nvim-native replacement. NerdTree has been on life-support for a long time now.

ghost commented 1 year ago

ima hop in on this one too, even if offtopic

if you dont like neotree then take a look at oil.nvim

its improved my workflow drastically over using a traditional sidebar tree