Adding syntax coloring for custom file type (v 1.8.0)


Installed packages:

  • language-json
  • json-colorer

I’ve got a “.duf” file type that uses JSON formatting, I’ve tried adjusting my config.cson to the following:

      "source.json": [

but my .duf files do not use any syntax highlighting.

Even took my .duf file and renamed it to .JSON and still no luck getting the syntax highlighting to work. Bottom right of window shows ‘JSON’ for the file’s language, and still no dice.

Any ideas what I’m doing wrong?


I haven’t been able to replicate this. Are your regular JSON files appropriately colored? Can you share the contents of the .duf file?


Here’s a dropbox link to the file ( its a lot to paste here )

So a few more things to note:

I tried uninstalling the json-colorer package from within Atom’s settings and it told me it couldn’t uninstall, something about file not being found. This prompted me to install json-colorer via command line. I verified that the folder was present inside ~/.atom/packages.

Also installed colorful-json package via apm.

Opened a different .duf file inside Atom and the syntax highlighting worked, however, the original file in question ( linked above ) still does not have any syntax coloring. I even tried moving it into another folder for sh*ts and giggles. ( screenshot of .duf w/ problem ) ( screenshot of problematic .duf renamed to .json ) ( screenshot of .duf that works with the .json highlighting )

totally boggled here!


You’re not crazy. Mat_Maybe.duf shows up uncolored for me, even though the grammar was set as JSON. However, when I copy and paste the file into my test.duf file which was being colored correctly, I see the appropriate coloration. So it works, just not for that one file. Maybe Atom has an issue with opening a file that’s nearly 100k lines? It takes a little while to color all those lines in the second file, but it works in the end.

I believe this is because the files on disc were deleted before the program was made aware of it. Atom has some quirky behavior surrounding package installation/updates/removal, and much of the time when an error crops up, just reloading the Atom window is sufficient to resolve it.


Well It’s good to know I’m not crazy :slight_smile: Didn’t consider the file size could cause an issue. Knowing that, I feel we perhaps uncovered a bug or limitation in the software.

I opened another file that is similar to Mat_Maybe.duf and it has 72k lines, no JSON coloring, even with grammar set to JSON. Seems there is a line limit when it comes to doing syntax coloring. Somewhere in above 48k lines, but below 72k lines, the syntax stops working.

edit - if the file already has syntax coloring and you add more lines, it keeps the syntax coloring. However, opening a file that is already > ~48k lines doesn’t process the syntax coloring.


This is perhaps associated with some limitations present to keep performance up at the cost of looks when processing a lot of information. However, I’m not sure exactly how. There’s an issue about the token limit, and this comment verifies that your specific problem has existed for a while. However, looking at the Atom and First Mate sources, I’m not sure where it’s breaking. 99k lines doesn’t turn off the parser, because it works if you paste the data into a file that has already been highlighted. It’s not that Atom doesn’t select a grammar for it, and if you delete most of the file, it still refuses to parse. These behaviors don’t align in pointing to a particular culprit.


This is a known issue: