diff --git a/.gitmodules b/.gitmodules index 99364ba6..3dcbc519 100644 --- a/.gitmodules +++ b/.gitmodules @@ -213,3 +213,6 @@ [submodule "assets/syntaxes/02_Extra/Zig"] path = assets/syntaxes/02_Extra/Zig url = https://github.com/ziglang/sublime-zig-language.git +[submodule "assets/syntaxes/02_Extra/gnuplot"] + path = assets/syntaxes/02_Extra/gnuplot + url = https://github.com/hesstobi/sublime_gnuplot diff --git a/assets/syntaxes/02_Extra/gnuplot b/assets/syntaxes/02_Extra/gnuplot new file mode 160000 index 00000000..04743470 --- /dev/null +++ b/assets/syntaxes/02_Extra/gnuplot @@ -0,0 +1 @@ +Subproject commit 04743470ff90237ba3fb34ccf77c2d256d611262 diff --git a/assets/syntaxes/02_Extra/gnuplot.sublime-syntax b/assets/syntaxes/02_Extra/gnuplot.sublime-syntax new file mode 100644 index 00000000..65ca5621 --- /dev/null +++ b/assets/syntaxes/02_Extra/gnuplot.sublime-syntax @@ -0,0 +1,182 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: gnuplot +file_extensions: + - gp + - gpl + - gnuplot + - gnu + - plot + - plt +scope: source.gnuplot +contexts: + main: + - include: number + - include: string_single + - include: string_double + - match: '\b(for)\b\s*(\[)' + comment: | + gnuplot iteration statement. + There are two forms: + numeric [n = 1:2{:inc}] + string based [str in "x y z"] + but both can also iterate over lists etc, so this is kept loose. + captures: + 1: keyword.other.iteration.gnuplot + 2: punctuation.definition.range.begin.gnuplot + push: + - meta_scope: meta.structure.iteration.gnuplot + - match: '\]' + captures: + 0: punctuation.definition.range.end.gnuplot + pop: true + - include: number + - include: operator + - include: string_double + - include: string_single + - match: ":" + scope: punctuation.separator.range.gnuplot + - match: '\b([a-zA-Z]\w*)\b\s*(=|in)' + scope: variable-assignment.range.gnuplot + - match: '(?i:[^\s(pi|e)\]])' + scope: invalid.illegal.expected-range-separator.gnuplot + - match: '\[' + comment: "gnuplot range statement [a:b]. Lots of things are legal, still more make no sense!" + captures: + 0: punctuation.definition.range.begin.gnuplot + push: + - meta_scope: meta.structure.range.gnuplot + - match: '\]' + captures: + 0: punctuation.definition.range.end.gnuplot + pop: true + - include: number + - include: operator + - match: ":" + scope: punctuation.separator.range.gnuplot + - match: '(?i:[^\s(pi|e)\]])' + scope: invalid.illegal.expected-range-separator.gnuplot + - match: \\. + scope: constant.character.escape.gnuplot + - match: '(?|>=|<|<=|&|&&|:|\||\|\||\+|-|\*|\.\*|/|\./|\\|\.\\|\^|\.\^)\s* + comment: Operator symbols + scope: keyword.operator.symbols.matlab + string_double: + - match: '"' + captures: + 0: punctuation.definition.string.begin.gnuplot + push: + - meta_scope: string.quoted.double.gnuplot + - match: '"' + captures: + 0: punctuation.definition.string.end.gnuplot + pop: true + - match: '\\[\$`"\\\n]' + scope: constant.character.escape.gnuplot + string_single: + - match: "'" + captures: + 0: punctuation.definition.string.begin.gnuplot + push: + - meta_scope: string.quoted.single.gnuplot + - match: "'" + captures: + 0: punctuation.definition.string.end.gnuplot + pop: true diff --git a/tests/syntax-tests/highlighted/gnuplot/test.gp b/tests/syntax-tests/highlighted/gnuplot/test.gp new file mode 100644 index 00000000..bb96f60d --- /dev/null +++ b/tests/syntax-tests/highlighted/gnuplot/test.gp @@ -0,0 +1,19 @@ +set terminal pngcairo enhanced +set output "/tmp/polynomial.png" + +set grid + +set xrange [-5:5] +set yrange [-5:10] + +set samples 10000 + +set key bottom right + +f(x) = 1.0 / 14.0 * ((x+4) * (x+1) * (x-1) * (x-3)) + 0.5 + +plot \ + f(x) title "polynomial of degree 4" \ + with lines \ + linewidth 2 \ + linetype rgb '#0077ff' diff --git a/tests/syntax-tests/source/gnuplot/test.gp b/tests/syntax-tests/source/gnuplot/test.gp new file mode 100644 index 00000000..411cf134 --- /dev/null +++ b/tests/syntax-tests/source/gnuplot/test.gp @@ -0,0 +1,19 @@ +set terminal pngcairo enhanced +set output "/tmp/polynomial.png" + +set grid + +set xrange [-5:5] +set yrange [-5:10] + +set samples 10000 + +set key bottom right + +f(x) = 1.0 / 14.0 * ((x+4) * (x+1) * (x-1) * (x-3)) + 0.5 + +plot \ + f(x) title "polynomial of degree 4" \ + with lines \ + linewidth 2 \ + linetype rgb '#0077ff'