commit 4c8640eee137316a8a3aee8bc7bef3e949b01f83
parent ff49fd385be4694412ea36b45258d7f3e4f9247d
Author: Vincent Demeester <vincent@sbr.pm>
Date: Wed, 8 Apr 2020 11:38:03 +0200
config-compile.el: change company-active-map
- Unbind C-n, C-p and RET
- Bind TAB to complete common or cycle
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Diffstat:
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/tools/emacs/config/config-completion.el b/tools/emacs/config/config-completion.el
@@ -2,6 +2,7 @@
;;; Commentary:
;;; Setup completion framework
;;; Code
+
;; UseMinibuffer
(use-package minibuffer
:unless noninteractive
@@ -210,12 +211,19 @@ Otherwise, use `projectile-switch-to-project'."
:map company-active-map
("C-d" . company-show-doc-buffer)
("C-l" . company-show-location)
- ("C-n" . company-select-next)
- ("C-p" . company-select-previous)
("C-t" . company-select-next)
("C-s" . company-select-previous)
- ("TAB" . company-complete))
+ ("C-<up>" . company-select-next)
+ ("C-<down>" . company-select-previous)
+ ("TAB" . company-complete-common-or-cycle))
:config
+ (defun company-complete-common-or-selected ()
+ "Insert the common part, or if none, complete using selection."
+ (interactive)
+ (when (company-manual-begin)
+ (if (not (equal company-common company-prefix))
+ (company--insert-candidate company-common)
+ (company-complete-selection))))
(setq-default company-idle-delay 0.2
company-selection-wrap-around t
company-minimum-prefix-length 2
@@ -231,7 +239,13 @@ Otherwise, use `projectile-switch-to-project'."
company-gtags
company-etags)
company-dabbrev
- company-keywords)))
+ company-keywords))
+
+ ;; We don't want completion to prevent us from actually navigating the code
+ (define-key company-active-map (kbd "<return>") nil)
+ (define-key company-active-map (kbd "RET") nil)
+ (define-key company-active-map (kbd "C-p") nil)
+ (define-key company-active-map (kbd "C-n") nil))
;; FIXME(vdemeester) Do this in programming-*.el
;; Add company-css to css-mode company-backends