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

noremap bindings not working #18

Closed
metakirby5 opened this issue Sep 17, 2016 · 3 comments
Closed

noremap bindings not working #18

metakirby5 opened this issue Sep 17, 2016 · 3 comments

Comments

@metakirby5
Copy link
Contributor

I've gotten into the habit of using noremap for a lot of my keybindings, but this doesn't work with vim-leader-guide.

Minimal .vimrc to reproduce the problem, assuming vim-plug is installed:

call plug#begin('~/.vim/plugins')
  Plug 'hecal3/vim-leader-guide'
call plug#end()

let g:lgmap = {}
call leaderGuide#register_prefix_descriptions('', 'g:lgmap')
nnoremap <silent> [ :<c-u>LeaderGuide '['<CR>
vnoremap <silent> [ :<c-u>LeaderGuideVisual '['<CR>

nnoremap ; :
nnoremap : ;
nnoremap <silent> [e <esc>:echo "hello world"<cr>

Steps to reproduce problem:

  1. Run vim
  2. Quickly type [e and observe that hello world is echoed
  3. Type [ and wait for the leader guide to show up
  4. Type w and observe that the mapping was fed with remapping, thus putting o "hello world" into the buffer

I've done some investigating on my own, and found that if the feedkeys flags are changed to "nt" on this line, this case works as expected, but breaks non-noremapped mappings. I think the solution here is to dynamically set the flags in response to the key's entry in :map, since noremapped mappings will have an asterisk between the key and the mapping. However, I don't know the code well enough to fix this issue myself. If you don't have the spare time on your hands, I'd be more than happy to fix the issue. Just give me a few pointers on where to make my changes :)

hecal3 added a commit that referenced this issue Sep 17, 2016
hecal3 added a commit that referenced this issue Sep 17, 2016
@hecal3
Copy link
Owner

hecal3 commented Sep 17, 2016

Thanks for hunting that down.

I made the changes you suggested on the noremap branch. As far as I can tell the issue is fixed but I will do some additional testing. (I vaguely remember there was a reason I set the flag to "mt")

The mapping information is read with maparg() by the way. One of the fields in the result dictionary is noremap. It indicates if a mapping is remapped or not. I used to parse the :map output, but using maparg() is much cleaner and easier. This dictionary is now passed to the feedkeys part and the flag is set accordingly.

@metakirby5
Copy link
Contributor Author

Excellent! I'll give it a go later today. Thank you for taking action so quickly :D

Also, thanks for the information about maparg()! I was facing a few issues with <Plug> mappings (specifically with git-gutter things bound to <leader>g<key>), but I haven't found a good minimal configuration to reproduce the issue. I'll take a closer look later and either PR or file an issue.

@metakirby5
Copy link
Contributor Author

These changes resolve the issue! 👍

@hecal3 hecal3 closed this as completed in bade1b9 Sep 18, 2016
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