Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

fix: avoid overwrting user defined mapping #154

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

haorenW1025
Copy link
Collaborator

I get called out on stream...so I must fix this 😢
Right now completion-nvim will prompt you to change your g:completion_confirm_key if you already have some mapping on <CR> and won't overwrite it.

Some notes here: There is no api to get a specific mapping. I used nvim_buf_get_keymap and nvim_get_keymap to get a full list of mapping then iterate then to check if there's conflicting mapping, which I think is not that smart... I wonder if there's a better way to do it.

cc @kdheepak @tjdevries

fixes #153

fix some stuff

fix

not show error on old mapping
@haorenW1025 haorenW1025 force-pushed the fix_overwriting_mapping branch from 432963d to e5f3a3b Compare July 28, 2020 07:37
@tjdevries
Copy link
Member

Hmmm, it would probably be good to add an API around seeing if there exists any keymap for a particular key.... we do not have it yet though 😆

I wouldn't be worried about the performance, luajit would probably be fast enough. You could always just disable it on default? I'm not sure. The surprising thing was that <CR> was mapped by default for me when installing this (and I don't use it).

Perhaps just making it not a default anything would be better? (Sorry, I don't have a great solution nor understand 100% what's happening)

@parmort
Copy link

parmort commented Sep 10, 2020

You could try to chain the functionality onto the confirmation key. That makes for a more seamless user experience (and it's what tpope does)

@taylan97
Copy link

taylan97 commented Oct 25, 2020

Doh. I checked issues, but did not see this pull request.

I have suffered from this today, #255, with a similar fix: taylan97#1

Seems it's kind of old and no conflict, any reason to not merge?

I do kind of wonder if it's required for completion to set the binding and not just delegate that to the user configuration? I get that it has a custom function you have to call, I don't think it can just hook into whatever normal vim "confirm completion" stuff.

If you do have to set it in the actual plugin, I think a less intrusive option would be vim's default completion accept combo, over CR, people who want CR can use the confirm_key option.

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

Successfully merging this pull request may close these issues.

Functions mapped should respect user mappings
4 participants