set nocompatible "filetype off set rtp+=~/.vim/bundle/vundle call vundle#begin() Bundle 'gmarik/vundle' Plugin 'Valloric/YouCompleteMe' "Brief help of vundle ":BundleList ":BundleInstall ":BundleSearch ":BundleClean ":help vundle "End brief help
cd ~/.vim/bundle/YouCompleteMe python3 install.py --all
然而很遗憾,如果直接按照这个步骤来执行在下载 clang 时会报出类似这个错误:
1 2 3 4
for file: [/home/irvinglwj/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/../clang_archives/clang+llvm-3.9.0-x86_64-opensuse13.2.tar.xz] expected hash: [9153b473dc37d2e21a260231e90e43b97aba1dff5d27f14c947815a90fbdc8d7] actual hash: [e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855] status: [7;"Couldn't connect to server"]
# Copyright (C) 2014 Google Inc. # # This file is part of ycmd. # # ycmd is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # ycmd is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with ycmd. If not, see <http://www.gnu.org/licenses/>.
import os import ycm_core
# These are the compilation flags that will be used in case there's no # compilation database set (by default, one is not set). # CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR. 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', #'/usr/include/c++/7.3.0', '-isystem', '/usr/include/c++/4.8', '-isystem', '/usr/local/cuda-9.0/include', '-isystem', '/usr/local/cuda', '-isystem', '/usr/lib/gcc/x86_64-linux-gnu/4.8', #'-isystem', #'/usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/backward/', #'-isystem', #'/usr/include/clang/6.0.0/include', '-isystem', '/usr/include/x86_64-linux-gnu', #'-isystem', #'/usr/lib/llvm-6.0/lib/clang/6.0.0/include', #'-isystem', #'/usr/include/clang/6.0.0/include', '-isystem', '/usr/include/c++/4.8' ]
# Set this to the absolute path to the folder (NOT the file!) containing the # compile_commands.json file to use that instead of 'flags'. See here for # more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html # # Most projects will NOT need to set this to anything; you can just change the # 'flags' list of compilation flags. compilation_database_folder = ''
defGetCompilationInfoForFile( filename ): # The compilation_commands.json file generated by CMake does not have entries # for header files. So we do our best by asking the db for flags for a # corresponding source file, if any. If one exists, the flags for that file # should be good enough. if IsHeaderFile( filename ): basename = os.path.splitext( filename )[ 0 ] for extension in SOURCE_EXTENSIONS: replacement_file = basename + extension if os.path.exists( replacement_file ): compilation_info = database.GetCompilationInfoForFile( replacement_file ) if compilation_info.compiler_flags_: return compilation_info returnNone return database.GetCompilationInfoForFile( filename )
# This is the entry point; this function is called by ycmd to produce flags for # a file. defFlagsForFile( filename, **kwargs ): ifnot database: return { 'flags': flags, 'include_paths_relative_to_dir': DirectoryOfThisScript() }
# Bear in mind that compilation_info.compiler_flags_ does NOT return a # python list, but a "list-like" StringVec object. return { 'flags': list( compilation_info.compiler_flags_ ), 'include_paths_relative_to_dir': compilation_info.compiler_working_dir_ }