snippets icon indicating copy to clipboard operation
snippets copied to clipboard

Trigger on context instead of tab?

Open oleander opened this issue 11 years ago • 8 comments

I was hoping to implement this snippet in atom, but I can't find any support for triggering snippets based on context.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>content</key>
    <string>#{${1:$TM_SELECTED_TEXT}}</string>
    <key>keyEquivalent</key>
    <string>#</string>
    <key>name</key>
    <string>Embedded Code — #{…}</string>
    <key>scope</key>
    <string>B:(string.quoted.double.ruby|string.interpolated.ruby) - string source</string>
    <key>uuid</key>
    <string>EEE6D060-C5A0-400D-A2E0-0835013C5365</string>
</dict>
</plist>

It will expand # to #{} when inside a ruby string without hitting tab. The current migration tool doesn't seem to be able to do this. apm init --package . --convert https://github.com/textmate/ruby.tmbundle.

oleander avatar Apr 23 '14 22:04 oleander

Do you know what the B: part of the scope string is supposed to do?

kevinsawicki avatar Apr 23 '14 22:04 kevinsawicki

Your guess is as good as mine :)

oleander avatar Apr 23 '14 22:04 oleander

What did the apm init command convert this snippet to? Or did it just silently drop it?

kevinsawicki avatar Apr 23 '14 22:04 kevinsawicki

It didn't do anything. I tired removing everything in the original snippets folder except this snippet which resulted in an empty snippets folder in the output bin.

oleander avatar Apr 23 '14 22:04 oleander

Can you try changing the scope to (string.quoted.double.ruby|string.interpolated.ruby) - string source and see if that converts correctly?

kevinsawicki avatar Apr 24 '14 23:04 kevinsawicki

Same thing ...

oleander avatar Apr 24 '14 23:04 oleander

What about if the content is #{$1}?

kevinsawicki avatar Apr 24 '14 23:04 kevinsawicki

Nope, nothing.

oleander avatar Apr 24 '14 23:04 oleander