ydiff icon indicating copy to clipboard operation
ydiff copied to clipboard

Syntax highlighting

Open Valloric opened this issue 12 years ago • 6 comments

Thanks for creating this project! It's just what I was looking for and it's freaking awesome.

Any chance of getting syntax highlighting for the diff? I'm a big fan of Meld and it has syntax highlighting, but is overkill to bring up the whole GUI for smaller changes.

This wouldn't have to be complicated or anything; you could use the mimetypes module to detect the filetype and then do basic highlighting with pygments.

Having this feature would make cdiff truly perfect for my needs.

Valloric avatar Apr 12 '13 22:04 Valloric

Would this be possible given that cdiff only receives a diff and not a full file? For example, if the hunk contains Python code with """ in it, pygment's lexer can't know if that is the beginning or end of a multiline string.

myint avatar Apr 13 '13 02:04 myint

It wouldn't be perfect on some rare occasions, but it would be a net plus in most situations.

Valloric avatar Apr 13 '13 15:04 Valloric

Thanks for the idea, I will evaluate what does pygments ANSI sequence like, color schema of cdiff might need change completely.

On 2013-4-13, at 23:58, Val Markovic [email protected] wrote:

It wouldn't be perfect on some rare occasions, but it would be a net plus in most situations.

— Reply to this email directly or view it on GitHub.

ymattw avatar Apr 13 '13 23:04 ymattw

Hi, I've tried pygments command line for ansi color sequence effect, I'd rather not integrate with it as it will make cdiff much complex and I don't think I can do it perfect. Leave this open in case someone is interested to implement it. Thanks.

ymattw avatar Apr 28 '13 08:04 ymattw

Any branch avaliable? The thing is it should use the entire old and new file to render correctly

albfan avatar Mar 21 '19 11:03 albfan

+1 same problem , what if git diff comes with function context , most of the times when i use git diff i pass function context flag before passing it to ydiff . it may not be able to properly syntax higlight everyething , but language keywords and strings it does at least .

neerajbadlani avatar Aug 30 '19 15:08 neerajbadlani