Lazy-load company-mode

This commit is contained in:
Henrik Lissner 2016-06-04 22:31:01 -04:00
parent 92482309fc
commit e21607f567
3 changed files with 18 additions and 8 deletions

View file

@ -1,6 +1,8 @@
;;; core-company.el ;;; core-company.el
(use-package company (use-package company
:commands (company-mode global-company-mode company-complete
company-complete-common company-manual-begin company-grab-line)
:init :init
(setq company-idle-delay nil (setq company-idle-delay nil
company-minimum-prefix-length 2 company-minimum-prefix-length 2
@ -12,18 +14,23 @@
company-require-match 'never company-require-match 'never
company-global-modes '(not eshell-mode comint-mode erc-mode message-mode help-mode) company-global-modes '(not eshell-mode comint-mode erc-mode message-mode help-mode)
company-frontends '(company-pseudo-tooltip-frontend company-echo-metadata-frontend) company-frontends '(company-pseudo-tooltip-frontend company-echo-metadata-frontend)
company-backends '((company-capf company-keywords)) company-backends '(company-capf company-yasnippet)
company-quickhelp-delay nil company-quickhelp-delay nil
company-statistics-file (concat doom-temp-dir "/company-stats-cache.el")) company-statistics-file (concat doom-temp-dir "/company-stats-cache.el"))
:config :config
(require 'company-capf)
(require 'company-yasnippet)
;; Rewrites evil-complete to use company-dabbrev ;; Rewrites evil-complete to use company-dabbrev
(setq evil-complete-next-func 'doom/company-evil-complete-next (setq evil-complete-next-func 'doom/company-evil-complete-next
evil-complete-previous-func 'doom/company-evil-complete-previous) evil-complete-previous-func 'doom/company-evil-complete-previous)
(push 'company-sort-by-occurrence company-transformers) (push 'company-sort-by-occurrence company-transformers)
(global-company-mode +1) (define-key company-active-map "\C-w" nil)
(define-key company-active-map "\C-w" nil))
(global-company-mode +1))
;; NOTE: Doesn't look pretty outside of emacs-mac ;; NOTE: Doesn't look pretty outside of emacs-mac
(use-package company-quickhelp (use-package company-quickhelp
@ -35,11 +42,11 @@
:config (company-statistics-mode +1)) :config (company-statistics-mode +1))
(use-package company-dabbrev :commands company-dabbrev) (use-package company-dabbrev :commands company-dabbrev)
(use-package company-dabbrev-code :commands company-dabbrev-code) (use-package company-dabbrev-code :commands company-dabbrev-code)
(use-package company-etags :commands company-etags)
(use-package company-files (use-package company-files :commands company-files)
:commands company-files) (use-package company-gtags :commands company-gtags)
(use-package company-ispell :commands company-ispell)
(use-package company-dict (use-package company-dict
:commands company-dict :commands company-dict

View file

@ -54,7 +54,9 @@
(defun doom/company-complete () (defun doom/company-complete ()
"Bring up the completion popup. If there is only one result, auto-complete it." "Bring up the completion popup. If there is only one result, auto-complete it."
(interactive) (interactive)
(when (and (company-manual-begin) (require 'company)
(when (and (bound-and-true-p company-mode)
(company-manual-begin)
(= company-candidates-length 1)) (= company-candidates-length 1))
(company-complete-common))) (company-complete-common)))

View file

@ -10,6 +10,7 @@
(quoted (eq (car-safe backends) 'quote))) (quoted (eq (car-safe backends) 'quote)))
`(progn `(progn
(defun ,def-name () (defun ,def-name ()
(require 'company)
(set (make-local-variable 'company-backends) (set (make-local-variable 'company-backends)
(append '((,@(mapcar (lambda (backend) (append '((,@(mapcar (lambda (backend)
(if quoted (if quoted