patstockwell / vim-monokai-tasty

VIM Colour scheme
390 stars 51 forks source link

C++ Syntax Highlighting not working #33

Closed rtunazzz closed 3 years ago

rtunazzz commented 3 years ago

Hi!

Beginner (neo)Vim user here... Love your theme!! Works lovely for Python, JS & TS from my testing. I am having some issues with getting syntax highlighting to work properly with C++ files though (on MacOS). See the screenshots below:

Theme turned OFF

(colorscheme vim-monokai-tasty commented out in my config file) - Notice how variable declarations such as int or bool are highlighted just fine

Screen Shot 2021-05-21 at 1 41 37 PM

Theme turned ON

Notice how variable declarations such as int or bool are just white, without any highlights

Screen Shot 2021-05-21 at 1 44 21 PM

Steps to reproduce

As I mentioned I am pretty new to Vim (and Vim plugins) so I am not sure what would be useful for you to trace the issue. Let me know if it'd be helpful if I shared my config files or anything like that.

rtunazzz commented 3 years ago

I went ahead and inspected the output of the :highlight command in Vim and I noticed that a few C/ C++ highlight definitions are cleared - for example Type, cppSTLfuntion, cCustomDot, cCustomPtr and a bunch of others.

Would be awesome if you could add those to the theme! 🤩

Screenshot from :highlight:

patstockwell commented 3 years ago

Done! 🎉

Thanks for raising an issue with some nice clear screen shot comparisons. To help me identify missing syntax groups I have a vim alias called :What. I have this in my .vimrc:

" `What` will print out the syntax group that the cursor is currently above.
" from https://www.reddit.com/r/vim/comments/6z4aau/how_to_stop_vim_from_autohighlighting_italics_in/
command! What echomsg synIDattr(synID(line('.'), col('.'), 1), 'name')

I opened a C++ file and placed my cursor over a int keyword and I got the highlight group cType. I've added a highlight for cType in vim-monokai-tasty. I used italic light blue to be consistent with the approach Sublime Text's implementation.

See these commits: e6816633a42ad652174af64944b7f42ba750e41f abb8e4f50ba2e7273a8cd1eb2e45427b0222f463

Before image

After Screen Shot 2021-05-27 at 11 30 47 am

Sublime (for comparison) Screen Shot 2021-05-27 at 11 31 04 am

Some of the other words in the file without any highlights simply return nothing when running :What. This tells me that vim hasn't identified that particular syntax with a highlight group, so we simply can't give them a colour.

If you are interested in getting even better colours, there might be C++ plugins out there that define match regex's to identify more accurate syntax groups. These plugins will have their own syntax group names that would allow you to apply even more highlights.

Thanks again for taking the time to make a git issue 🏅

rtunazzz commented 3 years ago

Hi! Thanks for taking the time to look into this & fixing it.

Love that you mentioned the What alias, very useful!

Some types are still missing (cppModifier, cppType - both are linked to Type which is cleared) but that's no big deal. I will try to figure it out myself and perpahs open a pull request at some point.

Either way, thank you for the awesome theme and thanks for the update! ⭐️