Skip to content

Neovim plugin for semantic highlighting in C++ based on Neovim's build-in LSP support. Mirror of https://gitlab.com/robert-oleynik/clangd-nvim/

License

Notifications You must be signed in to change notification settings

tom-anders/clangd-nvim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DEPRECATED! Use nvim-treesitter instead.

clangd-nvim

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

Roadmap

  • Implement basic semantic highlight support
  • Implement highlight groups
  • Enable/Disable semantic highlighting
  • Change highlight color

Features

  • Semantic Highlighting for c,cpp

Requirements

Install

" Required
Plug 'neovim/nvim-lsp'
" Plugin
Plug 'robert-oleynik/clangd-nvim'

Setup

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

Functions

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()

Change Colors

  1. Add to init file (init.vim)
augroup ConfigSetup
    autocmd!
    autocmd VimEnter,ColorScheme * runtime syntax/custom_colors.vim
augroup END
  1. Add to neovim config folder syntax/custom_colors.vim-File (on Linux ~/.config/nvim/syntax/custom_colors.vim)
  2. 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.

Symbols And Syntax Highlight Groups

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

About

Neovim plugin for semantic highlighting in C++ based on Neovim's build-in LSP support. Mirror of https://gitlab.com/robert-oleynik/clangd-nvim/

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 71.8%
  • Vim Script 28.2%