Needed: better symbolication options and API access to symbol index

I’m currently working on an extension for the fish shell scripting language. Syntax highlighting has hugely profited from Nova 4’s introduction of anchored subscopes, and I am pretty happy with the results. What I am less happy with is the state of symbolication in my scopes.

This has to do with the peculiarities of shell languages with their intricate take on escaping / unescaping. For instance, a\ 0 is the same symbol as "a 0", a' 0', or, for that matter ""''a' '""\060 (never mind the question who would write it like that – the point is the latter is valid syntax), and I haven’t even started talking about line continuations.

You can probably see where this is going: Nova indexes all of the above variations as different symbols, and the replacement facility in display name generation is nowhere flexible enough to unify them. Octal, hex and Unicode character escapes need to be replaced by the equivalent literal, but only outside quotes; quotes stripped, but only when they are not surrounding characters illegal as literals or considered escapes outside them; spurious backslashes removed, but significant ones retained; line continuations stripped unconditionally … Even with the full power of PCRE2 at my disposal, this is beyond what a single search and replace expression can do.

To complicate matters further, when completing, the symbol has to be escaped differently depending on the completion context, e.g. the above example would be inserted as a\ 0 outside quotes, but as a 0 inside quotes. To address this, Nova’s extension APIs are currently missing two things:

  1. A way to perform far more wide ranging manipulations on the symbols fed by syntax definition files into Nova’s index than is currently possible, so I could pass it a canonical form of the symbol instead of a raw match.
  2. An API for accessing Nova’s store of indexed symbols derived from the current document’s syntax definition, so I could write a dynamic CompletionProvider handling the different insertion situations.

As it stands, I can decide if I want my extension to provide a vastly sub-par symbolication (and concomitant symbol completion) feature or none at all … both of which I find very unsatisfactory, especially for an editor as slick as Nova is.

I’ll make notes of your request for our future feature considerations!

2 Likes

That would be great, thank you. Syntax support for fish is almost done, and it will be absolutely first class, if I may say so myself (I think I have used every feature the Nova syntax system offers bare one; thank you for introducing anchored subscopes and for using PCRE2 internally – both were life savers). It would be a pity if that had to be paired with sub-par autocompletion and symbolication for the duration.

1 Like