Hacker News new | ask | show | jobs
by Jeaye 4096 days ago
After looking, I'm astonished that this doesn't exist in Emacs. There is a completion plugin using libclang; maybe the highlighting could just be added into it.

On vim's side, YouCompleteMe explicitly denied my approach to integrate highlighting.

3 comments

I hacked together something to add at least #ifdef highlighting* to YouCompleteMe. It's not quite ready to share due to some bugs, but I'm planning to release it as a patch / friendly fork when I find some time.

I believe there's no reason to have two plugins each running an instance of clang.

* i.e. showing parts of code that are ifdef'ed out in grey

it would be nice if it could hook into YCM's config file instead of needing a separate one, when available.
Yeah, that's something I considered from the start. The issue is that, in order for that to work reliably, color_coded would basically need an embedded Python interpreter.

YCM's config file can contain arbitrary python functions and doesn't really need to follow any standards. This makes it hard on color_coded and ultimately didn't seem worth the trouble.

Have you got a plain text version of the highlighted source examples somewhere? I want to compare it with emacs' default highlighting (I think default emacs highlights almost as much as the "After color_coded" screen shot).
The first picture is from the color_coded source itself:

https://github.com/jeaye/color_coded/blob/master/include/asy...

The second picture is from my C++14 JSON library:

https://github.com/jeaye/jeayeson/blob/master/include/jeayes...

Thanks, for anyone curious here's what emacs does with the first example:

http://imgur.com/Rddi9QH

compare with color_coded: https://camo.githubusercontent.com/5cf719c6357f27b86c45bf9b5...

So it looks like color_coded can highlight at least a few things that default emacs doesn't: function calls, variables (when they are used, both can highlight declarations) and non-standard type template parameters.

I don't see real-time semantic highlighting using an embedded compiler there. Maybe I missed it.
My bad, I assumed it included highlighting, but it appears it is just auto-complete from Clang.

https://github.com/brianjcj/auto-complete-clang

That being said, if the core infrastructure is there, the hard part (Clang backend) is there, how much more can semantic highlighting be?

(I duck because I write amateurish code and do not do C/C++ yet, but would hopefully learn to do something awesome like that one day.)