Options for creating an extension for a very simple language

So, in terms of theming/syntax highlighting you are out of luck without tree-sitter grammar.

If you ever decide to create a grammar, definately avoid the RegEx. That one is certainly dead and soon will be totally removed from Nova :coffin:. Would just be a waste of your time

However for autcompletion
It all depends. So the simplest, which might be very well fit for purpose for you, considering you managed to create a Syntax that recognizes the CoE5 is creating a Clips extension.

Option 1 Clips Extension:

  1. Head over to menubar > extensions > create new extension > Clips
  2. Now this will create a dummy Clips file
{
  "clips" : [
    {
      "content" : "$AUTHOR_NAME",
      "name" : "User Signature",
      "trigger" : "usersig"
    },
    {
      "name" : "Group Name",
      "children" : [
        {
          "content" : "console.log(${:message})",
          "name" : "Console Log",
          "scope" : "editor",
          "shortcut" : "cmd-alt-shift-l",
          "syntax" : "javascript",
          "trigger" : "log"
        }
      ]
    }
  ]
}

  1. I would say just add a Clips.json in the project you managed to get the syntax.xml working, and you will be good to go filling it up.
  2. You can see you can organise your syntax into groups
  3. Also set the "syntax" : "CoE5" so that in only shows in that file.

The only problem is that Clips is not documented at all :expressionless: However it is sort of self explanatory using the template. Just activate extension and play around in an HTML and JS file to get an idea. You can also head to sidebar to see the snippets, appearing in the clip under the extension tab. The snippet formating are documented here

image

Option 2 XML based Completion:

As you have managed to get Nova recognise the CoE5. You could simply create XML based completions. Now this one is a bit more involved.

  1. You would just need to worry about sorting
    • <syntax>
    • maybe <trigger>
    • <expression>
  2. Then write your static completion
  3. Request them using <set> in the <provider>

Problem with both approach:

I initially I thought you could have a flexibility with the XML based one, but I should say both are pretty similar if you do not use any grammar. What I mean by that is context aware completion. I thought you could maybe use Lookarounds in the <expression> for the XML completion and only provide values that are specific to a command. Unfortunately that is not supported. (I did not know that myself!)

//Example
init <nbr>
Initiative value for the weapon, default is 2. Some common
initiative values are these 1=spell, 2=fist/dagger/bow,
3=club/axe, 4=sword, 6=spear

For example only providing 1,2,3,4,5,6 as values for the init command. I personally dont see a way for you to restrict the values. Maybe you could just create snippets, and associate a name for them to fill for you. ie, init1 and it just expands to init 1 and so forth? I think Clips will be a better option with no grammar.

Tree-Sitter

This is a very simple command value syntax, with no injection no nothing. writing a tree-sitter for it would be a piece of cake. The only problem is the tree-sitter docs learning curve. I personally did not find it friendly at all when I was writing a grammar myself. lots of tears and pulling hair! but in your case it should be super easy! :+1:

There would be two benefits

  1. you can sort the syntax highlighting
  2. You can target a node and provide a completion just for that node! I played around with it and it for my project and it is very cool. You could just write a simple grammer that recognises command value.
  3. After that, all you have to do, is to name your nodes and then target them inside the <query> see docs, then filter the completions sets, provided based on the string value of the typed command using the predicates and captures! Now that would be cool eh? [:warning:rabbit hole warning :warning:] :eyes:

I hope that was helpful!
I personally would just keep the current working syntax.xml and add the Clips.json targeting CoE5, then see how you get on before going for anything overkill! good luck!

1 Like