-
Notifications
You must be signed in to change notification settings - Fork 1
/
ca2+init.el
128 lines (98 loc) · 4.2 KB
/
ca2+init.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; install sources ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'ca2+)
(require 'ca2+sources)
(require 'ca2+source-semantic)
(require 'ca2+ac)
;; Options what tab should preferably do.
;; just uncomment the preferred method:
;; default: tab cycles to next source
(define-key ca-active-map [tab] 'ca-next-source)
;; tab cycles to next candidate
;;(define-key ca-active-map [tab] 'ca-cycle)
;; tab expands current candidate
;;(define-key ca-active-map [tab] 'ca-expand-top)
;; tab expands common part, after that it expands the
;; current candidate to the next word boundary
;; when only one candidate is left tab will insert
;; that candidate
;; (define-key ca-active-map [tab] 'ca-expand-common)
;; when rebinding tab you'll need another binding for
;; cycling sources. e.g.:
;; (define-key ca-active-map "\M-h" 'ca-next-source)
;; if the source has an 'continue' action, like e.g. filename-source
;; to continue completion after inserting a directory name, or
;; semantic-source to continue with completion of member variables
;; resp. inserting a function argument template these will be triggered
;; by expand-and-continue
(define-key ca-active-map [(C return)] 'ca-expand-and-continue)
(ca-clear-completion-sources)
;;;; MODE SPECIFIC sources
;; sources are pushed on the list: load lower priority sources first
;;;; ELISP source:
(ca-add-source ca-source-lisp
'(emacs-lisp-mode
lisp-interaction-mode))
;;;; GTAGS source:
;; complete prefixes with tags found in gtags tags table
(eval-after-load 'gtags
'(progn
(ca-add-source ca-source-gtags
'(c++-mode c-mode java-mode))))
;;;; SEMANTIC source:
;;(eval-after-load 'semantic
;; '(progn
;;(require 'semantic-ia)
;; Enable experimental, but (hopefully) faster version.
;; Search results for a desired type are also sorted by
;; reachability so vars having the desired type come first, then
;; vars that have members from which desired type is reachable.
(require 'ca2+semantic)
;; complete prefix with tags found in semantics tags table
;; (ca-add-source ca-source-semantic-tags
;; '(c++-mode c-mode))
;;;; this source tries to figure out from context what preferred
;; candidates are. e.g: for 'int bla =' it finds vars and
;; functions that have int as type, same within function
;; arguments. it also sorts candidates first that have members
;; from which the desired type is reachable (when using
;; ca2+semantic). Use C-ret (ca-expand-and-continue) to complete
;; a function and insert argument templates for funtions or to
;; complete a variable and insert '.' resp. '->' and continue with
;; completing its members.
(ca-add-source ca-source-semantic-context
'(c++-mode c-mode java-mode jde-mode))
;;;; OMNICOMPLETION:
;; uncomment things below for omnicompletion. though you can just
;; type [tab] and C-ret to complete current candidate, insert '.' or
;; respectively '->' and show completion menu for members.
;;
;; (defun ca-semantic-completion (arg)
;; (interactive "p")
;; (self-insert-command arg)
;; (when (and (= arg 1))
;; (ca-begin nil ca-source-semantic-context)))
;; (defun ca-semantic-c-hook ()
;; (local-set-key "." 'ca-semantic-completion)
;; (local-set-key ">" 'ca-semantic-completion))
;; (add-hook 'c-mode-common-hook 'ca-semantic-c-hook)
;; ))
(eval-after-load "pymacs"
;; TODO figure out when rope is loaded
(ca-add-source ca-source-python-rope
'(python-mode)))
;;;; GENERAL sources are tried after mode specific ones
(ca-add-source ca-source-filename 'otherwise)
(ca-add-source ca-source-dabbrev 'otherwise)
;;;; YASNIPPET source:
;; this source show possible completions when a prefix
;; matches more than one yasnippet template
;; it seems that this needs to be set before '(require 'yasnippet)'
;; change this to your liking, but tab would interfere with
;; completion within yas templates.
;; (defvar yas/next-field-key (kbd "C-f"))
;; (defvar yas/prev-field-key (kbd "C-b"))
;; (eval-after-load 'yasnippet
;; '(progn
;; (ca-add-source ca-source-yasnippet 'otherwise)))
(global-ca-mode 1)
(provide 'ca2+init)