Sublime Forum

Plugin API

#1

I’ve just released beta 20080322, which comes with a published API. Docs are at:

sublimetext.com/docs/plugin-basics
sublimetext.com/docs/plugin-examples
sublimetext.com/docs/api-reference

There’s still more functionality that needs to be exposed, and more introductory documentation that needs to be written, but I feel this is a pretty good start.

I haven’t mentioned it in any of the above docs, but within the console you have access to two variables, view and window, which are a good place to start exploring.

0 Likes

#2

Damn! now I have to learn python :wink:

Fantastic, Jon, thanks.

0 Likes

#3

You want to call view.substr() with a region encompassing the entire buffer, e.g.,

view.substr(sublime.Region(0, view.size()))

0 Likes

#4

Hi, Jon. I wanted to know if there was a way yet to use the sublime.Options class to set a plugin-specific option?

I’m trying to improve my auto-backup plugin so that the user can add the backup dir as a preference. I’d like the user to modify easily-accessible preferences – say Application.sublime-options – and add

[code]plugin.AutoBackupPlugin.autoBackupDir c:\usr\backups\[/code]

Then, my code can read;

[code]backupDir = view.options().getString("plugin.AutoBackupPlugin.autoBackupDir")[/code]

and let the user specify the option without hacking the python file. Is there any way to do this, or anything like it? I can get file-type-specific options (eg, I can set autoBackupDir in Python.sublime-options and read that, but there seems to be no inheritance from the application options.)

ALSO – can I suggest a Advanced Customisation forum, for python API, macros, theme development, etc?

0 Likes

#5

Yeah, only file type options are exposed atm - I’ll change that for tonights beta.

All file type options inherit from Packages/Default/Options/Default.sublime-objects, but it’s probably best to put something like the backup dir in the application options.

0 Likes