2015-03-24 03:28:32 +00:00
|
|
|
(defvar company-mode-packages '(company))
|
|
|
|
|
|
|
|
;; company-quickhelp from MELPA is not compatible with 24.3 anymore
|
|
|
|
(unless (version< emacs-version "24.4")
|
|
|
|
(push 'company-quickhelp company-mode-packages))
|
2014-11-04 15:11:25 +00:00
|
|
|
|
2014-11-20 01:44:17 +00:00
|
|
|
(defvar company-mode-excluded-packages
|
2014-12-25 07:54:13 +00:00
|
|
|
'(auto-complete ac-ispell tern-auto-complete auto-complete-clang edts)
|
2015-03-22 06:23:12 +00:00
|
|
|
"Packages that use auto-complete that are no longer necessary and might
|
|
|
|
conflict.")
|
2014-11-30 00:56:53 +00:00
|
|
|
|
2014-11-04 15:11:25 +00:00
|
|
|
(defun company-mode/init-company ()
|
|
|
|
(use-package company
|
2015-03-22 06:23:12 +00:00
|
|
|
:defer t
|
|
|
|
:init
|
2014-11-04 15:11:25 +00:00
|
|
|
(progn
|
2015-03-22 06:28:10 +00:00
|
|
|
(setq company-idle-delay 0.5
|
2014-11-04 15:11:25 +00:00
|
|
|
company-minimum-prefix-length 2
|
|
|
|
company-require-match nil
|
|
|
|
company-dabbrev-ignore-case nil
|
|
|
|
company-dabbrev-downcase nil
|
2014-11-07 21:41:23 +00:00
|
|
|
company-tooltip-flip-when-above t
|
2014-11-08 16:27:22 +00:00
|
|
|
company-frontends '(company-pseudo-tooltip-frontend)
|
2014-11-07 21:41:23 +00:00
|
|
|
company-clang-prefix-guesser 'company-mode/more-than-prefix-guesser)
|
2015-03-22 06:23:12 +00:00
|
|
|
(add-hook 'prog-mode-hook 'global-company-mode))
|
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(spacemacs|diminish company-mode " Ⓒ" " C")
|
|
|
|
;; Set the completion key
|
|
|
|
(if company-mode-use-tab-instead-of-enter
|
|
|
|
(progn
|
|
|
|
;; have tab stand in for enter
|
|
|
|
(define-key company-active-map (kbd "TAB") 'company-complete-selection)
|
|
|
|
(define-key company-active-map (kbd "<tab>") 'company-complete-selection)
|
|
|
|
(define-key company-active-map [tab] 'company-complete-selection)
|
|
|
|
;;disable enter
|
|
|
|
(define-key company-active-map [return] nil)
|
|
|
|
(define-key company-active-map (kbd "RET") nil))
|
2015-02-18 11:19:46 +00:00
|
|
|
;; Fix integration of company and yasnippet
|
|
|
|
(define-key company-active-map (kbd "TAB") nil)
|
|
|
|
(define-key company-active-map (kbd "<tab>") nil)
|
2015-03-22 06:23:12 +00:00
|
|
|
(define-key company-active-map [tab] nil))
|
|
|
|
;; key bindings
|
|
|
|
(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-/") 'company-search-candidates)
|
|
|
|
(define-key company-active-map (kbd "C-M-/") 'company-filter-candidates)
|
|
|
|
(define-key company-active-map (kbd "C-d") 'company-show-doc-buffer)
|
|
|
|
;; Nicer looking faces
|
|
|
|
(custom-set-faces
|
|
|
|
'(company-tooltip-common
|
|
|
|
((t (:inherit company-tooltip :weight bold :underline nil))))
|
|
|
|
'(company-tooltip-common-selection
|
|
|
|
((t (:inherit company-tooltip-selection :weight bold :underline nil)))))
|
|
|
|
;; Transformers
|
|
|
|
(defun spacemacs//company-transformer-cancel (candidates)
|
2015-03-23 04:22:27 +00:00
|
|
|
"Cancel completion if prefix is in the list
|
|
|
|
`company-mode-completion-cancel-keywords'"
|
|
|
|
(unless (and (member company-prefix company-mode-completion-cancel-keywords)
|
|
|
|
(not company-mode-use-tab-instead-of-enter))
|
2015-03-22 06:23:12 +00:00
|
|
|
candidates))
|
|
|
|
(setq company-transformers '(spacemacs//company-transformer-cancel
|
|
|
|
company-sort-by-occurrence))
|
|
|
|
;; Backends
|
|
|
|
(setq company-backends
|
|
|
|
(mapcar 'spacemacs/company-backend-with-yas company-backends)))))
|
2015-02-19 04:23:17 +00:00
|
|
|
|
|
|
|
(defun company-mode/init-company-quickhelp ()
|
|
|
|
(use-package company-quickhelp
|
2015-03-22 06:23:12 +00:00
|
|
|
:if (display-graphic-p)
|
|
|
|
:defer t
|
|
|
|
:init (add-hook 'company-mode-hook 'company-quickhelp-mode)))
|