Breaking change: as of v1 release August 2019, migrated MATLAB grammar source from TextMate to official MATLAB support mathworks/MATLAB-Language-grammar. This fixed many reported issues and improved MATLAB highlighting to match official github/linguist used on Github.com.
Octave grammar source remains unchanged.
Octave grammar is converted from TextMate Bundle and remains unchanged from v0 to v1. Last update was v0.2. See: https://github.com/textmate/matlab.tmbundle
The syntax highlighting comes from the MathWorks TextMate grammar: https://github.com/mathworks/MATLAB-Language-grammar
https://github.com/mathworks/MATLAB-Language-grammar/tree/40d9a0cd3b628f80cdcf948bbe1747a527ed5dd5
-
Clone, convert, and update the grammar:
git clone [email protected]:mathworks/MATLAB-Language-grammar.git apm init --package language-matlab-temp --convert MATLAB-Language-grammar/Matlab.tmbundle/ cp language-matlab-temp/grammars/matlab.cson language-matlab-octave/grammars/m.cson
-
Apply an Atom-specific patch to the file
language-matlab-octave/grammars/m.cson
:- Change
name: "meta.class.matlab"
toname: ""
. This prevents atom from improperly coloring all class contents.
- Change
-
Re-add function highlighting into updated
language-matlab-octave/grammars/m.cson
:- MATLAB-Language-grammar does not highlight MATLAB functions exactly like the TextMate grammar. If you view the diff of the newly generated
language-matlab-octave/grammars/m.cson
, you'll see the functions to add back. - For convenience, these are included as reference in
language-matlab-octave/grammars/functions-reference.cson
. Use this file to updatepatterns:
andrepository:
sections of the newm.cson
.
- MATLAB-Language-grammar does not highlight MATLAB functions exactly like the TextMate grammar. If you view the diff of the newly generated
See the MATLAB file highlighting-test.m
for MATLAB code snippets to test syntax highlighting changes. Supposing you've updated grammars/m.cson
you can test your changes by doing the following:
cd your-repo-clone
apm remove language-matlab-octave
apm link .
atom .
Open highlighting-test.m
and ensure that the syntax highlighting is as desired. If you fix something specific, consider adding a code snippet to that file locking down your change for future testing.