Emacs automatic completion, the best plug-in belongs to Ycmd. The following records my installation process.
1. Installing Ycmd Server
GitHub official address: Https://github.com/Valloric/ycmd
-Git clone ycmd to local ~/ycmd
$ git clone https://github.com/Valloric/ycmd.git ~/ycmd
-Install the necessary compilation tools and libraries
$ sudo apt-get install build-essential cmake python-dev
-Download the full submodule (big oh ... )
$ git submodule update --init --recursive
-Compile (slow oh ... )
$ CD ~/ycmd
$ ./build.py --all
once the compilation is complete, a Ycmd folder is generated in the current directory, and now it's like this ~/ycmd/ycmd
2. Install the Ycmd client and the necessary tools
-Open Emacs, command m-x list-packages, respectively install ycmd, Company-ycmd, Flycheck-ycmd
3. Configuration, add the following to ~/.emacs
;;;; ============================================================================================ < for Ycmd start >
;;;; To use Ycmd-mode on all supported modes
(Require ' Ycmd)
(Add-hook ' After-init-hook # ' Global-ycmd-mode)
;;;; Specify only support C + + mode
;;( Require ' Ycmd)
;;( Add-hook ' C++-mode-hook ' Company-mode)
;;( Add-hook ' C++-mode-hook ' Ycmd-mode)
;;;; Specify how to run the server
(set-variable ' Ycmd-server-command ' ("/usr/bin/python" "/home/peterpan/ycmd/ycmd"))
;;( Set-variable ' Ycmd-server-command ' ("/usr/bin/python" "~/ycmd/ycmd"));; Cannot use ~, should use Abspath
;;;; Specify a global Emacs configuration
(set-variable ' Ycmd-global-config "/home/peterpan/ycmd/examples/.ycm_extra_conf.py")
;;( Set-variable ' Ycmd-global-config "~/ycmd/examples/.ycm_extra_conf.py");; Cannot use ~, should use Abspath
;;;; Completion framework
(Require ' Company-ycmd)
(Company-ycmd-setup)
(Add-hook ' After-init-hook # ' Global-company-mode)
;;;; Enable Flycheck
(Require ' Flycheck-ycmd)
(Flycheck-ycmd-setup)
(Add-hook ' After-init-hook # ' Global-flycheck-mode)
;;;; Set always complete immediately
(setq company-idle-delay 0)
;;;; ============================================================================================ < for ycmd end >
There is a problem: the completion of the time, pop-up tip window, can not press TAB or Ctrl + N key to cycle option, can only continue to enter, until the first is to use, and then press ENTER to select. You need to know how to solve this problem, please tell me:P
Finish.
Emacs Auto-Complete plug-in Ycmd