vaanwd / Zeal

Zeal for Sublime Text 2/3
MIT License
184 stars 24 forks source link

Support for multiple scopes and handle sub Pythons #27

Closed FMCorz closed 6 years ago

FMCorz commented 6 years ago

The function view.scope_name can return a string of multiple scopes, when that happens, that last component of the last scope is used to guess the language. That can lead to Zeal not recognising the language.

# Method to fetch the scope before patch
print(view.scope_name(view.sel()[0].begin()))

# Example in Django. Before patch, yields model.
>>> source.python.django support.type.django.model

# Example in JSON. Before patch, yields json, from constant.language.json
>>> source.json meta.structure.dictionary.json meta.structure.dictionary.value.json constant.language.json 

The patch uses the first scope found. Further improvement could be made to always use the scopes starting with source. (and text.?). I also added a special rule for Python which helps with scopes like source.python.django.