Is there a function that just returns the current syntax highlighting/detected file type for the file open in the active window?
Edit: Mmm, using view.syntaxName(0) would seem to work, but it’s not that obvious from the documentation at least. Not to mention needlessly wordy by passing an parameter where none should be needed for this use case IMHO.
Edit2: This function seems to return a flat Unicode string consisting of two parts. The first part being specific for the point you call syntaxName() on, the second part identifying the type of file/syntax highlighting applied, e.g.:
keyword.control.import.from.python source.python
meta.preprocessor.c source.c++
Example use:
[code]import sublime, sublimeplugin
class MyPlugin(sublime.TextCommand):
def run(self, view, args):
syntax = view.syntaxName(0).split()[1]
source.python
[/code]
Edit3: jps, any chance of getting a simpler function that just returns ‘python’ or ‘c++’?