Using Ycmd mode plus the Company-mode described earlier
Download and install Ycmd server first
Reference, key content has been cut out
Building
[Clients commonly build and set up ycmd for you, you is unlikely to need tobuild ycmd yourself unless, want to build a New client.]
This is all for Ubuntu Linux. Details on getting ycmd running to other OS ' s can befound in YCM ' s instructions (ignore the vim-specific parts).
First, install the dependencies:
sudo apt-get install build-essential cmake python-dev
When you first clones the repository you'll need to update the submodules:
git submodule update --init --recursive
Then run ./build.py --clang-completer --omnisharp-completer --gocode-completer
. This should get going.
For more detailed instructions in building ycmd, see YCM ' sinstructions (ignore the vim-specific parts).
Once compiled, a ycmd directory with the same name appears in the Ycmd directory. This path and so on will be needed.
Then install the Ycmd and company modules with the package system
This is no longer elaborate.
Configure the Init.el file as follows
;; Company mode (add-hook ' C++-mode-hook ' Global-company-mode);; Ycmd (Require ' ycmd) (Add-hook ' C++-mode-hook ' Ycmd-mode) (set-variable ' Ycmd-server-command ' ("Python"/home/dean/ Work/software/ycmd/ycmd ")) (Set-variable ' ycmd-extra-conf-whitelist ' ("/home/dean/work/gitlab/gitlab.com/ cppwizard/console/* ")) (Require ' Company-ycmd) (Company-ycmd-setup)
Configuring a dedicated Ycmd file for C + + engineering
The file can be copied from the Ycmd example directory, called. ycm_extra_conf.py, and put it here.
/home/dean/work/gitlab/gitlab.com/cppwizard/console/*
I made the changes, mainly changed the Include directory, deleted the configuration of object C
Flags = ['-wall ', '-wextra ', '-werror ', '-fexceptions ', '-dndebug ', # this is important! Without a "-std=<something>" flag, Clang won ' t know which# language to use when compiling headers. So it would guess. Badly. So c++# headers would be compiled as C headers. You don ' t want it all specify# a "-std=<something>". # for a C project, and you would set this to something like ' C99 ' instead of# ' c++11 '. ' -std=c++11 ', # ... and the same thing goes for the magic-x option which specifies the# language so the files to be Compil Ed is written in. This was mostly# relevant for C + + headers.# for a C project, and you would set the this to ' C ' instead of ' C + + '. -X ', ' C + + ', '-isystem ', '/usr/include ', '-isystem ', '/usr/local/include ', '-isystem ', '/home/dean/work/gitlab/ Gitlab.com/cppwizard/console/include ']
Use it, restart Emacs, enter C + + code to start editing, the first time will say wait for service to start, then later, try again. will see very comfortable hints, not only the standard library can automatically prompt, their own code is OK.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Emacs 24.4.1 Ultimate C + + Smart Tips Solution