Github Repository Source Identification Fix

#1

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

#2

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

#3

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

1 Like

#4

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

0 Likes

#5

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

0 Likes

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

#7

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

.editor_script would be another Lua one.

0 Likes

#8

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

#9

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

#10

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

#11
1 Like

#12

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

#13

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

#14

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

#15

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