Overriding an Existing Syntax

Is it possible to extend or override an existing Panic syntax? I’m trying to fix a bug with the Ruby syntax where it doesn’t properly indent a method with a block. i.e.:

[1, 2, 3].each do |i|

I did manage to create a new extension with a renamed Syntax, where I managed to update the indentation rule to:

<expression>(^\s*(class|def|elsif|else|rescue|ensure|for|if|begin|with)\b.*$)|\bdo\b|(\{[^}\"']*$)|(\[[^\]\"']*$)|(\([^)\"']*$)</expression>

Now I’d like to be able to use it day-to-day without conflicting with the built-in extension. Is that possible?

1 Like

Overriding of built-in syntaxes is not supported. If you wouldn’t mind, please do file this bug in Nova’s help form (Get Help with Nova) and we can look into getting it fixed!

Thanks for the reply. Filed that bug report.

I would like to note that it would be really helpful if built-in syntax rules were exposed through extensions to allow developers to address short-comings. There are quirks and particulars that don’t seem well covered in Ruby in Nova (but are in VSCode, etc). While I trust that Panic might address them eventually in reality it’s easier for a developer to write up a quick fix through an extension rather than waiting for Panic to fix/correct things, if at all. Some examples:

  • in the Ruby language using is categorized as an identifier and not a core method
  • string interpolation with #{var} is not addressable in syntax styling and just considered as part of the string
  • A symbol in the form :@instance_var is styled as an instance var and not a symbol

If built-in syntaxes were extensible I could address these myself as some might be opinion based (like the last one). I do file bugs for things I catch, but others that are more opinion based I don’t bother submitting because honestly the Bug/Feature reporting seems like a bit of a blackhole.

Anyhow I really do like Nova and wish eventually it will meet all my needs. Appreciate all the work that’s been done up through Nova 6, here’s looking forward to 7, 8, 9 and on. Cheers

2 Likes

Having struggled with this exact issue for a syntax that is essentially an additive variant of an existing one (JavaScript), I definitely agree. Nova is halfway there to allowing this via template scopes; halfway only because this injects the extra scopes everywhere in the parent syntax, including into comments, strings etc. The other half, I think, would be a way to restrict scoping of template scopes to a context, e.g. via selectors similarly to how the context selector for completions work.

1 Like

@logan could you maybe consider allowing scope selectors for more granular injection of template scopes a feature request?

Overriding of built-in syntaxes is not supported.

So, does that mean it will never be possible to create custom code folding regions in Nova, because fold regions are defined in the language? After syntax highlighting, this is the most important thing an editor does for my use.

Actually, since this was originally posted, “not supported” changed from ”technically not possible” to “unsupported and undocumented”. You’ll find more details in this thread.