How can I define a selector in the build system with the custom extension (like *.ltx
, *.cmake
etc) for which there is no available selector (like text.tex.latex
, source.c++
etc)?
Is it possible? If yes - how?
How can I define a selector in the build system with the custom extension (like *.ltx
, *.cmake
etc) for which there is no available selector (like text.tex.latex
, source.c++
etc)?
Is it possible? If yes - how?
It's possible, if you define a new syntax definition (i.e., a new .tmLanguage file). Syntax definitions can declare new 'scope names' which you can then use in your new, custom build systems.
The new syntax definition file doesn't actually have to define/match the file's syntax, as you can simply match by file extension...!
Take a look here at the .tmLanguage file syntax. The "scopeName" item allows you to name your new scope (i.e., "text.tex.latex", etc.). I'll go through an example below.
I created a new syntax which defined a new scope -- it was quite easy (like most things in Sublime):
... replace "Syntax Name" with a descriptive name, "source.syntax_name" with your new scope name, and fill in "fileTypes" to contain one or more file extensions. For instance:
"fileTypes": ["tex", "ltx"]
You're done! Any new files which happen to have one of the extensions defined in "fileTypes" will activate the "scopeName" scope.
You can now use this scope in a new Build System file (Tools > Build System > New Build System...)
Cheers!