Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to disable shortcuts? #87

Open
DanielLoney opened this issue Jul 6, 2021 · 2 comments
Open

How to disable shortcuts? #87

DanielLoney opened this issue Jul 6, 2021 · 2 comments

Comments

@DanielLoney
Copy link

I tried doing let ropevim_enable_shortcuts=0 in my vimrc but the shortcuts are still being bound. How would I properly disable all shortcuts?

@eivindjahren
Copy link
Contributor

eivindjahren commented Jul 16, 2022

I also tried this with both let ropevim_enable_shortcuts=0 and let g:ropevim_enable_shortcuts=0 and it seems to create the shortcuts in both cases. The switch to set the shortcuts is done here:

ropevim/ropevim.py

Lines 520 to 521 in 55fe3e2

def _enable_shortcuts(env):
if env.get('enable_shortcuts'):

and env.get does the magic of testing for existence and prepending g:ropevim_:

ropevim/ropevim.py

Lines 88 to 95 in 55fe3e2

def get(self, name, default=None):
vimname = 'g:ropevim_%s' % name
if str(vim.eval('exists("%s")' % vimname)) == '0':
return default
result = vim.eval(vimname)
if isinstance(result, str) and result.isdigit():
return int(result)
return result

It seems that env.get("enable_shortcuts") returns 0 and the noremap commands never executed, but the shortcuts are still available.

@eivindjahren
Copy link
Contributor

eivindjahren commented Jul 17, 2022

Ah, I see now that the problem is that add_command does not respect enable_shortcuts.

ropevim/ropevim.py

Lines 325 to 331 in 55fe3e2

def _add_command(self, name, callback, key, prefix, prekey):
self._add_function(name, callback, prefix)
vim.command('command! -range %s call %s()' %
(_vim_name(name), _vim_name(name)))
if key is not None:
key = prekey + key.replace(' ', '')
vim.command('noremap %s :call %s()<cr>' % (key, _vim_name(name)))

This is as per the documentation, but it is subtle and not what the user expects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants