DEPRECATED! Use nvim-treesitter instead.
Issues: see gitlab
clangd-nvim uses Neovim's build- in Language Server Protocol to enable clangd's support for semantic highlighting.
Left: clangd-nvim + nvim-lsp; Right: no plugin
- Implement basic semantic highlight support
- Implement highlight groups
- Enable/Disable semantic highlighting
- Change highlight color
- Semantic Highlighting for
c
,cpp
- With vim-plug:
" Required
Plug 'neovim/nvim-lsp'
" Plugin
Plug 'robert-oleynik/clangd-nvim'
Add to init file:
lua << EOF
local clangd_nvim = require'clangd_nvim'
require'lspconfig'.clangd.setup{
capabilities = {
textDocument = {
semanticHighlightingCapabilities = {
semanticHighlighting = true
}
}
},
on_init = clangd_nvim.on_init
}
EOF
Enable semantic highlighting
Enabled by default
lua require'clangd_nvim'.enable()
Disable semantic highlighting
lua require'clangd_nvim'.disable()
Reload current buffer's semantic highlight
lua require'clangd_nvim'.reload()
Clear current buffer's semantic highlight
lua require'clangd_nvim'.clear_highlight()
- Add to init file (init.vim)
augroup ConfigSetup
autocmd!
autocmd VimEnter,ColorScheme * runtime syntax/custom_colors.vim
augroup END
- Add to neovim config folder
syntax/custom_colors.vim
-File (on Linux~/.config/nvim/syntax/custom_colors.vim
) - Change Colors by:
hi! default link <clangd-syntax-highlight-group> <vim-syntax-highlight-group>
" Example:
hi! default link ClangdClass Type
Note:
:so $VIMRUNTIME/syntax/hitest.vim
lists all available syntax highlight groups with colors.
Clangd Symbol | Highlight Group | Default Value |
---|---|---|
entity.name.function.cpp |
ClangdFunction |
Function |
entity.name.function.method.cpp |
ClangdMemberFunction |
Function |
entity.name.function.method.static.cpp |
ClangdStaticMemberFunction |
Function |
entity.name.function.preprocessor.cpp |
ClangdPreprocessor |
Macro |
entity.name.namespace.cpp |
ClangdNamespace |
Namespace |
entity.name.other.dependent.cpp |
ClangdDependentName |
Function |
entity.name.type.class.cpp |
ClangdClass |
Type |
entity.name.type.concept.cpp |
ClangdConcept |
Type |
entity.name.type.dependent.cpp |
ClangdDependentType |
Type |
entity.name.type.enum.cpp |
ClangdEnum |
Type |
entity.name.type.typedef.cpp |
ClangdTypedef |
Type |
entity.name.type.template.cpp |
ClangdTemplateParameter |
Type |
storage.type.primitive.cpp |
ClangdPrimitive |
Type |
variable.other.cpp |
ClangdVariable |
Variable |
variable.other.local.cpp |
ClangdLocalVariable |
Variable |
variable.parameter.cpp |
ClangdParameter |
Variable |
variable.other.field.cpp |
ClangdField |
Variable |
variable.other.static.field.cpp |
ClangdStaticField |
Variable |
variable.other.enummember.cpp |
ClangdEnumConstant |
Constant |
meta.disabled |
ClangdInactiveCode |
Comment |