# vimconfig **Repository Path**: chinafengliang/vimconfig ## Basic Information - **Project Name**: vimconfig - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: zhihui - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-12-29 - **Last Updated**: 2023-07-31 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README My vim configuration # 1. 安装 Vim: ```bash $ sudo apt-get install vim ``` # 2. 配置 ```bash $ cd $ rm -rf .vim .vimrc $ git clone git@gitee.com:chinafengliang/vimconfig.git $ ln -s vimconfig/vim .vim $ ln -s vimconfig/vimrc .vimrc ``` ## 2.1 Install Vundle plugin manager ```bash $ git clone https://gitee.com/chinafengliang/Vundle.vim.git ~/.vim/bundle/Vundle.vim ``` ## 2.2 安装插件 Launch vim and run`:PluginInstall`command or run `vim +PluginInstall +qall` from command line directly. After done that, please go to [here](https://github.com/Valloric/YouCompleteMe) to see more about the installation of YouCompleteMe plugin. ## 2.3 安装 powerline 字体 after powerline fonts installed, configure the terminal to use one of the powerline fonts. 作者认为*Source Code Pro for Powerline Medium*的12号字体 比较舒服。 ```bash $ git clone https://gitee.com/chinafengliang/fonts.git ``` ### linux ``` $ cd fonts && ./install.sh ``` ### windows 先按 Windows + x 调出 WinX 菜单,然后按 a 以管理员权限运行 PowerShell ,修改执行 策略并执行 install.ps1。 ``` > cd fonts > Set-ExecutionPolicy bypass > .\install.ps1 > Set-ExecutionPolicy Default ``` ### 参考文献 - [Powerline 字体安装 for Windows / Mac / Ubuntu](https://blog.csdn.net/LutingWang/article/details/123515698) ## 2.4 suan/vim-instant-markdown ```bash $ sudo apt-get install xdg-utils curl nodejs-legacy npm $ sudo npm -g install instant-markdown-d ``` # 3. 源码编译 ``` $ git clone https://github.com/vim/vim.git ``` ## 3.1 配置 在vim的help文档中, 提到`当同时支持Python 2和Python 3时,必须动态加载它们。在 Linux / Unix系统上执行此操作并导入global symbols时,这会导致使用第二个Python版本 时发生崩溃。 所以要么加载global symbols只激活一个Python版本,要么不导入全局符号。 这会导致Python导入vim提供的全局符号的相关库的import出错。` 因此,我们仅编译支持 python 2 或 python 3功能。 支持Python 2配置如下: ``` $ ./configure --with-features=huge \ --enable-multibyte \ --enable-rubyinterp=yes \ --enable-pythoninterp=yes \ --with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu \ --enable-perlinterp=yes \ --enable-luainterp=yes \ --enable-cscope \ --prefix=/usr/local ``` 支持Python 3配置如下: ``` $ ./configure --with-features=huge \ --enable-multibyte \ --enable-rubyinterp=yes \ --enable-python3interp=yes \ --with-python3-config-dir=/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu \ --enable-perlinterp=yes \ --enable-luainterp=yes \ --enable-cscope \ --prefix=/usr/local ``` ## 3.2 安装 ``` $ make VIMRUNTIMEDIR=/usr/local/share/vim/vim81 $ make install ``` # 4. YouCompleteMe YouCompleteMe 是一款非常强大的自动补全功能插件。该插件功能依赖python2或python3的 支持,否则将会报错。 # 5. coc 插件 coc.nvim 是一款自动补全功能插件。相对于 YouCompleteMe,coc的体积更小且安装方便。该插件功能依赖nodejs ## 5.1 nodejs ```bash $ curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash - $ sudo apt-get install -y nodejs $ sudo npm install --force -g yarn $ cd ~/.vim//bundle/coc.nvim/ $ yarn install $ yarn build ``` ## 5.2 ccls ``` $ git clone --depth=1 --recursive https://github.com/MaskRay/ccls ``` 下载"Pre-Built Binaries" from https://releases.llvm.org/download.html 并解压到 /path/to/clang+llvm ``` $ sudo apt-get install libclang-10-dev ``` ``` $ cmake -H. -BRelease -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_PREFIX_PATH=/path/to/clang+llvm ``` ``` $ sudo cmake --build Release --target install ``` 安装完成后,首先进入nvim中,而后输入CocConfig,而后终端会出现一个新的页面,把下 面的json文本粘贴进去。 ## 5.3 语言支持 为了使coc插件支持某种语言,需要稍加修改配置文件。安装完成后,首先进入nvim中,而后输入CocConfig,而后终端会出现一个新的页面,把下面的json文本粘贴进去。 ```bash { "languageserver": { "ccls": { "command": "ccls", "filetypes": ["c", "cpp", "cuda", "objc", "objcpp"], "rootPatterns": [".ccls-root", "compile_commands.json"], "initializationOptions": { "cache": { "directory": ".ccls-cache" }, "client": { "snippetSupport": true } } } } } ``` 在vim中执行 ``` CocInstall coc-ccls ``` 解决如下报错信息`[coc.nvim] Unable to load global extension at...`。 ```bash $ cd ~/.config/coc/extensions/node_modules/coc-ccls $ ln -s node_modules/ws/lib lib ``` # 6. 参考文献 1. http://easwy.com/blog/archives/advanced-vim-skills-catalog/ 2. http://blog.csdn.net/wooin/article/details/1858917 3. http://blog.csdn.net/wooin/article/details/2004470 4. http://www.cnblogs.com/zhongcq/p/3642794.html 5. http://blog.csdn.net/fivedoumi/article/details/50594348 命令模式下输入 :hi[ghlight] 能够看到当前vim的着色风格 命令模式下输入 :sy[ntax] 能够看到当前语法加亮模式,当文档的文字与列表里的正則表 達式匹配时,vim会给文字着色、应用缩进等等 想要自己定义着色风格,能够在~/.vim/colors/ 下建立.vim文件,然后在vim里使用 :colorscheme 载入。 也能够将:colorscheme命令写进.vimrc自己主动载入 color文件的格式: 以 " 开头的行为凝视行 highlight clear//清除全部颜色设定 let g:colors_name = ""My//设定颜色风格的名字 颜色设定表: highlight <组名> = highlight <组名> = ... 组名是用:highlight命令显示的最左一列,属于这一组的文字会用设定的方式着色 Key能够是: Myterm(普通控制台)/cterm(高级控制台,有着色等功能)/gui Myctermfg(cterm前景色)/ctermbg(cterm背景色)等 Args能够是: Mybold/none/underline/italic/inverse/reverse My或者是颜色代码: Mycterm用1-7代表提前定义的7种颜色,假设文字被加上了bold属性,以高亮颜色显示 Mygui能够用颜色名或RGB码标示颜色 样例: highlight Statement ctermfg=3 cterm=bold guifg=#c0c000 gui=bold " 修改~/etc/vimconfig/vim/after/syntax/c.vim ``` -hi cFunction gui=NONE guifg=#B5A1FF ctermfg=darkblue +hi cFunction gui=NONE guifg=#B5A1FF ctermfg=154 ```