This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
spacemacs/contrib/company-mode/packages.el

73 lines
3.2 KiB
EmacsLisp
Raw Normal View History

(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
(defvar company-mode-excluded-packages
'(auto-complete ac-ispell tern-auto-complete auto-complete-clang edts)
"Packages that use auto-complete that are no longer necessary and might
conflict.")
2014-11-04 15:11:25 +00:00
(defun company-mode/init-company ()
(use-package company
:defer t
:init
2014-11-04 15:11:25 +00:00
(progn
(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
company-tooltip-flip-when-above t
2014-11-08 16:27:22 +00:00
company-frontends '(company-pseudo-tooltip-frontend)
company-clang-prefix-guesser 'company-mode/more-than-prefix-guesser)
(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))
;; Fix integration of company and yasnippet
(define-key company-active-map (kbd "TAB") nil)
(define-key company-active-map (kbd "<tab>") nil)
(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))
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
:if (display-graphic-p)
:defer t
:init (add-hook 'company-mode-hook 'company-quickhelp-mode)))