vim-lsp-cxx-highlight is a vim plugin that provides C/C++/Cuda/ObjC semantic highlighting using the language server protocol.
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
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 regionsThe following language server clients are supported:
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'
Using vim8's native package manager (Run this command in a terminal)
git clone https://github.com/jackguo380/vim-lsp-cxx-highlight.git ~/.vim/pack/vendor/start/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 clangd
coc-settings.json
must have:
{
"clangd.semanticHighlighting": true,
"coc.preferences.semanticTokensHighlights": false
}
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
The plugin should work without any additional configuration. But if you don't like
the default settings see :help vim-lsp-cxx-highlight
vim-lsp-cxx-highlight now has support for Vim 8.1's text properties (See :help textprop
).
What using text-properties improves:
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 = 1
Note: 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!
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。