/
init-company.el
59 lines (48 loc) · 2.6 KB
/
init-company.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
;; From https://github.com/purcell/emacs.d/blob/master/lisp/init-company.el
;; WAITING: haskell-mode sets tags-table-list globally, breaks tags-completion-at-point-function
;; TODO Default sort order should place [a-z] before punctuation
(setq tab-always-indent 'complete) ;; use 't when company is disabled
(add-to-list 'completion-styles 'initials t)
;; Stop completion-at-point from popping up completion buffers so eagerly
(setq completion-cycle-threshold 5)
(when (maybe-require-package 'company)
(add-hook 'after-init-hook 'global-company-mode)
(after-load 'company
(diminish 'company-mode "CMP")
(define-key company-mode-map (kbd "M-/") 'company-complete)
(define-key company-active-map (kbd "M-/") 'company-select-next)
(setq-default company-backends '((company-capf company-dabbrev-code) company-dabbrev)))
(global-set-key (kbd "M-C-/") 'company-complete)
(when (maybe-require-package 'company-quickhelp)
(add-hook 'after-init-hook 'company-quickhelp-mode))
(defun sanityinc/local-push-company-backend (backend)
"Add BACKEND to a buffer-local version of `company-backends'."
(set (make-local-variable 'company-backends)
(append (list backend) company-backends))))
;; Suspend page-break-lines-mode while company menu is active
;; (see https://github.com/company-mode/company-mode/issues/416)
(after-load 'company
(after-load 'page-break-lines-mode
(defvar sanityinc/page-break-lines-on-p nil)
(make-variable-buffer-local 'sanityinc/page-break-lines-on-p)
(defun sanityinc/page-break-lines-disable (&rest ignore)
(when (setq sanityinc/page-break-lines-on-p (bound-and-true-p page-break-lines-mode))
(page-break-lines-mode -1)))
(defun sanityinc/page-break-lines-maybe-reenable (&rest ignore)
(when sanityinc/page-break-lines-on-p
(page-break-lines-mode 1)))
(company-statistics-mode)
(setq company-statistics-size 40000)
;; can't work with TRAMP
(setq company-backends (delete 'company-ropemacs company-backends))
;; I don't like the downcase word in company-dabbrev
;; for languages use camel case naming convention
(setq company-dabbrev-downcase nil)
(setq company-show-numbers t)
(setq company-begin-commands '(self-insert-command))
(setq company-idle-delay 0.2)
; (setq company-clang-insert-arguments nil)
(add-hook 'company-completion-started-hook 'sanityinc/page-break-lines-disable)
(add-hook 'company-completion-finished-hook 'sanityinc/page-break-lines-maybe-reenable)
(add-hook 'company-completion-cancelled-hook 'sanityinc/page-break-lines-maybe-reenable)))
(provide 'init-company)