Syntax Detectors - Filename detection by regex

Various system files follow patterns where the extension represents purpose rather than the name with a static extension, i.e. Jenkinsfile.prod, Dockerfile.nginx

Similar circumstances define patterns for a filename rather than a fixed string.

It is currently not possible to reliably detect these cases within Nova. (Matching content is too circumstantial)

To work around this, some editors allow for detection using pattern matching for the filename and extension. It would be very helpful if Nova had something similar.

Let me see, so, basically, what you’d need is a way to use regexps on the <detectors> field of the language syntax, e.g. instead of, say, the static extensions in the examples below:

	<detectors>
		<extension priority="1.0">lsl,ossl</extension>
		<match-content lines="5" priority="1.0">^(//)?\s*vi:\s*(syntax|ft)=(lsl|Linden Scripting Language)\b</match-content>
	</detectors>

where two extensions are statically defined, e.g. lsl and ossl, you’d want something like:

	<detectors>
		<extension priority="1.0">[l|os]sl</extension>
		<match-content lines="5" priority="1.0">^(//)?\s*vi:\s*(syntax|ft)=(lsl|Linden Scripting Language)\b</match-content>
	</detectors>

i.e. where a pattern can be matched at the extension level and thus be able to capture many more possible variants than just simply enumerating those that are supported by a specific syntax?

It sounds like something Panic could develop, but… I’m not quite sure I understand what exactly you’re looking for. Let’s start with your examples: Jenkinsfile.prod and Dockerfile.nginx. One might assume that Jenkinsfile.prod would be used by a Jenkins extension — so that case would be easy to deal with — while Dockerfile.nginx… could either be read by an extension for Docker files or one for nginx configuration files… which one are you specifying? By default, one might assume that the extension will reveal the kind of file it is, and thus presume what format it’s written in.

However, I might understand the need for having two extensions, one that reads Docker files specifically for nginx, the other specifically for Apache, and, as such, at some point in the code, Nova would have to decide which would be the appropriate syntax file to load. Instead, you propose that such ‘decision’ would not be in the hands if the extension developer, but rather on the ‘client’ side of things, who would be responsible for selecting which extension should be called depending on their name — and thus, since no such syntax/extension currently exists, there is no obvious way to let the user decide what files ought to be opened by each extension.

Note that besides extension & content. you can also use just match the filename, and, although I haven’t tested it out (yet!.. ), I believe you can add all sorts of regexps to that whole pattern-matching field. But I’m not quite sure of what exactly you have in mind…

I have little experience with ‘other editors’, so to speak, so I wonder what exactly you’re describing.