2014-11-04 15:11:25 +00:00
|
|
|
(defvar company-mode-packages
|
|
|
|
'(
|
|
|
|
company
|
|
|
|
company-tern
|
2014-12-16 08:42:51 +00:00
|
|
|
company-c-headers
|
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)
|
2014-11-20 01:44:17 +00:00
|
|
|
"Packages that use auto-complete that are no longer necessary and might conflict.")
|
|
|
|
|
2014-11-28 03:05:06 +00:00
|
|
|
(defvar company-mode/completion-cancel-keywords '("do" "then" "begin" "case")
|
|
|
|
"Keywords on which to cancel completion so that you can use RET to complet without blocking common line endings.")
|
|
|
|
|
2014-11-30 00:56:53 +00:00
|
|
|
(defvar company-mode/enable-yas t
|
|
|
|
"Enable yasnippet for all backends.")
|
|
|
|
|
|
|
|
(defun company-mode/backend-with-yas (backend)
|
|
|
|
(if (or (not company-mode/enable-yas) (and (listp backend) (member 'company-yasnippet backend)))
|
|
|
|
backend
|
|
|
|
(append (if (consp backend) backend (list backend))
|
|
|
|
'(:with company-yasnippet))))
|
|
|
|
|
2014-11-04 15:11:25 +00:00
|
|
|
(defun company-mode/init-company ()
|
|
|
|
(use-package company
|
|
|
|
:config
|
|
|
|
(progn
|
2014-11-28 03:05:06 +00:00
|
|
|
(defun company-mode/keyword-cancel-transformer (candidates)
|
|
|
|
"company frontend that cancels completion when a keyword is typed
|
|
|
|
so that you don't have 'do' completed to 'downcase' in Ruby"
|
|
|
|
(if (member company-prefix company-mode/completion-cancel-keywords) '() candidates))
|
|
|
|
|
2014-11-04 15:11:25 +00:00
|
|
|
(setq company-idle-delay 0.0
|
|
|
|
company-minimum-prefix-length 2
|
|
|
|
company-require-match nil
|
2014-11-28 03:05:06 +00:00
|
|
|
company-transformers '(company-mode/keyword-cancel-transformer company-sort-by-occurrence)
|
2014-11-04 15:11:25 +00:00
|
|
|
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)
|
2014-11-04 15:11:25 +00:00
|
|
|
|
|
|
|
(global-company-mode 1)
|
|
|
|
|
2014-11-28 03:05:06 +00:00
|
|
|
;; Fix integration of company and yasnippet
|
2014-11-04 15:11:25 +00:00
|
|
|
(define-key company-active-map (kbd "TAB") nil)
|
|
|
|
(define-key company-active-map (kbd "<tab>") nil)
|
|
|
|
(define-key company-active-map [tab] nil)
|
|
|
|
|
2014-11-08 17:21:27 +00:00
|
|
|
(add-hook 'markdown-mode-hook '(lambda () (company-mode -1)))
|
|
|
|
|
2014-11-28 03:05:06 +00:00
|
|
|
;; The default common face is a really ugly underlined thing with a different background.
|
2014-11-08 17:21:27 +00:00
|
|
|
(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)))))
|
|
|
|
|
2014-11-30 00:56:53 +00:00
|
|
|
(setq company-backends (mapcar #'company-mode/backend-with-yas company-backends))
|
|
|
|
|
2014-12-23 21:39:57 +00:00
|
|
|
(spacemacs|diminish company-mode " Ⓒ" " C"))))
|
2014-11-04 15:11:25 +00:00
|
|
|
|
2014-12-22 02:29:10 +00:00
|
|
|
(defun company-mode/init-company-c-headers ()
|
|
|
|
(use-package company-c-headers
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(add-to-list 'company-backends 'company-c-headers)))
|
|
|
|
|
2014-11-04 15:11:25 +00:00
|
|
|
(defun company-mode/init-company-tern ()
|
2014-11-28 03:05:06 +00:00
|
|
|
(use-package company-tern
|
|
|
|
:defer t
|
2014-11-30 00:56:53 +00:00
|
|
|
:init
|
|
|
|
(add-to-list 'company-backends (company-mode/backend-with-yas 'company-tern))))
|