-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsetup-company.el
64 lines (49 loc) · 2.01 KB
/
setup-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
60
61
62
63
64
;;; Company mode - intelligent completion
;;; https://github.com/company-mode/company-mode
(require-package 'company)
(defun bw/company-complete-lambda (arg)
"Ignores passed in arg like a lambda and runs company-complete"
(company-complete))
(defun bw/enable-company-mode ()
"Enables company-mode"
(company-mode 1)
;; Make sure emacs does the right thing with completion command
(define-key (current-local-map) [remap hippie-expand] 'company-complete))
;; shorten company lighter
(setq company-default-lighter " com")
(after-load 'company
(add-hook 'prog-mode-hook 'bw/enable-company-mode)
(add-hook 'enh-ruby-mode-hook 'bw/enable-company-mode)
(setq
;; never start auto-completion unless I ask for it
company-idle-delay nil
;; autocomplete right after '.'
company-minimum-prefix-length 0
;; remove echo delay
company-echo-delay 0
;; don't complete in certain modes
company-global-modes '(not git-commit-mode)
;; make sure evil uses the right completion functions
evil-complete-next-func 'bw/company-complete-lambda
evil-complete-previous-func 'bw/company-complete-lambda))
(require 'company)
(after-load 'go-mode
;;; company-go - company backend for Golang
;;; https://github.com/nsf/gocode/blob/master/emacs-company/company-go.el
(require-package 'company-go)
(defun bw/setup-company-go ()
"Hook for running on company-go"
;; we only want to use company-go - it's so accurate we won't need any other
;; completion engines
(set (make-local-variable 'company-backends) '(company-go)))
(after-load 'company-go
(defadvice company-go (around fix-company-go-prefix activate)
"Clobber company-go to use company-grab-word instead of the
flakey regular expression. This allows us to complete standard
variables etc. as well as methods and properties."
ad-do-it
(when (eql (ad-get-arg 0) 'prefix)
(setq ad-return-value (company-grab-word))))
(add-hook 'go-mode-hook 'bw/setup-company-go))
(require 'company-go))
(provide 'setup-company)