2

I am working with Sublime and also running some q/kdb scripts from Sublime. I have a "q Build" set up and works fine when I manually change the build. But I tend to switch between q and other languages quiet often and each time I need to manually change the build type.

How can I setup all *.q files to be run automatically with the q build setup I already have only by doing the usual Command + B?

{
"cmd": ["[full q path]", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.q",

}
Thomas Smyth - Treliant
  • 4,993
  • 6
  • 25
  • 36
Alim Hasanov
  • 197
  • 1
  • 3
  • 16

2 Answers2

2

When you have the Build System set to Automatic (e.g. Tools > Build System > Automatic from the menu), Sublime should select the correct build system for the currently focused file as long as the build file is set up correctly.

Based on the build system you have outlined above, as long as you have some package installed that is providing a custom syntax for this package (e.g. the q KBD package) that assigns the scope source.q as a base scope, this should work fine in this case.

To verify, while a q file has the input focus, select Tools > Developer > Show Scope Name from the menu (or press the associated key) and make sure that the scope begins with source.q (the package above does this). The scope that you see may be longer than this depending on where you are in the file, but as long as it starts with this, you should be OK.

If that's not the scope that you see, then the reason the build as you've outlined it is not automatically selected is because the package you're using uses a different scope, or you don't have a q package installed (this is the case if the scope you see is text.plain, for example).

The solution in that case would be to either update the scope based on the package you're using or install the above package (if you don't have anything related to this already installed).

In lieu of installing a support package that provides a syntax, you could also modify the build to be as follows, which should tell it it to use the build for all *.q files regardless of their scope. Arguably the package install method is superior since it would give you syntax highlighting for your files as well.

{
    "cmd": ["[full q path]", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "file_patterns": ["*.q"]
}
OdatNurd
  • 21,371
  • 3
  • 50
  • 68
0

I believe you need to add a language syntax definition file, in order to create a new "scope" for automatically enabling the build system.

You can see the answer here for an example: https://stackoverflow.com/a/14263821/8694303

Jonathon McMurray
  • 2,881
  • 1
  • 10
  • 22