Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 74 lines (52 sloc) 2.859 kb
af5e592 @Golevka README in org markup
Golevka authored
1 * Introduction
2
3 emacs-clang-complete-async is an emacs extension to complete C and C++ code,
7bf0dbd @Golevka Update README.org
Golevka authored
4 it uses libclang to parse the source code on the fly and provides completion candidates to
af5e592 @Golevka README in org markup
Golevka authored
5 auto-complete (http://cx4a.org/software/auto-complete).
6
7 [[https://github.com/Golevka/emacs-clang-complete-async/raw/master/screenshots/showcase.png]]
8
9 This extension is not implemented in pure elisp, it is made up of a client part
10 (auto-complete-clang-async.el, written in elisp) and a server part
11 (clang-complete binary, written in C), they work cooperately in asynchonous
12 client-server fashion.
13
ffd2cad @Golevka updated README.org
Golevka authored
14 * Experimental Feature - On the fly syntax checking
15
16 An experimental feature is added to this branch --- running
17 =ac-clang-syntax-check= to highlight errornous lines in your souce code.
18
f10848d @Golevka fixed invalid reference to image
Golevka authored
19 [[https://github.com/Golevka/emacs-clang-complete-async/raw/master/screenshots/syntax_check.png]]
ffd2cad @Golevka updated README.org
Golevka authored
20
af5e592 @Golevka README in org markup
Golevka authored
21
22 * Setup
23
94d17f7 @toojays Allow the location of "llvm-config" to be overridden on the "make" comma...
toojays authored
24 Compile the server part (clang-complete binary) first, by executing
25 =make=. The build process uses =llvm-config= to determine the location of
26 libclang and the appropriate compile flags to use. If =llvm-config= is not in
27 your path or has a different name, you can pass =make= an =LLVM_CONFIG=
28 argument, e.g. =make LLVM_CONFIG=llvm-config-3.4=.
29
30 Copy auto-complete-clang-async.el and the previously compiled
af5e592 @Golevka README in org markup
Golevka authored
31 clang-complete executable to ~/.emacs.d/, and add the following code to your
32 .emacs file.
33
34 #+BEGIN_SRC elisp
35 (require 'auto-complete-clang-async)
36
37 (defun ac-cc-mode-setup ()
2d55b6b @Golevka updated README, notice that the configuration code needs to be modified ...
Golevka authored
38 (setq ac-clang-complete-executable "~/.emacs.d/clang-complete")
af5e592 @Golevka README in org markup
Golevka authored
39 (setq ac-sources '(ac-source-clang-async))
2d55b6b @Golevka updated README, notice that the configuration code needs to be modified ...
Golevka authored
40 (ac-clang-launch-completion-process)
af5e592 @Golevka README in org markup
Golevka authored
41 )
42
43 (defun my-ac-config ()
44 (add-hook 'c-mode-common-hook 'ac-cc-mode-setup)
45 (add-hook 'auto-complete-mode-hook 'ac-common-setup)
46 (global-auto-complete-mode t))
47
48 (my-ac-config)
49 #+END_SRC
50
51 Now emacs-clang-complete-async will show completion candidates automatically
52 when you type as usual in C or C++ mode.
53
54
55 * Usage
56
57 This extension fades in emacs C/C++ mode and provides candidates
58 automatically while you typing code, if you want to add parameters to clang
59 (libclang, actually), such as -Ipath, just call ac-clang-set-cflags
60 interactively or set the value of ac-clang-flags in .emacs or .dir-locals.el,
61 maybe you need an explicit call to ac-clang-update-cmdlineargs to make changes
0476227 @Golevka Update README.org
Golevka authored
62 to cflags take effect, which is a niggling part of it T T
af5e592 @Golevka README in org markup
Golevka authored
63
64
65 * Note
66
67 Most code of auto-complete-clang-async.el is taken from brainjcj's
68 auto-complete-clang.el, The only difference between this one and bj's
69 ac-clang-complete is: This one interacts with a process geared with libclang to
70 retrieve completion candidates instead of calling clang process, which is way
71 slower, and the asynchonous nature of our C-S based working model won't block
72 the editor while parsing source code and resolving completion candidates,
73 which provides a "smooth" coding experience.
Something went wrong with that request. Please try again.