Linguist: Support language highlighting on GitHub.com based upon Linguist overrides

Created on 29 Nov 2014  路  25Comments  路  Source: github/linguist

Currently the Linguist overrides only affect the language statistics and not the syntax highlighting. It would be good to allow these overrides to change the syntax highlighting behaviour also.

Emacs/Vim mode strings support would also be nice.

Related: https://github.com/github/linguist/issues/781 https://github.com/github/linguist/issues/875

Most helpful comment

Is this issue still being reviewed?

All 25 comments

Emacs/Vim mode strings support would also be nice.

PR in progress here: https://github.com/github/linguist/pull/2041

OK #2041 is in master now. We plan to cut a gem tomorrow.

@arfon Does this mean that the idea of overrides impacting highlighting is abandoned?

Yikes. Closed this by mistake. We'd still like to support the Linguist-style overrides.

Just want to add my support for this feature of allowing Linguist to set the syntax highlighting with .gitattributes (especially when working with custom extensions) :+1:

Yes please, this would be awesome.

:+1:

:+1:

:+1:

:+1:

:+1:

I think this is important, and good for github because it allows github to be used as a place to build and share technologies that are not yet mainstream (like JSX before it became popular). Can you update on the plan for this?

:+1: Sometimes people invent weird extensions for normal things (like "jpp" for a certain functional classification of "jsp").

+1

Is this issue still being reviewed?

Also interested in this.

This feature would be super useful, I'd love to see it implemented.

This would be really useful to have as adding vim modelines to every file is extremely inconvenient with a lot of files with a non-standard file extension.

It would additionally help if it was possible to associate a file extension with syntax highlighting but then not include that in the language statistics. Example use case: writing your own language similar to another language. You want the syntax highlighting but it isn't the same language so you don't want it changing your language statistics.

Good news peeps, this is now a thing that was shipped to all users just over a week ago.

Your language overrides should now be reflected in syntax highlighting of blobs and diffs as well as the language statistics.

All highlighting caches were flushed so you should be seeing your overrides taking place already. If not, pushing a new commit to your repository again should force a re-analysis (it may take a few minutes to appear as the refresh is a low-priority background job).

https://github.com/lildude/test-highlighting-override is an example illustrating this new behaviour. It contains a single ruby file containing ruby code but is then over-ridden by the .gitattributes giving us...

screen shot 2017-03-14 at 10 16 14

... confirming the statistics and ...

java-highlighting-on-ruby-files

... confirming the syntax highlighting override.

If you're not seeing this or are experiencing problems, please contact GitHub Support and they'll take a look at any repositories you're having problems with, but please ensure you've made at least a single commit and push to the affected repository since 7 Mar 2017 to be sure all data has been re-analysed.

I'll raise a PR to address the Linguist readme to reflect this now works.

Unfortunately this does not seem to work for marking Drupal *.module files as PHP, see https://github.com/klausi/github-lingiust-test . Can you also enable PHP as language that can be set in .gitattributes?

Holy crap.

Colour me a happy bastard.

@klausi Hrm, that's odd. Perhaps push a change to a .module file? The .gitattributes thingie was set after the file was uploaded, it might need a cache-bust.

@Alhadis Indeed, thanks! So that means you need to touch each and every file in a git commit so that the new syntax highlighting takes effect?

Well, that was actually a half-educated guess, haha. I don't know the actual mechanics going on behind the scenes, but I know that changes to Linguist won't retroactively affect every file that's already been indexed and cached. =)

For instance, this repository hasn't been updated in over 3 years, and it's still being classified as Perl (despite the actual language breakdown being very different).

I think it's safe to say many other mechanisms are handled the same way across the site.

Wow

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Alhadis picture Alhadis  路  5Comments

BnSalahFahmi picture BnSalahFahmi  路  3Comments

oldmud0 picture oldmud0  路  6Comments

haskellcamargo picture haskellcamargo  路  3Comments

Sanchez3 picture Sanchez3  路  4Comments