![](https://img-blog.csdnimg.cn/20201227160027396.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3BvcDU0MTExMQ==,size_16,color_FFFFFF,t_70#pic_center)
初步未详细配置
编译安装vim
zypper remove vim #删除自带的vim
git clone https://github.com/vim/vim.git
cd vim
#添加python3支持
./configure --with-features=huge \
--enable-multibyte \
--enable-rubyinterp=yes \
--enable-pythoninterp=yes \
--with-python-config-dir=/usr/lib64/python2.7/config \
--enable-python3interp=yes \
--with-python3-config-dir=/usr/lib64/python3.8 \
--enable-perlinterp=yes \
--enable-luainterp=yes \
--enable-gui=gtk2 \
--enable-cscope \
--prefix=/usr/local/vim8
make && make install
将编译安装的vim添加到环境变量中
sudo update-alternatives --install /usr/bin/editor editor /usr/local/vim8/bin/vim 1
sudo update-alternatives --set editor /usr/local/vim8/bin/vim
sudo update-alternatives --install /usr/bin/vim vim /usr/local/vim8/bin/vim 1
sudo update-alternatives --set vim /usr/local/vim8/bin/vim
软件版本管理命令update-alternatives
参考 https://www.jb51.net/article/112372.htm
vim --version
如下
tom@ton-turing:~>vim --version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Dec 26 2020 20:31:12)
Included patches: 1-2202
Compiled by tom@ton-turing
Huge version without GUI. Features included (+) or not (-):
...
+comments +libcall -python +visual
+conceal +linebreak +python3 +visualextra
安装vim插件管理工具Vundle
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
向.vimre
添加如下内容
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" 在这里放YouCompleteMe插件
plugin 'Valloric/YouCompleteMe'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
为编译好的vim添加man page
ton-turing:~ # vim /etc/manpath.config
添加如下行
MANDATORY_MANPATH /usr/local/vim8/share/man
mandb
或者重启后man vim
生效
编译安装YouCompleteMe
进入vim
:PluginInstall
然后在shell中
cd ~/.vim/bundle
git clone https://github.com/Valloric/YouCompleteMe.git #git下载YouCompleteMe
检查完整性(在 `~/.vim/bundle/YouCompleteMe` 目录下)
git submodule update --init --recursive
#cd ~/.vim/bundle/YouCompleteMe
python3 install.py --clang-completer --rust-completer 编译安装
报错与解决
-
Searching Python 3.8 libraries... ERROR: Python headers are missing in /usr/include/python3.8.
这里需要zypper install python3-dev
或者zypper install python38-devel
安装python3的头文件和静态库
https://software.opensuse.org/package/python3-dev opensusue tumbleweed下的安装配置源
-
编译报错(如果没有安装cmake先安装
zypper in cmake -y
)
No CMAKE_CXX_COMPILER could be found.
这里需要安装c++编译器
zypper in gcc-c++
- 启动YCM报错(ycmd log File如下)
ton-turing:~ # cat /tmp/ycmd_47837_stderr_wssiseei.log
Traceback (most recent call last):
File "/usr/lib64/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib64/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/root/.vim/bundle/YouCompleteMe/python/ycm/../../third_party/ycmd/ycmd/__main__.py", line 193, in <module>
Main()
File "/root/.vim/bundle/YouCompleteMe/python/ycm/../../third_party/ycmd/ycmd/__main__.py", line 169, in Main
from ycmd import handlers
File "/root/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/handlers.py", line 27, in <module>
from ycmd import extra_conf_store, hmac_plugin, server_state, user_options_store
File "/root/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/server_state.py", line 22, in <module>
from ycmd.completers.language_server import generic_lsp_completer
File "/root/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/completers/language_server/generic_lsp_completer.py", line 20, in <module>
from ycmd.completers.language_server import language_server_completer
File "/root/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/completers/language_server/language_server_completer.py", line 30, in <module>
from watchdog.events import PatternMatchingEventHandler
File "/root/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/watchdog_deps/watchdog/build/lib3/watchdog/events.py", line 91, in <module>
from pathtools.patterns import match_any_paths
ModuleNotFoundError: No module named 'pathtools'
ton-turing:~ #
这里安装pathtools
sudo pip3 install pathtools
-
NoExtraConfDetected: No .ycm_extra_conf.py file detected, so no compile flags are available. Thus no semantic support for C/C++/ObjC...
YCM配置问题
https://blog.csdn.net/u014070086/article/details/88692896
YCM配置
" YouCompleteMe
" Python Semantic Completion
let g:ycm_python_binary_path = '/usr/bin/python3'
" C family Completion Path
let g:ycm_global_ycm_extra_conf='~/.ycm_extra_conf.py'
" 跳转快捷键
nnoremap <c-k> :YcmCompleter GoToDeclaration<CR>|
nnoremap <c-h> :YcmCompleter GoToDefinition<CR>|
nnoremap <c-j> :YcmCompleter GoToDefinitionElseDeclaration<CR>|
" 停止提示是否载入本地ycm_extra_conf文件
let g:ycm_confirm_extra_conf = 0
" 语法关键字补全
let g:ycm_seed_identifiers_with_syntax = 1
" 开启 YCM 基于标签引擎
let g:ycm_collect_identifiers_from_tags_files = 1
" 从第2个键入字符就开始罗列匹配项
let g:ycm_min_num_of_chars_for_completion=2
" 在注释输入中也能补全
let g:ycm_complete_in_comments = 1
" 在字符串输入中也能补全
let g:ycm_complete_in_strings = 1
" 注释和字符串中的文字也会被收入补全
let g:ycm_collect_identifiers_from_comments_and_strings = 1
" 弹出列表时选择第1项的快捷键(默认为<TAB>和<Down>)
let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
" 弹出列表时选择前1项的快捷键(默认为<S-TAB>和<UP>)
let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
" 主动补全, 默认为<C-Space>
"let g:ycm_key_invoke_completion = ['<C-Space>']
" 停止显示补全列表(防止列表影响视野), 可以按<C-Space>重新弹出
"let g:ycm_key_list_stop_completion = ['<C-y>']