0

So I'm using nvim-lsp-clangd-highlight plugin to try and set up semantic highlighting with clangd

in my ~/.config/nvim/init.nvim

call plug#begin()
    Plug 'neovim/nvim-lsp'
    Plug 'neovim/nvim-lspconfig'
    Plug 'williamboman/mason.nvim'
    Plug 'williamboman/mason-lspconfig.nvim'
    Plug 'adam-wolski/nvim-lsp-clangd-highlight'
    ...
call plug#end()

I've done :PlugInstall and :PlugUpdate

in my ~/.config/nvim/lua/plugins.lua...

local nvim_lsp_clangd_highlight = require'nvim-lsp-clangd-highlight'

require('lspconfig')['clangd'].setup({
   on_attach = on_attach,
   cmd = {
      clangd_path,
      "--header-insertion=never"
   },
   capabilities = {
      textDocument = {
         semanticHighlightingCapabilities = {
            semanticHighlighting = true
         }
      }
   },
   on_init = nvim_lsp_clangd_highlight.on_init
})

in my ~/.config/nvim/ginit.vim...

augroup ConfigSetup
    autocmd!
    autocmd VimEnter,ColorScheme * runtime syntax/custom_colors.vim
augroup END

I've used this default script for my ~/.config/nvim/syntax/custom_colors.vim

I know that clangd is working, my hover key command works and errors are pointed out. But I can't get clangd's full semantic highlighting to work.

If I use the command hi Type guifg=Black only the built in types change color, anything user defined stays the same. If I use the command hi Namespace guifg=Black nothing changes and I have places with std::... or custom namespaces where I believe it should.

Does anyone know what I'm missing? What should I check?

1 Answer 1

0

I was able to get this working using this plugin and the following in my coc-settings.json

{
    "clangd.enabled": true,
    "[cpp]": {
        "inlayHint.enable": false,
        "semanticTokens.enable": true
    }
}
1
  • May be could you accept your own answer using the v button next to the arrow coming buttons. It allow the question to rest :-) Commented Aug 31, 2023 at 4:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.