zoukankan      html  css  js  c++  java
  • Ubuntu16.04下配置YouCompleteMe

    目的:想要在Ubuntu下跑实验,所以希望能够有类似于IDE那样的代码提示功能的软件,所以在Ubuntu下进行了配置,遇到了很多问题。

    需要工具:VundleVim

         YouCompleteMe

    1、安装VundleVim

      VundleVim能够为我们自动安装插件,并且为YouCompleteMe做必要的准备,具体方法可以见github:

      https://github.com/VundleVim/Vundle.vim

      可以执行命令:

    git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

      如果出现没有git命令,可以先安装git命令.

    sudo apt-get install git

      完成之后,来到根目录进行配置,具体操作:

    1 $ cd ~
    2 $ vim .vimrc

      之后将Vundle中的配置文件内容拷贝到.vimrc中,可以对其中一些不需要的配置进行注释

    2、安装YouCompleteMe    

      在.Vimrc中写入YouCompleteMe

      

      保存退出

      之后随意的开启vim,在vim中输入

    :PluginInstall 

      注意:大小写是敏感的,PluginInstall前有一个冒号.

      等待安装完成,需要一些时间。

      之后我们按照官方文档上来执行:https://github.com/Valloric/YouCompleteMe#ubuntu-linux-x64

      编译支持C族语言的YCM

    cd ~/.vim/bundle/YouCompleteMe
    ./install.py --clang-completer

      编译不支持C族语言的YCM

    cd ~/.vim/bundle/YouCompleteMe
    ./install.py

      可能会出现的问题,CMake没有安装,可能出现No CMAKE_CXX_COMPILER could be found

    sudo apt-get install cmake

     在编译时也会遇到编译通不过问题可以尝试一下执行

    git submodule update --init --recursive

    其次需要确保你有一些python头文件。如果没有,请按如下安装:

    sudo apt-get install python-dev

    3.配置YCM

      编译完成后,自己创建了一个cpp编辑发现不能提示,并且报错,No .ycm_extra_conf.py file detected, so no compile flags are available. Thus no semantic support for C/C++/ObjC/ObjC++

      首先到 .vim/bundle/YouCompleteMe文件下没有发现cpp这个文件,自己建立了一个

    mkdir cpp

      阅读手册:https://github.com/Valloric/YouCompleteMe#general-semantic-completion

      一共有两种方法来建立.ycm_extra_conf.py ,第一种没有看懂,所以使用第二种

    For a more elaborate example, see YCM's own .ycm_extra_conf.py. You should be able to use it as a starting point. Don't just copy/paste that file somewhere and expect things to magically work; your project needs different flags. Hint: just replace the strings in the flags variable with compilation flags necessary for your project. That should be enough for 99% of projects.

    You could also consider using YCM-Generator to generate the ycm_extra_conf.py file.(暂未实现理解)

    在第二种方法中,我们可以看到作者给的YCM's own .ycm_extra_conf.py,我们可以通过拷贝它来放到自己之前建立的cpp中。在cpp下建立.ycm_extra_conf.py然后将作者的拷贝过来,注:需要在.ycm_extra_conf.py下添加一些引用即在flags下(结尾处加上“,”):

    './tests/gmock/include',
    '-isystem',
    '/usr/include',
    '/usr/include/c++/5.4.0',
    '/usr/include',
    '/usr/include/x86_64-linux-gnu/c++',

    在.vimrc中配置.ycm_extra_conf.py的路径

    g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/cpp/.ycm_extra_conf.py'

     到这里配置就完成了

    纸上得来终觉浅,绝知此事要躬行
  • 相关阅读:
    Qt刷新机制的一些总结(Qt内部画的时候是相当于画在后台一个对象里,然后在刷新的时候调用bitblt统一画,调用window的api并不会影响到后面的那个对象)
    delphi中formatFloat代码初探(在qt下实现floatformat的函数)
    Qt中如何写一个model(自定义一个RowNode,我没有碰到过)
    DNN简介以及安装
    理解C# 4 dynamic(4) – 让人惊艳的Clay
    C#基础知识系列八(const和readonly关键字)
    ASP.NET MVC 5 -从控制器访问数据模型
    随机数的算法
    c#拷贝
    MVC UnitOfWork EntityFramework架构
  • 原文地址:https://www.cnblogs.com/asheng/p/6337611.html
Copyright © 2011-2022 走看看