I’m trying to create a keyboard shortcut to set an unsaved file’s syntax.
view.syntax_name(view.buffer_id()) in the console returns the correct type for files already saved, but I can’t figure out how to set it.
Thanks,
Kirk
I’m trying to create a keyboard shortcut to set an unsaved file’s syntax.
view.syntax_name(view.buffer_id()) in the console returns the correct type for files already saved, but I can’t figure out how to set it.
Thanks,
Kirk
I think when the quick panel API becomes available that will make a syntax selection tool much better.
Try something like this:
view.settings().set(‘syntax’, ‘Packages/’+ syntax + ‘/’ + syntax + ‘.tmLanguage’)
Isn’t view.settings().set() implemented in the ST2 alpha? The syntax doesn’t appear to change when I execute
view.settings().set('syntax', 'Packages/'+ syntax + '/' + syntax + '.tmLanguage')
where syntax is “XML”, for example.
I’m trying to implement the DetectFileType plugin in ST2, to be able to detect .html.erb etc. in a reliable way.
view.settings().set() should work, but isn’t the best way to change the syntax in any case, as it won’t cause the right .sublime-settings files to be associated with the view.
There will be a new API function, view.set_syntax_name(), in the next version.