Github Repository Source Identification Fix

I was annoyed that GitHub would detect my repo as having Go code in it, so I did some quick doc reading and modified the .gitattributes file to hint it in the right direction.

# Defold Files
*.atlas linguist-language=JSON5
*.collection linguist-language=JSON5
*.font linguist-language=JSON5
*.go linguist-language=JSON5
*.gui linguist-language=JSON5
*.tilemap linguist-language=JSON5
*.tilesource linguist-language=JSON5

Anything else I should add, I’m just adding them as I find them for now.

6 Likes

This would be a good candidate to add to all of the example projects.

You could add .script and .gui_script for Lua

4 Likes

Great idea! Worth noting that those are protobufs, not JSON.

2 Likes

Ahhh, they seem to be JSON5 compliant from what I could guess, will look to see if linguist supports protobuf.

So using Protocol-Buffer as the language looses the syntax highlighting that JSON5 had when viewing in github. :frowning:

  • cached, updated to Protocol-Buffer per linguist docs. Added some new mappings as well.
3 Likes

Probably something you could post as an issue about somewhere though I don’t know where.

.editor_script would be another Lua one.

Ah, this is great! Perhaps you could make a PR for this to one of our repos? I can then make sure to copy it to the rest.

1 Like

About this I mean about the lack of highlighting with linguist-language=Protocol-Buffer, I think this is where it needs to be addressed https://github.com/github/linguist/issues

1 Like

Ok, figured it out. Protocol-Buffer in linguist is for highlighting Protocol-Buffer files that conform to the language specification.

The files that Defold outputs are text encoded protocol buffer messages and can be translated using protoc --encode and protoc --decode accordingly.

I don’t know that there will ever be a syntax for the text format available, as it is not a language itself, but a data packet not too dissimilar from the binary format that Protocol Buffers would normally pass messages around with.

If I mark them as JSON5 I get syntax highlighting because of the unquoted key names, however, the comment in the format is # and does not highlight properly, as well as JSON5 expects a comma at the end of the line instead of a new-line, however this does not break the highlighter.

The trick here is that anything defined as “data” instead of a language, would not count against your stats, as data is not accumulated in github for a language score. So using JSON5 for now would get us halfway there, and unless someone creates a hiughlighter for text protobuf messages, nothing else really exists, and it would look like plain text.

Simply marking the types as ‘linguist-detectable=false’ is enough to remove them from the language stats, without attempting to pretty the output when viewed on github.

Thoughts?

1 Like
1 Like

re: PR I see two options depending on goals… The easiest one that solves the language detection problems.

# Defold Data
*.go linguist-detectable=false

# Defold GLSL Shaders
*.fp linguist-language=GLSL
*.vp linguist-language=GLSL

# Defold Lua Files
*.editor_script linguist-language=Lua
*.render_script linguist-language=Lua
*.script linguist-language=Lua
*.gui_script linguist-language=Lua

or this fully typed attributes file.

4 Likes

Going to be submitting a PR to github linguist for syntax highlighting real soon.

But first, might as well push out an extension for Visual Studio Code as well:
https://marketplace.visualstudio.com/items?itemName=thejustinwalsh.textproto-grammer

Add some file.associations to your .vscode/settings.json and you are in highlighted diff business.

"files.associations": {
    "*.script": "lua",
    "*.gui_script": "lua",
    "*.atlas": "textproto",
    "*.collection": "textproto",
    "*.font": "textproto",
    "*.go": "textproto",
    "*.gui": "textproto",
    "*.tilemap": "textproto",
   "*.tilesource": "textproto",
},
4 Likes

There’s already an extension that I’ve been using for this for a while:

https://marketplace.visualstudio.com/items?itemName=thesofakillers.vscode-pbtxt

With this config file: https://github.com/critique-gaming/crit-boilerplate/blob/master/.vscode/settings.json

6 Likes

I found that one right before I published. The grammar file wasn’t as complete as the effort I put into mine so I decided to push still. Going to be using this implementation for the PR as it supports highlighting and tokenization of everything I could discover in the wild.

3 Likes

textproto-grammer just got an update with a big PR from the community.
Better matching / highlighting, using match terminology as defined by import / export implementations in go. Working on some tests against more files found in the wild. Let me know how it goes for you, and please leave some feedback / bugs on github.

7 Likes