auto-completion: support emacs style for navigation in company

This commit is contained in:
syl20bnr 2016-04-21 21:29:20 -04:00
parent da8b0294c5
commit 667a7f61a4
2 changed files with 40 additions and 13 deletions

View File

@ -177,11 +177,25 @@ Here is an example to add =company= auto-completion to python buffer:
| Key Binding | Description |
|-------------+--------------------------------------------------------------------------|
| ~C-j~ | go down in company dropdown menu |
| ~C-k~ | go up in company dropdown menu |
| ~C-d~ | open minibuffer with documentation of thing at point in company dropdown |
| ~C-/~ | show candidates in Helm (for fuzzy searching) |
| ~C-M-/~ | filter the company dropdown menu |
| ~C-d~ | open minibuffer with documentation of thing at point in company dropdown |
Vim Style:
| Key Binding | Description |
|-------------+--------------------------------------------------------------------------|
| ~C-j~ | (vim style) go down in company dropdown menu |
| ~C-k~ | (vim style) go up in company dropdown menu |
| ~C-l~ | (vim style) complete selection |
Emacs style:
| Key Binding | Description |
|-------------+--------------------------------------------------------------------------|
| ~C-f~ | (emacs style) complete selection |
| ~C-n~ | (emacs style) go down in company dropdown menu |
| ~C-p~ | (emacs style) go up in company dropdown menu |
** Auto-complete

View File

@ -103,16 +103,29 @@
(spacemacs//auto-completion-set-RET-key-behavior 'company)
(spacemacs//auto-completion-set-TAB-key-behavior 'company)
(spacemacs//auto-completion-setup-key-sequence 'company)
(when (or (eq 'vim dotspacemacs-editing-style)
(and (eq 'hybrid dotspacemacs-editing-style)
hybrid-mode-enable-hjkl-bindings))
(let ((map company-active-map))
(define-key map (kbd "C-/") 'company-search-candidates)
(define-key map (kbd "C-M-/") 'company-filter-candidates)
(define-key map (kbd "C-d") 'company-show-doc-buffer)
(define-key map (kbd "C-j") 'company-select-next)
(define-key map (kbd "C-k") 'company-select-previous)
(define-key map (kbd "C-l") 'company-complete-selection)))
(let ((map company-active-map))
(define-key map (kbd "C-/") 'company-search-candidates)
(define-key map (kbd "C-M-/") 'company-filter-candidates)
(define-key map (kbd "C-d") 'company-show-doc-buffer))
(defun spacemacs//company-active-navigation (style)
"Set navigation for the given editing STYLE."
(cond
((or (eq 'vim style)
(and (eq 'hybrid style)
hybrid-mode-enable-hjkl-bindings))
(let ((map company-active-map))
(define-key map (kbd "C-j") 'company-select-next)
(define-key map (kbd "C-k") 'company-select-previous)
(define-key map (kbd "C-l") 'company-complete-selection)))
(t
(let ((map company-active-map))
(define-key map (kbd "C-n") 'company-select-next)
(define-key map (kbd "C-p") 'company-select-previous)
(define-key map (kbd "C-f") 'company-complete-selection)))))
(add-hook 'spacemacs-editing-style-hook 'spacemacs//company-active-navigation)
;; Nicer looking faces
(custom-set-faces
'(company-tooltip-common