A tree-sitter grammar for gnuplot 6.x.
Supports .gnuplot, .gp, .plt, .plot, .gnu files. Built with an external
scanner for command disambiguation, comprehensive syntax highlighting queries, and
275 corpus tests.
This project is the next evolution of gnuplot.vim, designed for accuracy to gnuplot 6 syntax and long-term maintainability.
Node type names and field names are the query API: highlights.scm, editor
plugins and language servers match on them, and a change that leaves the schema
valid can still make an existing query match nothing. Such changes are released
as breaking.
Function plots bind their expression to the function field of plot_element.
Earlier releases bound it to data, which is now used only for datafile and
datablock sources, so a query written as (plot_element data: (function ...))
must become (plot_element function: (function ...)). Both fields already
existed, so node-types.json remains backward compatible — only which field the
parser populates changed.
The ! shell form now stores the whole logical line in
(cmd_system (shell_command)), replacing its former expression children
(identifier, string_literal, etc.). This requires a breaking release for
consumers of that tree shape. The system <expression> form keeps its tree.
Backquotes are opaque command_substitution nodes in expressions and
double-quoted strings; single-quoted strings keep them literal. Both these
substitutions and shell_command inject their shell text as Bash. The parser
does not expand shell output into generated commands or keywords.
Computed expressions (sin(x)*exp(-x), numbers, ternaries, sums, parenthesized
forms) moved from data to function as well. data keeps string literals,
datablocks, bare variable references and top-level . string concatenation.