I am building a Package wherein I have 3 snippets that I want my users to be able to override by including an identically-named snippet in their User
Package. Note that I am NOT using the normal trigger mechanism to insert it. Instead, I am using them from within a plugin (because there is about 25 different ways to trigger it, but I need there to be only ONE snippet file) by calling
self.view.run_command("insert_snippet", args)
One of the arguments in the args
dictionary is
"name": "path/to/snippet-file"
for example
"name": "Packages/ProComment/c_header.sublime-snippet"
I want my users to be able to use their own snippet files with this. I tried copying c_header.sublime-snippet
to my User
Package and altering it, but the original one in the package directory was still being used. I tried
- “${packages}/ProComment/c_header.sublime-snippet”
- “${packages}/c_header.sublime-snippet”
- “${packages_path}/ProComment/c_header.sublime-snippet”
- “${packages_path}/c_header.sublime-snippet”
and none of them work to get it to use the one in the User
package. Of course
"name": "Packages/User/c_header.sublime-snippet"
works, but then doesn’t go back to the default snippet when the one in the User
package is removed.
Is there some magic variable or token to include in the Path string to get Sublime Text to detect that there is an override snippet in the User
package? Or do I need to “manually” (in the plugin code) check for the existence of the snippet file in the User
package and use it if it is there, else drop back to the default path?
P.S. I have figured out how to manually check whether there is a user-override Snippet file present by using sublime.packages_path()
, but I’d much rather use a magic variable like ${packages} in a single path submitted to the insert_snippet
command if that is possible.