Sublime Forum

Hide plugin from syntax' list

#1

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.

0 Likes

#2

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 :smile:

All the other questions are open, though, especially

:smile:

r.

0 Likes

#3

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

[code]“ignored_packages”:

	"Vintage",
	...
  ...
][/code]
0 Likes

#4

You can include the original syntax definition in your own:

		<dict>
			<key>include</key>
			<string>source.ruby</string>
		</dict>

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:

def is_enabled(self): caret = self.view.sel()[0].a return "source.ruby" in self.view.scope_name(caret)

0 Likes

#5

thank you. this is great stuff. ^^_

r.

0 Likes