Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github does not highlight Nix anymore #5109

Closed
domenkozar opened this issue Nov 24, 2014 · 22 comments
Closed

Github does not highlight Nix anymore #5109

domenkozar opened this issue Nov 24, 2014 · 22 comments

Comments

@domenkozar
Copy link
Member

Sigh. I spent time on pygments to get Nix support, waited few months and now finally.. It's gone.

Apparently Github uses TextMate now.

cc @aroben

@vcunat
Copy link
Member

vcunat commented Nov 24, 2014

Oh, that's unlucky!

@aroben
Copy link

aroben commented Nov 24, 2014

Sorry about that! Do you know of any TextMate/Sublime Text/Atom grammars for Nix? It doesn't look like it would be too hard to translate the Pygments lexer if not. I'm happy to help if you go that route.

@domenkozar
Copy link
Member Author

Unfortunately not. @aroben we'd love to get Nix support back into github. Are there any docs how to write grammar for TextMate/Sublime/Atom?

@wmertens
Copy link
Contributor

I took a first stab at Sublime yesterday, and below is the YAML I have so
far.

Terrible Sublime docs are here:
http://docs.sublimetext.info/en/latest/extensibility/syntaxdefs.html

Better Textmate docs:
http://manual.macromates.com/en/language_grammars

Work in progress, but it already works a bit. Would like a BNF to syntax
convertor, I'm looking at https://code.google.com/p/autohighlight/.

[PackageDev] target_format: plist, ext: tmLanguage


name: Nix
scopeName: source.nix
fileTypes: [ "nix" ]
uuid: 0514fd5f-acb6-436d-b42c-7643e6d36c8f

patterns:

- match: "\b[a-zA-Z_][a-zA-Z0-9_'-]*"

name: "id.nix"

  • name: "comment.nix"
    begin: "/_"
    end: "_/"
  • name: "comment.nix"
    match: "#.*"
  • name: "string.multi.nix"
    begin: "''"
    end: "''"
  • name: "string.single.nix"
    match: ""[^\"]*""
  • name: "string.url.nix"
    match: "[a-zA-Z0-9._-+]*(/[a-zA-Z0-9._-+]+)+"
  • name: "keyword.operator.nix"
    match:
    "(.|!|-|==|!=|<|<=|>|>=|&&||||->|//|?|+|-|*|/|++|:|=|;)"
  • name: "keyword.other.nix"
    match: "\b(or|let|in|if|then|else|rec|inherit|import)\b"

On Tue Nov 25 2014 at 2:26:43 PM Domen Kožar notifications@github.com
wrote:

Unfortunately not. @aroben https://github.com/aroben we'd love to get
Nix support back into github. Are there any docs how to write grammar for
TextMate/Sublime/Atom?


Reply to this email directly or view it on GitHub
#5109 (comment).

@aroben
Copy link

aroben commented Nov 25, 2014

Yep, those are the right docs. Your grammar looks like a good start!

@wmertens
Copy link
Contributor

Ok here's a decent grammar: https://gist.github.com/wmertens/9f0f1db0e91bc5e3e430 (in the SublimeText YAML-tmLanguage format, I can make it CSON or whatever).

@aroben how would I go about getting that into the github highlighting?

@domenkozar
Copy link
Member Author

Nice! Hopefuly @aroben can help us get back on track

@wmertens
Copy link
Contributor

wmertens commented Dec 1, 2014

TextMate format is at https://gist.github.com/wmertens/ee3da82fd179549875ac

Tested it with the .nix files in the tests for Nix and with a bunch of nixpkgs files. It absorbs everything and marks illegal things as illegal. (unfortunately it's not 100% a parser because regex highlighting is not a proper state machine).

@aroben
Copy link

aroben commented Dec 1, 2014

Nice! It might be good to do some quick tests with GitHub's highlighter too at https://lightshow.githubapp.com. It doesn't accept YAML grammars currently; I'll look into adding that.

Once you're satisfied with your grammar, stick it in a GitHub repo with an appropriate license and follow step 2 of https://github.com/github/linguist/blob/master/CONTRIBUTING.md#i-want-to-add-support-for-the-x-programming-language and open a PR. Or ping me and I'll be happy to add it for you.

@aroben
Copy link

aroben commented Dec 1, 2014

It doesn't accept YAML grammars currently; I'll look into adding that.

YAML grammars can now be used directly with Lightshow.

@wmertens
Copy link
Contributor

wmertens commented Dec 1, 2014

Impressive turnaround time @aroben 🍻! I opened github-linguist/linguist#1802.

@wmertens
Copy link
Contributor

wmertens commented Dec 1, 2014

Alright, the grammar got accepted into the github highlighter, it should take no more than 2 weeks for the change to become visible.

Here's an example of what to expect.

@iElectric ok to close or should we keep it open as a reminder?

@domenkozar
Copy link
Member Author

Thanks! 🍻 Let's wait until the changes are in place.

@aroben
Copy link

aroben commented Dec 2, 2014

Highlighting should be working now.

@vcunat
Copy link
Member

vcunat commented Dec 2, 2014

Yes, I can see it in the web-editor. However, I see no highlighting in regular file view, e.g. https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/all-packages.nix (but I do so e.g. for xml).

@wmertens
Copy link
Contributor

wmertens commented Dec 2, 2014

@vcunat it works 😁 https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/make-tarball.nix

all-packages is just too gigantic... it also gets cut off in search results. We should split it up in a bunch of files.

@wmertens
Copy link
Contributor

wmertens commented Dec 2, 2014

@vcunat @aroben then again, https://github.com/NixOS/nixpkgs/blob/master/default.nix doesn't get highlighted and that's tiny...

@vcunat
Copy link
Member

vcunat commented Dec 2, 2014

@wmertens
Copy link
Contributor

wmertens commented Dec 3, 2014

@aroben another question, the online editor seems to be using the old highlighter, any way to update that? It has problems with complex embedded strings.

@aroben
Copy link

aroben commented Dec 3, 2014

then again, https://github.com/NixOS/nixpkgs/blob/master/default.nix doesn't get highlighted and that's tiny...

Looks like we forgot to invalidate some caches. That should be fixed now.

the online editor seems to be using the old highlighter, any way to update that? It has problems with complex embedded strings.

We're looking into making the editor use the same grammars as the rest of the site. Thanks for pointing it out.

@domenkozar
Copy link
Member Author

Thank you all, this is fixed :)

@offlinehacker
Copy link
Contributor

Nice :)
On Dec 3, 2014 5:26 PM, "Domen Kožar" notifications@github.com wrote:

Closed #5109 #5109.


Reply to this email directly or view it on GitHub
#5109 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants