zl程序教程

您现在的位置是:首页 >  工具

当前栏目

发现的更强大的vim配置信息

Vim配置 信息 强大 发现
2023-09-14 08:59:42 时间

项目地址: https://github.com/wklken/k-vim
是wklken同学的一个git项目
wklken同学的blog主页: http://wklken.me/

演示

这里写图片描述

安装

下载K-VIM
clone到本地,配置到linux个人目录(如果是从linux_config过来的,不需要clone)

git clone https://github.com/wklken/k-vim.git

进入目录

注意原先装过的童鞋, 重装时,不要到~/.vim下执行(这是软连接指向k-vim真是目录),必须到k-vim原生目录执行

cd k-vim/

执行安装

会进入安装插件的列表,目前30+个插件,一一安装是从github clone的,完全取决于网速

sh -x install.sh

安装的时候会比较缓慢,尤其是在安装YouCompleteMe,请大家耐心等待

安装时有个错误,这是正常的,因为ycm需要手动编译出库文件。

Done! With errors; press l to view log

ycm_client_support.[so|pyd|dll] and ycm_core.[so|pyd|dll] not detected; you need to compile YCM before using it. Read the docs!


更加详细的安装信息请参见
https://github.com/wklken/k-vim

可能出现的问题

安装配置YouCompleteMe

vim需要支持python

要安装YouCompleteMe ,vim须支持Python。看是否支持,可以在vim中:–version 查看, 如果python前有+号,就是支持,减号就是不支持。
如果不支持,需要以编译安装方式重新安装vim。编译配置选项:

./configure --with-features=huge --enable-pythoninterp --enable-python3interp --enable-luainterp --enable-multibyte --enable-sniff --enable-fontset

步骤四: 然后到.vim/bundle/YouCompleteMe 下执行命令:

./install.sh --clang-completer --system-libclang

参数是为了支持c/c++的补全

命令报错1

然后可能还会出现报错:

Some folders in /home/sky-tm/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party are empty; you probably forgot to run: git submodule update --init --recursive

若出现此错误,则按照提示来,继续输入命令:

 git submodule update --init --recursive

等此命令更新完成后,再此执行命令:

./install.sh --clang-completer --system-libclang

这里写图片描述
安装完成后,进行一些简单的配置就可以使用了。

命令报错2
 STDERR:

Your C++ compiler supports C++11, compiling in that mode.

Downloading Clang 3.5

CMake Error at ycm/CMakeLists.txt:62 (message):

 No pre-built Clang 3.6 binaries for 32 bit linux. Youll have to compileClang 3.6 from source. See the YCM docs for details on how to use a

 user-compiled libclang.


YCM插件需要clang支持,Ubunto14.04源中的clang版本比较低,是clang-3.4
报这种错的原因是我们的clang版本太低或者没有clang.
需要从管网上下载clang的源码进行编译安装(You’ll have to compileClang 3.6 from source)
安装clang请参照这里Ubunto编译安装llvm-clang

YouCompleteMe编译完成后,会提示如下
这里写图片描述

YouCompleteMe进行补全时需要查找一个 ycm_global_ycm_extra_conf文件。可以每次在工作目录中放置这个文件,也可以设置全局。全局设置要在.vimrc中添加一行即可。

注:.ycm_extra_conf.py 是个隐藏文件,路径在~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py

let g:ycm_global_ycm_extra_conf = ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py