Home Download Buy Blog Forum Support

Hide plugin from syntax' list

Hide plugin from syntax' list

Postby ostinelli on Sun Apr 15, 2012 4:30 pm

Dear all,

I'm developing a plugin which is an add-on to an existing syntax, let's say Ruby. My plugin has its own directory (so that it can easily be distributed), and defines also tmLanguage and tmTheme files because it uses the output panel and I want to stylize it.

Unfortunately, it shows up as an item in the syntax selection list, but I do not want to show it as it has no syntax (which is defined in the proper Ruby.tmLanguage file).

The questions are:

  • what is the best way to 'extend' and existing syntax definition?
  • Shall i use 'source.ruby' as scopeName?
  • How can I hide this plugin from the available syntaxes?
  • How can I ensure that my plugin's commands are only called if within the source.ruby scope?

Thank you so much to any kind soul who will take the time to give me some insights ^^_

Cheers,

r.
ostinelli
 
Posts: 15
Joined: Thu Apr 12, 2012 4:50 am

Re: Hide plugin from syntax' list

Postby ostinelli on Sun Apr 15, 2012 6:07 pm

ostinelli wrote:
  • How can I hide this plugin from the available syntaxes?


In cas anyone wanders, I found that renaming the file extensions to .hidden-tmLanguage and .hidden-tmTheme did the trick of hiding my plugin from the available syntax list :)

All the other questions are open, though, especially
ostinelli wrote:
  • How can I ensure that my plugin's commands are only called if within the source.ruby scope?


:)

r.
ostinelli
 
Posts: 15
Joined: Thu Apr 12, 2012 4:50 am

Re: Hide plugin from syntax' list

Postby C0D312 on Sun Apr 15, 2012 6:25 pm

A better way to hide the packages is to add them to the 'ignored_packages' setting in Preferences > Settings - User.

Code: Select all
"ignored_packages":
   [
      "Vintage",
      ...
      ...
   ]
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am

Re: Hide plugin from syntax' list

Postby quarnster on Sun Apr 15, 2012 6:27 pm

ostinelli wrote:what is the best way to 'extend' and existing syntax definition?

You can include the original syntax definition in your own:
Code: Select all
      <dict>
         <key>include</key>
         <string>source.ruby</string>
      </dict>


ostinelli wrote:How can I ensure that my plugin's commands are only called if within the source.ruby scope?

Implement the "is_enabled" and "is_visible" functions in your WindowCommand or TextCommand. See the API

So for example your commands might use something like this:
Code: Select all
def is_enabled(self):
    caret = self.view.sel()[0].a
    return "source.ruby" in self.view.scope_name(caret)
quarnster
 
Posts: 389
Joined: Tue Nov 29, 2011 11:34 am

Re: Hide plugin from syntax' list

Postby ostinelli on Sun Apr 15, 2012 11:49 pm

thank you. this is great stuff. ^^_

r.
ostinelli
 
Posts: 15
Joined: Thu Apr 12, 2012 4:50 am


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 5 guests

cron