码迷,mamicode.com
首页 > 编程语言 > 详细

emacs 24.4.1 终极 C++智能提示解决方案

时间:2015-10-05 00:49:39      阅读:993      评论:0      收藏:0      [点我收藏+]

标签:c++   emacs   

采用ycmd模式 加上 前面介绍的company-mode

首先下载并安装ycmd server

参考,重点内容已经截出来

Building

[Clients commonly build and set up ycmd for you; you are unlikely to need tobuild ycmd yourself unless you want to build a new client.]

This is all for Ubuntu Linux. Details on getting ycmd running on 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 clone 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 you going.

For more detailed instructions on building ycmd, see YCM‘sinstructions (ignore the Vim-specific parts).


编译好后,会出现一个在ycmd目录下出现一个同名的ycmd目录。这个路径等会需要。


然后用package system安装ycmd和company模块

这个不再细说。


配置init.el文件如下

;; 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)


为C++工程配置专门的ycmd文件

文件可以从ycmd的example目录中复制出来,名为.ycm_extra_conf.py,放在这里

/home/dean/work/gitlab/gitlab.com/cppwizard/console/*


我做了修改,主要是改了include目录,删除了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 will guess. Badly. So C++
# headers will be compiled as C headers. You don‘t want that so ALWAYS specify
# a "-std=<something>".
# For a C project, 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 that the files to be compiled are written in. This is mostly
# relevant for c++ headers.
# For a C project, you would set 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‘
]

使用吧,重启emacs, 进入C++代码开始编辑,第一次会说等待服务启动,那就过会儿,再试。会看到很舒服的提示,不仅标准库能自动提示,自己的代码也行了。

技术分享






版权声明:本文为博主原创文章,未经博主允许不得转载。

emacs 24.4.1 终极 C++智能提示解决方案

标签:c++   emacs   

原文地址:http://blog.csdn.net/csfreebird/article/details/48898801

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!