Sublime Forum

Plugin for generating boilerplate files

#1

Hi hackers,
I’ve been working on a plugin that creates a small directory structure and a few boilerplate files. I’d like to prompt the user to specify the name of a new root directory for the generated subdirectories and files, and then to specify a location to save this new root directory and its generated contents.

I’m able to prompt the user with an input panel for the name of the new directory, and I would then like the OS file choose to appear, enabling the user to select a filesystem location where this new directory should be created. Do any of you have some advice about how I might be able to do this? I feel like it may not be possible given the ST2 API.

0 Likes

#2

Sublime Text is kind of limited in terms of UI, there aren’t many ways to show Windows.

Depending on your target OS, you could try to open the FolderChooseDialog with the native api or with http://qt-project.org/. You could create an executable that delivers the selected directory back to sublime and go on from there

You could also try to extend the context menu of the advanced sidebar plugin with your entry (e.g. genereate xy here), or let the User define a full/relative path by himself.

0 Likes

#3

Hmmm. I may have to have the user create the directory first, open the directory in a new Sublime window, and then execute my plugin within the context of that directory.

If anyone else happens to see this thread, I’d love to know if there’s a way, via the plugin API, to prompt the user for a location on the filesystem via GUI.

0 Likes

#4

You could try Grunt Init or Yeoman, which are exactly for generating boilerplates.

If you really, really want to use sublime, i’d suggest you to make a plugin that is only a wrapper around one of these two above; if you decide to change your editor you won’t loose your boilerplates :wink:

0 Likes