Home Download Buy Blog Forum Support

EventListener for a specific syntax

EventListener for a specific syntax

Postby Jotomicron on Mon May 19, 2014 5:25 pm

I'm just starting to delve into Sublime's Plugin API, as I am trying to create a new plugin for my needs.

My question is if there is a way to make an EventListener fire only when the focused view uses a specific syntax.
I know that I could use
Code: Select all

but I'm afraid this will not scale on the long run, if someone has many views opened

Thank you!
Posts: 2
Joined: Mon May 19, 2014 4:49 pm

Re: EventListener for a specific syntax

Postby tito on Sat May 31, 2014 4:57 am

Just use it ! It scales because the event will likely fire for the current view, not for all the views at the same time.
Give APIs, let the community build the rest!
Posts: 988
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay

Re: EventListener for a specific syntax

Postby FichteFoll on Tue Jun 03, 2014 9:22 pm

Working on
Code: Select all

is just fine.

Another idea would be to use the associated scope that the syntax defines and match a selector on that. It's more flexible in that you can match multiple syntaxes with a single selector and it's easily expanded. Here are some links to work with:

http://docs.sublimetext.info/en/sublime ... tml#scopes
https://github.com/SublimeText/AAAPacka ... #L112-L115
http://docs.sublimetext.info/en/sublime ... h_selector

And here is an example usage:
https://github.com/FichteFoll/CSScheme/ ... #L224-L238
Posts: 871
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany

Return to Plugin Development

Who is online

Users browsing this forum: Google [Bot] and 5 guests