jackguo380 / vim-lsp-cxx-highlight

Vim plugin for C/C++/ObjC semantic highlighting using cquery, ccls, or clangd
MIT License
337 stars 26 forks source link

Does not highlight until clangd becomes idle #40

Closed amandeepgautam closed 4 years ago

amandeepgautam commented 4 years ago

Hi have vim-lsp-cxx-highlight setup with coc-clangd and coc.nvim.

For files in a large project, I do not see the highlighting until clangd becomes idle. This can take up to a minute. It is not a problem for coc.nvim as it still shows incomplete auto-completion list. However, for highlighting purposes, it feels like too much of a lag.

jackguo380 commented 4 years ago

This is neither a bug or related to vim-lsp-cxx-highlight.

clangd (and ccls) only can send highlighting information after obtaining the AST for the file which naturally involves "compiling" and analyzing it with libclang. Given the complexity of C++ syntax its natural the process takes awhile if there's a significant amount of code to go through. For perspective, I use ccls and this plugin to work on a code base that takes over an hour to fully index on a fairly powerful workstation.

If you close your vim frequently then you should be saving the index to disk for faster reloading. ccls by default will do this for all versions but only recent versions of clangd have indexing support (I think version 10+) and may need to be configured by the user. As this isn't the place for clangd support please find the appropriate channel if you can't figure it out. I recommend upgrading the version and looking at the docs first.