我编译了 clang-complete 并将其放在〜/ .emacs.d /中。 我的 init.el 按如下方式配置插件:
(require 'auto-complete-clang-async)
(defun ac-cc-mode-setup ()
(setq ac-clang-complete-executable "~/.emacs.d/clang-complete")
(setq ac-sources '(ac-source-clang-async))
(ac-clang-launch-completion-process))
(defun ac-common-setup ()())
(defun my-ac-config ()
(add-hook 'c-mode-common-hook 'ac-cc-mode-setup)
(add-hook 'auto-complete-mode-hook 'ac-common-setup)
(global-auto-complete-mode t)
(setq ac-auto-show-menu 1))
(setq ac-clang-flags
(mapcar (lambda (item)(concat "-I" item))
(split-string
"
/usr/include/c++/4.6
/usr/include/c++/4.6/x86_64-linux-gnu/.
/usr/include/c++/4.6/backward
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
/usr/include/c++/4.8
/usr/include/x86_64-linux-gnu/c++/4.8
/usr/include/c++/4.8/backward
/usr/lib/gcc/x86_64-linux-gnu/4.8/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
"
)))
(my-ac-config)
我必须定义一个空的 ac-common-setup 函数,因为auto complete没有找到它。 当我打开一个cpp文件时,它在右下角显示:
(C++/l AC yas...)
我没有收到任何错误,但自动完成对c ++不起作用。