spacemacs c++ 智能提示


这里选择ycmd server的方案。我的系统是ArchLinux,请根据自己的系统做调整。

安装ycmd server

Ubuntu上很简单

sudo apt-get install ycmd


安装两个layer

在.spacemacs文件中的dotspacemacs-configuration-layers里面添加ycmd

然后也要安装auto-completition layer

auto-completion layer里面包含了company mode。


配置

在user-config()函数里面配置如下:

  ;; ycmd
  (require 'ycmd)
  (add-hook 'c++-mode-hook 'ycmd-mode)
  
  (setq ycmd-extra-conf-whitelist '("~/work/gitlab/gitlab.com/mystudy/mongodb/code/*"))

  (require 'company-ycmd)
  (company-ycmd-setup)


在ubuntu上没有找到合适的设置ycmd-seerv er-command的方法,只能修改ycmd/pacakge.el, 

(setq ycmd-packages
  '(
    (company-ycmd :toggle (configuration-layer/package-usedp 'company))
    (flycheck-ycmd :toggle (configuration-layer/package-usedp 'flycheck))
    ycmd
    ))
(setq ycmd-server-command '("python2" "/usr/bin/ycmd"))

(unless (boundp 'ycmd-server-command)
  (message (concat "YCMD won't work unless you set the ycmd-server-command "
                   "variable to the path to a ycmd install.")))



重新启动emacs,然后打开一个main.cc文件,开始愉快的编程吧。

spacemacs c++ 智能提示_第1张图片


你可能感兴趣的:(#,Emacs,C++)