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', 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:
- 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.
- An API for accessing Nova’s store of indexed symbols derived from the current document’s syntax definition, so I could write a dynamic
CompletionProviderhandling 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.