Sublime Forum

Build System based on Language

#1

Is there a way to associate a build system with a language? I save a file with a .rb extension and Sublime knows to use the Ruby syntax: yay! But then I press F7 and it’s trying to use a Makefile on it: bummer. Is there a way to automatically have the build system picked based on the language of the current file? If not, I humbly submit this as a feature request.

0 Likes

#2

I have a not too simple workaround using the keymap and options for a file type, in my case PLSQL.

In my PLSQL package directory the Default.sublime-keymap contains this

<bindings>
  <binding key="f7" command="compilePackage">
    <context name="option" value="useCompilePackage"/>
  </binding>
</bindings>

“compilePackage” is a plugin which lets me select a database before compiling.
Using the context allows to restrict the key binding to this file type. It is necessary as ST loads all keymaps found in alphabetical order- and the last is the winner. In my case

  • Packages\Default/Default.sublime-keymap

  • Packages\HTML/Default.sublime-keymap

  • Packages\StickySearch/Default.sublime-keymap

  • Packages\User/Default.sublime-keymap

  • Packages\XML/Default.sublime-keymap

  • Packages\aaaloadfirstextensions/Default.sublime-keymap

  • Packages\ctags/Default.sublime-keymap

  • Packages\plSQL/Default.sublime-keymap

  • Packages\quickhg/Default.sublime-keymap

For this reason only in my PLSQL.sublime-options the above mentioned option ist set true.

# sql*plus support
useCompilePackage true

Maybe someone can simplify this?

0 Likes

#3

Not possible right now but I want that too, define build files in file types options… +1 :smile:

For now is only possible to define it per project…

project.buildFile Packages/C++/Make.sublime-build

0 Likes

#4

Add me to the list of people who would like this. I don’t even think it’s necessary to make an option for it, just default to the .sublime-build file in the same folder as the .tmLanguage file being used. That should handle 99% of all cases.

0 Likes

#5

I agree this feature would be VERY helpful. Most of my projects have Ruby, C, Perl and even Python. I don’t see how adding this ability would get in the way. It would be nice to extend the build specification so that it can specify builders for specific extensions, since various builders may be available for a given file extension.

0 Likes