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

Do not set the default mapping for normal mode #15

Closed
jdhao opened this issue Apr 16, 2019 · 6 comments
Closed

Do not set the default mapping for normal mode #15

jdhao opened this issue Apr 16, 2019 · 6 comments

Comments

@jdhao
Copy link

jdhao commented Apr 16, 2019

I have used ,f for other mapping in normal mode. This plugin should check if the mapping key has been used before setting the default mappings for normal mode.

@alerque
Copy link
Member

alerque commented Apr 16, 2019

The plugin checks whether there is already a mapping to the function it wants to map. The way to work around this is to assign a mapping to the two footnote related commands. The plugin will then not touch the default <leader>f. For example in my init.vim file I have:

nmap <Leader>^ <Plug>AddVimFootnote

Adding a custom binding like this will suppress the default one.

@jdhao
Copy link
Author

jdhao commented Apr 16, 2019

The issue is that I do not really need the two normal mode mappings since I usually insert footnote in insert mode instead of normal mode.

@alerque
Copy link
Member

alerque commented Apr 16, 2019

As a work around setup a normal mode binding anyway to some throw away key you don't use. I'll leave this issue open until we figure out a way to suppress the bindings altogether.

@alerque
Copy link
Member

alerque commented Apr 16, 2019

This was fixed as of 7eb62d2, mappings are no longer added if the user has an existing mapping on the default key.

Note the warned-of repository rebase also just happened, so in order to update your plugin you might need to either remove and re-install it or manually git pull --rebase origin/master.

@jdhao
Copy link
Author

jdhao commented Apr 16, 2019

A minor issue.

In normal mode, ,f and ,r are kind of paired. If ,f has been mapped to other operations, there is no meaning to define a ,r normal mode map for Return From footnote.

The logic should be: if ,f has been mapped to <Plug>ReturnFromFootnote, then we may map the ,r sequence to <Plug>ReturnFromFootnote if ,r has no prior mapping.

@alerque
Copy link
Member

alerque commented Apr 16, 2019

@jdhao That would not cover the case of the user having setup a custom map for the first but wanting to use the default binding for the second. It already handles the case of not adding an extra mapping if the user has a custom one.

If you start trying to cover all possible cases then things get really complex and I'm not sure it's worth the confusion. This is why some plugins just brute force this and either force all their default mappings (even if they clobber others) or had a flag to set no bindings at all (leaving the user to map everything).

I think the present config makes some sense and I'm not really worried about the extra return binding getting set in the event of a clobber + no custom bindings. That can be left as an exercise for the user. Besides we're talking about overhauling bindings anyway, see #17.

derdennis pushed a commit to derdennis/vim-markdownfootnotes that referenced this issue Apr 18, 2019
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