-
Notifications
You must be signed in to change notification settings - Fork 33
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
company-active-map not fully working when company-quickhelp-mode is active #17
Comments
There's nothing I can do about this. Evil is quite aggressive in making sure it's keybindings have top priority. I suggest you move your keybindings into one of evil's own keymaps where they won't get shadowed. If that's not possible, or if you don't want to solve your problem that way, I suggest you open a ticket in the evil repo to figure out why evil-mode is shadowing the keybindings in this situation. |
For now I'll go with rebinding then. You can get around the issue if you make the proper keybinds and put them into |
Expanding on the previous solution (since I never found an answer that laid it out explicitly), I used code like the following to make this work: (add-hook 'company-completion-started-hook 'ans/set-company-maps)
(add-hook 'company-completion-finished-hook 'ans/unset-company-maps)
(add-hook 'company-completion-cancelled-hook 'ans/unset-company-maps)
(defun ans/unset-company-maps (&rest unused)
"Set default mappings (outside of company).
Arguments (UNUSED) are ignored."
(general-def
:states 'insert
:keymaps 'override
"C-n" nil
"C-p" nil
"C-l" nil))
(defun ans/set-company-maps (&rest unused)
"Set maps for when you're inside company completion.
Arguments (UNUSED) are ignored."
(general-def
:states 'insert
:keymaps 'override
"C-n" 'company-select-next
"C-p" 'company-select-previous
"C-l" 'ans-company-complete-continue)) This uses general.el for key definitions, but any key definition command should work. To me, this issue seems similar to #63. |
building on ashiklom's solution, here's a block of code which'll let you specify the bindings only once. (let* ((bindings '("C-j" company-select-next
"C-k" company-select-previous))
(unset-bindings (mapcar (lambda (value)
(if (stringp value)
value
nil))
bindings)))
(defun custom/unset-company-bindings (&rest args)
(apply 'general-define-key
:keymaps 'override
:states 'insert
unset-bindings))
(defun custom/set-company-bindings (&rest args)
(apply 'general-define-key
:keymaps 'override
:states 'insert
bindings)))
(add-hook 'company-completion-started-hook 'custom/set-company-bindings)
(add-hook 'company-completion-finished-hook 'custom/unset-company-bindings)
(add-hook 'company-completion-cancelled-hook 'custom/unset-company-bindings) |
Got the idea for the fix from this comment: company-mode/company-quickhelp#17 (comment) I simplified it to only un/define C-k, since C-j worked without the fix.
Got the idea for the fix from this comment: company-mode/company-quickhelp#17 (comment) I simplified it to only un/define C-k, since C-j worked without the fix.
Got the idea for the fix from this comment: company-mode/company-quickhelp#17 (comment) I simplified it to only un/define C-k, since C-j worked without the fix.
Got the idea for the fix from this comment: company-mode/company-quickhelp#17 (comment) I simplified it to only un/define C-k, since C-j worked without the fix.
Got the idea for the fix from this comment: company-mode/company-quickhelp#17 (comment) I simplified it to only un/define C-k, since C-j worked without the fix.
Got the idea for the fix from this comment: company-mode/company-quickhelp#17 (comment) I simplified it to only un/define C-k, since C-j worked without the fix.
Got the idea for the fix from this comment: company-mode/company-quickhelp#17 (comment) I simplified it to only un/define C-k, since C-j worked without the fix.
Slightly cleaner impl from a closer-to the source issue: company-mode/company-quickhelp#17
I have a few custom keybinds I use for company mode:
(define-key company-active-map (kbd "C-j") 'company-select-next)
(define-key company-active-map (kbd "C-k") 'company-select-previous)
(define-key company-active-map (kbd "C-ü") 'helm-company)
(define-key company-active-map (kbd "<tab>") 'company-complete-common-or-cycle)
If I activate
company-quickhelp-mode
the first two keybindings will no longer work andinstead execute their globally bound (evil-mode) actions instead. The latter two keybinds
continue working as inteded. I also tried using
C-w
,C-s
andJ
,K
as well.The former was equally broken while the latter was working properly.
This issue only appeas if
company-quickhelp-mode
is active and the popup was visible. I'm able to useC-j
andC-k
to cycle though the completion candidates if no popup has yet appeared.I'm using company version 0.9.0-cvs and the newest company-quickhelp installed from github via el-get.
The text was updated successfully, but these errors were encountered: