Bitwise » Forums » Provisional Ion syntax highlighting in Sublime Text 3
Jorge A. Gomes
1 posts
#15084 Provisional Ion syntax highlighting in Sublime Text 3
3 weeks, 3 days ago Edited by Jorge A. Gomes on April 26, 2018, 3:11 a.m. Reason: Initial post

I've been playing around with sublime-syntax files in attempt to get Ion syntax highlighting working by using as template this C.syntax-definition. The bad news is that I didn't figured out how the file works (yet). The good news is that, with some minor changes, it is possible to get large Ion syntax coverage.

What was changed?
Basically 3 things:
1st, At the top of the file:
name: C
  - c
  - h

changed to
name: Ion
  - ion

2nd, the key 'basic_types' under 'variables', in line 11:
basic_types: 'asm|__asm__|auto|bool|_Bool|char|_Complex|double|float|_Imaginary|int|long|short|signed|unsigned|void'

changed to include all ion basic types (the example below requires verification):
basic_types: 'bool|char|schar|uchar|double|float|int|uint|uintptr||long|ulong|llong|ullong|short|ushort|signed|unsigned|void'

And 3rd, every scope name terminated in .c got replaced by .ion. Example:
- match: ^/\* =(\s*.*?)\s*= \*/$\n?
   scope: comment.block.c
     1: meta.toc-list.banner.block.c

- match: ^/\* =(\s*.*?)\s*= \*/$\n?
   scope: comment.block.ion
     1: meta.toc-list.banner.block.ion

To add this definition in ST, you must:
1. Install the Sublime Text package PackageDev;
2. After installation, click on "New Syntax Definition..." under Tools>Packages>PackageDevelopment menu;
3. A new template syntax will be created, but you can replace its contents with the C.sublime-syntax file contents (change it as above);
4. Save it and enjoy.

P.S.: Sorry for any bad english in the text.
Steve Tranby
15 posts

Code Monkey

#15085 Provisional Ion syntax highlighting in Sublime Text 3
3 weeks, 3 days ago Edited by Steve Tranby on April 27, 2018, 6:05 p.m.

Here's my current "work-in-progress" ST3 syntax definition. I referenced the Odin language syntax YAML definition so it's probably a bit more verbose than it needs to be.

Ion Syntax Definition

I'll try to update my gist to add anything missing from the latest syntax additions, along with a few things you added that I haven't yet. It may even become more concise as I continue learning the syntax definition structure. I may also similarly break out the c/cpp/odin/etc full language package to look into adding other functionality beyond syntax highlighting. Also, the tangential functionality such as build system config.

I also just added it into my `~/Library/Application Support/Sublime Text 3/Packages/User` directory, but the PackageDev is probably the smarter approach.

Feel free to post your full definition for easier test/use.

I've updated mine to a point where I'm satisfied for my preferences. For me the other two aren't as complete or asthetic (as of Apr 27 2018), but that's a personal preference obviously. Mine could be improved, no doubt. It also makes a difference which color scheme you're using, of course. Lastly, sometimes syntax highlighting can get in the way and if you revert back to a no-highlighting 2-color (fg/bg) scheme sometimes that's better. YMMV as always.

I'll change this here whenever I commit a new revision:

(Last Updated: Fri Apr 27 17:38:29 2018 UTC)

I see 0xdeadc0de everywhere
2 posts
#15086 Provisional Ion syntax highlighting in Sublime Text 3
3 weeks, 3 days ago

I did already make one it's up on github.
Works with sublime/textmate/vscode (vs apparently through bundle)