设为首页 加入收藏

TOP

Emacs as C++ IDE
2015-07-24 06:37:46 】 浏览:7948
Tags:Emacs IDE
1.1 auto-completion
(require 'auto-complete)
(require 'auto-complete-config)
(ac-config_default)
Auto-completion is a basic plugin. When you input the existed string in a file, emacs will give your some tips.
1.2 yasnippet
(require 'yasnippet)
(yas-global-mode 1)
Yasnnipet is used to complete your code with code-fragments. For example, when you input "for" and press tab in a cpp file, code will be automatically completed as below:
for (i = 0; i < N; i++) {
}
1.3 auto-complete-c-headers
(defun my:ac-c-header-init()
(require 'auto-complete-c-headers)
(add-to-list 'ac-sources 'ac-source-c-headers)
(add-to-list 'achead:include-directories '(("/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"))))
(add-hook 'c++-mode-hook 'my:ac-c-header-init)
(add-hook 'c-mode-hook 'my:ac-c-header-init)
The "achead:include-directories" are my configuration. The include-directories vary with different systems. In terminal you can check include-directories as below command:
gcc -xc++ -E -v -
Use this plugins, when you press "#include
2 google style
2.1 google-cpplint
Some tools are required in your system
sudo apt-get install python-pip python-dev build-essential
sudo pip install cpplint
Then your can configure your emacs.
(defun my:flymake-google-init()
(require 'flymake-google-cpplint)
(custom-set-variables
'(flymake-google-cpplint-command "/usr/local/bin/cpplint"))
(flymake-google-cpplint-load))
(add-hook 'c-mode-hook 'my:flymake-google-init)
(add-hook 'c++-mode-hook 'my:flymake-google-init)
(require 'google-c-style)
(add-hook 'c-mode-common-hook 'google-set-c-style)
(add-hook 'c-mode-common-hook 'google-make-newline-indent)
This is my configure and maybe your cpplint-command directory isn't "/usr/local/bin/cpplint". you can set the directory as below command.
whereis cpplint
Using cpplint, you will see some "!, " at the begging of line in your .cpp or .h file, because your code isn't fit with google style.
2.2 clang
sudo apt-get install clang3.5 libclang-dev
git clone https://github.com/Sarcasm/irony-mode.git
git clone https://github.com/MJPA/SimpleJSON.git
mv irony-mode* irony-mode
mv SimpleJSon* SimpleJSon
mv SimpleJSon irony-mode/lib
mv SimpleJSon ~/.emacs.d/
cd ~/.emacs.d/SimpleJSon/build
cmake ..
make
sudo make install
The clang version varies with diffrent systems. you can check the package version in your system as the below command:
sudo apptitude search clang
Then you can configure your emacs as below:
(setenv "LD_LIBRARY_PATH" "/usr/lib/llvm-3.5/lib/")
(add-to-list 'load-path (expand-file-name "~/.emacs.d/irony-mode/elisp/"))
(require 'irony)
(irony-enable 'ac)
(defun my:irony-enable()
(when (member major-mode irony-known-modes)
(irony-mode 1)))
(add-hook 'c++-mode-hook 'my:irony-enable)
(add-hook 'c-mode-hook 'my:irony-enable)
Maybe the llvm-lib directory isn't "usr/lib/llvm-3.5/lib". you can search llvm-lib directory as below:
find / -name "llvm"
In reality, We setenv llv-lib because of iron's run is dependent on llvm-lib and it equals with adding llvm-lib in "/etc/ld.so.conf" file.
3 project manager
3.1 projectile
(require 'projectile)
;; 默认全局使用
(projectile-global-mode)
;; 默认打开缓存
(setq projectile-enable-caching t)
;; 使用f5键打开默认文件搜索
(global-set-key [f5] 'projectile-find-file)
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇c++ 副本构造器 下一篇求解一元线性同余方程组模版

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目