cylc / cylc-flow

Cylc: a workflow engine for cycling systems.
https://cylc.github.io
GNU General Public License v3.0
329 stars 93 forks source link

Syntax Files #2752

Open oliver-sanders opened 6 years ago

oliver-sanders commented 6 years ago

Provide lexers for the Cylc suite definition syntax in different editors / systems.

Currently supported:

Planned support:

A few major editors support the TextMate grammar format:

Dropped support:

Feature support table:

:ok: - Full Support :no_entry: - Not Supported :partly_sunny: - Partial Support

Feature Example vi emacs gedit kate pygments
1. Basic INI/Cylc Syntax
1.1 Sections / Settings [a]b=c :partly_sunny: [3] :partly_sunny: [5, 6] :partly_sunny: [5] :partly_sunny: [5] :ok:
1.2 Comments a=c # c :ok: :ok: :ok: :ok: :ok:
1.3 Multiline Str """ ... :ok: :ok: :ok: :ok: :ok:
1.4 Include Files %include :partly_sunny: [1] :no_entry: :partly_sunny: [8] :no_entry: :ok:
2. Exotic Cylc Syntax
2.1 Graph tasks + deps foo, => :no_entry: [14] :ok: [12] :partly_sunny: [9] :ok: :ok:
2.2 Graph Comments foo # Foo :ok: :ok: :ok: :ok: :ok:
2.3 Graph operators &, (), ! :no_entry: :no_entry: :ok: :partly_sunny: :ok:
2.4 Inter-Suite <a.b::c> :no_entry: :no_entry: :no_entry: :no_entry: :ok:
2.5 xtriggers @wall_clock :no_entry: :no_entry: :no_entry: :no_entry: :ok:
2.6 Parameter <x> :no_entry: :no_entry: :no_entry: :no_entry: :ok:
2.7 Parameter <x-1> :no_entry: :no_entry: :ok: :no_entry: :ok:
2.8 Parameter <x=1> :no_entry: :no_entry: :ok: :no_entry: :ok:
2.9 Qualifier a:fail :partly_sunny: [2] :no_entry: :no_entry: :no_entry: :ok:
2.10 Inter-cycle a[-P1D] :ok: :ok: :no_entry: :no_entry: :partly_sunny: [13]
3. Templating
3.1 Shebang #!... :ok: :no_entry: :ok: :ok: :ok:
3.2 Jinja2 {%, {{, {# :ok: :ok: [7] :partly_sunny: [11] :ok: :ok:
3.3 Jinja2 Multiline {% \n %} :ok: :ok: :ok: :no_entry: :ok:
3.4 empy (basic) @X, @(, @[ :partly_sunny: [4] :no_entry: :no_entry: :no_entry: :ok:
3.5 empy (full) @?, @!, @... :no_entry: :no_entry: :no_entry: :no_entry: :no_entry:

[1] Can't handle quoted file names. [2] Problem with custom qualifiers containing underscores [3] Equals characters in setting values breaks highlighting [4] Parenthesis in expressions can cause issues [5] Comments after sections break highlighting [6] => symbols are highlighted outside of graph strings [7] Cylc comments following Jinja2 blocks don't display as comments[Second observer: I don't see this issue?] [8] Unquoted files aren't highlighted [9] foo=>bar displays incorrectly [10] Suicide triggers not highlighted [11] Jinja2 comments not displayed as comments [12] => highlighted, & tasks appear in the same mode as e.g. standard values under sections but that seems appropriate? [13] Arbitrary whitespace not supported in arthymatic (e.g. [^+P1D] is fine but [^ + P1D] is not). [14] => acknowledged in triple-, but not single-, quoted graph strings.

Please update the table as syntax capabilities change.

sadielbartholomew commented 6 years ago

I volunteer myself as emacs rep! In the interests of achieving equality between the two most common editors, I am adding addressing Jinja2 Multiline (first & foremost) & EmPy to my To Do list.

(Oh & +1 for creative emoji use.)

hjoliver commented 6 years ago

@sadielbartholomew - I was an emacs user once, and then ... image

hjoliver commented 6 years ago

(apologies :sheep:-ish :grin:)

sadielbartholomew commented 6 years ago

That made me 'laugh out loud', though I don't think I will be having such a revelatory moment (with vim certainly... maybe with Atom)!

hjoliver commented 6 years ago

To be fair it did take me a little while to see the light!

oliver-sanders commented 6 years ago

IDEs aside the top text editors from the StackOverflow survey:

sadielbartholomew commented 6 years ago

...okay so I was completely wrong about emacs & vim being the two dominant editors (I got this impression but admittedly never thought to investigate)! Those are interesting stats indeed.

hjoliver commented 6 years ago

There's also MS Visual Studio Code, a standalone code editor built on electron. It's pretty slick and has a pretty comprehensive vim emulation mode. I tried it a while ago, but I felt a bit "dirty", and I still like the lightness of vim.

https://en.wikipedia.org/wiki/Visual_Studio_Code

matthewrmshin commented 6 years ago

I have also tried VSCode recently (on my home Windows box and an Ubuntu VM). It is pretty good. Not sure if I can actually use it for real productivity work or not.

oliver-sanders commented 6 years ago

Added to the list, I thought it was an IDE (been a while since I used visual studio).

TomekTrzeciak commented 6 years ago

I've come across EmPy highlighting for Atom, maybe it will be useful: https://github.com/dirk-thomas/language-empy

sadielbartholomew commented 5 years ago

(Updated main table in leading comment to reflect emacs mode update from merge of #2784.)

wxtim commented 4 years ago

n.b. I have started playing with with textMate for VSCode, and have got the basic bits working.

edmundhenley commented 4 years ago

Tim, as (now!) a VSCode user, who's just been hunting around a bit re options for rose/cylc, give me a shout if extra (noob-level) support on looking into textMate/being pilot user/reviewing docs/other helpful! (have seen Oliver's recommendation elsewhere that one can ~use ini syntax rules for rose).

MetRonnie commented 4 years ago

Just to announce I've picked up on Tim's TextMate grammar for VSCode, should be ready to go in a few days time. As discussed in the last couple of Metomi video meetings, we'll need to figure out how we're going to host it, GitHub-repo-wise, considering it'll also be ported over to Atom

MetRonnie commented 4 years ago

The VSCode/TextMate grammar is in an almost deliverable state.

Feature Example VSCode/TextMate
1. Basic INI/Cylc Syntax
1.1 Sections / Settings [a]b=c :ok:
1.2 Comments a=c # c :ok:
1.3 Multiline Str """ ... :ok:
1.4 Include Files %include :ok:
2. Exotic Cylc Syntax
2.1 Graph tasks + deps foo, => :ok:
2.2 Graph Comments foo # Foo :ok:
2.3 Graph operators &, (), ! :ok:
2.4 Inter-Suite <a.b::c> :ok:
2.5 xtriggers @wall_clock :ok:
2.6 Parameter <x> :ok:
2.7 Parameter <x-1> :ok:
2.8 Parameter <x=1> :ok:
2.9 Qualifier a:fail :ok:
2.10 Inter-cycle a[-P1D] :ok:
3. Templating
3.1 Shebang #!... :no_entry:
3.2 Jinja2 {%, {{, {# :ok: [1,2]
3.3 Jinja2 Multiline {% \n %} :ok: [1,2]
3.4 empy (basic) @X, @(, @[ :no_entry:
3.5 empy (full) @?, @!, @... :no_entry:
4. Extra
4.1 Cylc8 graph Syntax [[graph]]R1=... :ok:
4.2 Shell script script = echo "foo" :no_entry:
5. ISO 8601
5.1 Intervals P1Y1M1DT1H1M1S :ok:
5.2 Datetime long 2000-01-01T00:00:00-11:30 :ok:
5.2 Datetime short 20051201T0215+0530 :ok:
5.3 Illegal intervals P1D1Y, P1H :partly_sunny:
5.4 Illegal Datetime 2000-01-01T0000 :partly_sunny:

[1] Enabled even if #!Jinja2 shebang not present [2] Jinja2 content all uniform (no further highlighting within Jinja2 blocks) Can be used with a 3rd-party Jinja2 extension to provide Jinja2 highlighting inside cylc files

I've done it using a JavaScript file that can get 'compiled' to the JSON grammar file (used by VSCode and Atom). This makes it easier to reuse things when you have several similar rules.

The question is, how are we going to host it? I think we'll need separate repos for the VSCode and Atom versions of the grammar. How about an independent main repo for just the core TextMate grammar files (js, JSON and build scripts)? The VSCode and Atom repos could be modified clones and get merged into from the main repo, for new releases?

In any case, we could create the VSCode repo for now - should I create an empty repo then do a PR with all the commits so far?

oliver-sanders commented 4 years ago

The grammar ( and entire vscode plugin) are static so this isn’t really the domain of package managers like npm.

I think this might just be the kind of problem git Submodules we’re created to solve.

We would - Create a repo with the text mate extension in and a bunch of other repos for vscode, atom, heck maybe even textmate itself which use the same git Submodule.

Thoughts?

MetRonnie commented 4 years ago

I hadn't heard of submodules before but that looks promising

MetRonnie commented 4 years ago

Here is my VSCode repo for now. The Jinja2 support is currently in a separate branch to master

wxtim commented 4 years ago

I had a go at opening about 6 suites randomly picked from <site users path>/*/cylc-run/*/suite.rc when and they all looked Good. Tried it with one (I'll tell you which on a private channel) which I picked out as likely to push the envelope, and there are some crispy bits of jinja2 around the edges, but by-and-large it was ok.

hjoliver commented 4 years ago

Note our syntax support is far from perfect for any editor (I still use Vim mostly) so I woudn't worry too much about "the crispy bits" (nicely put @wxtim :grin: )

oliver-sanders commented 4 years ago

Agreed, just document the deficiencies in the table above, this is something we may get people in the Cylc community working on.

MetRonnie commented 4 years ago

(Posting here in addition to Discourse)

The extension for VSCode has been released: Visual Studio Marketplace; GitHub repo

Plus TextMate bundle for TextMate, PyCharm, WebStorm & Sublime Text 3: GitHub repo

Update: the package for Atom has been released: https://atom.io/packages/language-cylc