Install youcompleteme on centos
Haha, I came back again. I simply re-installed one virtual machine and configured vim again. This time I am confident that I have posted the installation method of youcomplete. I will give you an authoritative Link first, then, the specific steps are provided to ensure that the installation is successful.
Http://www.centoscn.com/image-text/install/2016/0424/7115.html
What is youcompleteme? It is a powerful auto-completion plug-in. After installing this plug-in, configure vim so that you will not forget the function name when coding ~
We need the following steps:
- First, check whether python is installed in your own virtual machine. Use vim to try 1: echo has ('python'). If the result is 1, it means yes (in fact, it doesn't matter if it doesn't exist, execute the installation command again)
yum install python
- Install vundle. vundle is a vim plug-in management tool. It is easy to install youcomplete.
1git clone https://github.com/gmarik/Vundle.vim.git ~ /. Vim/bundle/Vundle. vim
Add such a configuration statement to vimrc.
set nocompatible filetype off set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() Plugin 'gmarik/Vundle.vim' Plugin 'Valloric/YouCompleteMe' call vundle#end() filetype plugin indent on
Clone the youcompleteme code on github.
git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe
Install it in vim and run
:PluginInstall
DONE! Show it.
This step has been a pitfall for me for a long time. Many plagiarized online commands are apt commands and dnf commands, which are not suitable for my centos7. Just use yum!
yum install automake gcc gcc-c++ kernel-devel cmakeyum install python-devel python3-devel
No matter whether python is installed or not, after these two commands are executed, you have
The next step is compilation.
cd ~/.vim/bundle/YouCompleteMe./install.py --clang-completer
Execute the above two commands and wait ~ Compile it.
Modify the vimrc File
Let g: ycm_global_ycm_extra_conf = '/home/li /. vim/bundle/YouCompleteMe /. ycm_extra_conf.py let g ()? "\ <C-y>": "\ <CR>" "press enter to select the current item set completeopt = longest, menu "makes Vim's completion menu Behavior consistent with general IDE (refer to VimTip1228)
Note: In the first sentence, the/home/li/part is not necessarily common. It depends on your current login account. I use root login, so this part is/root/
Possible. the ycm_extra_conf.py file will automatically be available, maybe not. find it and modify vim if it is not found. The following is the file content. before copying it, enter
:set paste
Enter the replication mode, so that the format will not be messy after replication ~
import osimport ycm_coreflags = ['-Wall','-Wextra','-Wno-long-long','-Wno-variadic-macros','-fexceptions','-stdlib=libc++','-std=c++11','-x','c++','-I','.','-isystem','/usr/include','-isystem','/usr/local/include','-isystem','/Library/Developer/CommandLineTools/usr/include','-isystem','/Library/Developer/CommandLineTools/usr/bin/../lib/c++/v1',]compilation_database_folder = ''if os.path.exists( compilation_database_folder ): database = ycm_core.CompilationDatabase( compilation_database_folder )else: database = NoneSOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]def DirectoryOfThisScript(): return os.path.dirname( os.path.abspath( __file__ ) )def MakeRelativePathsInFlagsAbsolute( flags, working_directory ): if not working_directory: return list( flags ) new_flags = [] make_next_absolute = False path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ] for flag in flags: new_flag = flag if make_next_absolute: make_next_absolute = False if not flag.startswith( '/' ): new_flag = os.path.join( working_directory, flag ) for path_flag in path_flags: if flag == path_flag: make_next_absolute = True break if flag.startswith( path_flag ): path = flag[ len( path_flag ): ] new_flag = path_flag + os.path.join( working_directory, path ) break if new_flag: new_flags.append( new_flag ) return new_flagsdef IsHeaderFile( filename ): extension = os.path.splitext( filename )[ 1 ] return extension in [ '.h', '.hxx', '.hpp', '.hh' ]def GetCompilationInfoForFile( filename ): 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 return None return database.GetCompilationInfoForFile( filename )def FlagsForFile( filename, **kwargs ): if database: compilation_info = GetCompilationInfoForFile( filename ) if not compilation_info: return None final_flags = MakeRelativePathsInFlagsAbsolute( compilation_info.compiler_flags_, compilation_info.compiler_working_dir_ ) else: relative_to = DirectoryOfThisScript() final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to ) return { 'flags': final_flags, 'do_cache': True }