Ⅰ. 插件描述
Vim plugin for C/C++/ObjC semantic highlighting using cquery or cclsⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'jackguo380/vim-lsp-cxx-highlight'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'jackguo380/vim-lsp-cxx-highlight'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'jackguo380/vim-lsp-cxx-highlight'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/jackguo380/vim-lsp-cxx-highlight
Ⅳ. 文档说明
# vim-lsp-cxx-highlight
vim-lsp-cxx-highlight is a vim plugin that provides C/C++/ObjC semantic highlighting
using the language server protocol.
Introduction
How does this plugin differentiate itself from
color_coded and
chromatica?
vim-lsp-cxx-highlight does no compilation/analysis of source files. It receives all
of its semantic highlighting data over the language server protocol.
The main advantage of this plugin is that it is written entirely in vimscript.
The idea for this came from vscode-cquery
and seeing how it uses cquery to provide semantic highlighting.
Left: No Plugin, Right: vim-lsp-cxx-highlight + ccls

Requirements
The plugin requires vim or neovim. For vim +timers and +byte_offset are
recommended but not required.
Additionally a compatible language server and language server client is required.
The following language servers and protocol extensions are supported:
$cquery/publishSemanticHighlighting- semantic highlighting$cquery/setInactiveRegions- preprocessor skipped regions
$ccls/publishSemanticHighlight- semantic highlighting$ccls/publishSkippedRegions- preprocessor skipped regions
The following language server clients are supported:
Install
Using vim-plug (Or use the plugin manager of your choice)
Plug 'prabirshrestha/vim-lsp' " vim-lsp
" or
Plug 'autozimu/LanguageClient-neovim' " LanguageClient-neovim
" or
Plug 'neoclide/coc.nvim' " coc.nvim
" or
Plug 'neovim/nvim-lsp' " nvim-lsp
Plug 'jackguo380/vim-lsp-cxx-highlight'For cquery the following initializationOptions are needed:
{
"highlight": { "enabled" : true },
"emitInactiveRegions" : true
}For ccls the following initializationOptions are needed:
{
"highlight": { "lsRanges" : true }
}For a sample vim-lsp configuration see this
For a sample LanguageClient-neovim configuration see this
For a sample coc.nvim coc-settings.json see this
For a sample nvim-lsp configuration see this
Configuration
The plugin should work without any additional configuration. But if you don't like
the default settings see :help vim-lsp-cxx-highlight
Vim Text Properties
vim-lsp-cxx-highlight now has support for Vim 8.1's text properties (See :help textprop).
What using text-properties improves:
- Highlighting moves around with the text, inserting new lines/words no longer messes things up
- Deleting lines removes highlighting attached to text
- Some performance improvements? (Unverified)
Support for this feature has been tested on Vim version 8.1.1722, older versions may have problems.
It is recommended to upgrade to this version or newer.
To enable:
let g:lsp_cxx_hl_use_text_props = 1Note: This is now automatically enabled for vim version 8.2 or greater
This is a experimental feature so it may be quite buggy, please file bug reports!