1 Star 0 Fork 0

old_school_vim/vim-lsp-cxx-highlight

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

vim-lsp-cxx-highlight

vim-lsp-cxx-highlight is a vim plugin that provides C/C++/Cuda/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

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

    • $cquery/publishSemanticHighlighting - semantic highlighting
    • $cquery/setInactiveRegions - preprocessor skipped regions
  • ccls

    • $ccls/publishSemanticHighlight - semantic highlighting
    • $ccls/publishSkippedRegions - preprocessor skipped regions
  • clangd

    • Requires coc.nvim and coc-clangd
    • Using the proposed Semantic Highlighting Protocol
    • IMPORTANT: coc-clangd supports 2 implementaions: "semantic highlighting" (old, non-standard) and "semantic tokens" (new, LSP standard). The latest versions of clangd (12+) require disabling coc's semantic tokens to work; see below.

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'

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

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 = 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!

License

MIT License

Copyright (c) 2019 Jack Guo Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

暂无描述 展开 收起
README
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/old_school_vim/vim-lsp-cxx-highlight.git
git@gitee.com:old_school_vim/vim-lsp-cxx-highlight.git
old_school_vim
vim-lsp-cxx-highlight
vim-lsp-cxx-highlight
master

搜索帮助