Sublime Forum

Build selector question

#1

I like the build system for coffeescript, less, etc. but my googlefu failed me when learning how to target a selector by file name instead of extension. Lots of SO answers and example build blog posts assume “selector”: “package.json” would work, but they don’t (I’m assuming because of the lack of the “source” string). Mainly, the examples half work, in that they set a “working_dir” which operates from the project folder, and ignores the automatic “selector” functionality.

Am I overlooking how to select on a file name?

I’d love to be able to use { "cmd": "node", "$file" ], "selector": "app.js" }
and

{
	"cmd":  "npm install" ],
	"selector": "package.json"
}

without accidentally trying to build “other.js” or “random.json”

0 Likes

#2

selector is a scope name. It’s not a file name. nor a file extension.

I think there’s a plugin somewhere to build based on file extension, but couldn’t remember where.
It’s probably not something very difficult to write by yourself.

Build system use the scope name where the (first?) caret of the current active view is located.
To find this information, open the console and type the command below, the result here is for a json file:

>>> view.scope_name(view.sel()[0].a) u'source.json meta.structure.dictionary.json punctuation.definition.dictionary.begin.json '
Usually we use the global scope name, which is the first part of this string:

source.json
0 Likes