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

Draft: Fix highlight with unicode #77

Open Kamilcuk opened 2 years ago

Kamilcuk commented 2 years ago

This is a draft for now.

Solves issue #51 on neovim and on vim.

The extra catch are for, as I understand it, a race condition: it may happen, that a line is edited, and in midst editing the highlight function is triggered, then it may happen that it calls getbufline, while the columns are no longer there, because they were removed when editing. It actually causes nothing, as the column is no longer there, it can just throw and ignore the operation, and highlight it on the next pass. On the other hand, such issue shows that there is a slight delay in the functions, and it causes some slowdown, so it may be a good idea to make it in a feature flag.

I am using this for like a month with sources with a lot of π Ω « » characters, and it works really fine.

jackguo380 commented 2 years ago

At a first glance it looks like this code only fixes the neovim textprop backend. Maybe it works fine without this change on vim's textprop, but could you do a quick check to see if it's necessary?

The change "Add default highlight for LocalVariable" is not necessary. I deliberately left that group undefined as it's a very common one that most people don't want custom highlighting for. Adding it results in a lot more highlighting calls which slows things down. Users who want the group can always define it in their own vimrc.

Kamilcuk commented 2 years ago

Maybe it works fine without this change on vim's textprop

Added support for that, but I didn't test it that much.

Add default highlight for LocalVariable" is not necessary

Sure! Well, just added a comment then.... :p