NodeRequirer
NodeRequirer copied to clipboard
Investiate alternate method of triggering NodeRequirer.
Some of the bigger Sublime plugins seem to do some pretty complex stuff with the APIs sublime exposes (and they're not all listed in the official documentation). Creating intuitive interfaces in Sublime seems to be a matter of creatively (ab)using the APIs.
One idea I can think of is attempting to provide a different way of triggering NodeRequirer. The current method of doing it is with Ctrl
+Shift
+I
. And personally, I hate keyboard combos. It's another thing to memorize and it forces me to temporarily break my hands' typing position in order to hit the keys.
Here's one creative idea for a method of triggering NodeRequirer by abusing two sublime APIs in combination:
- We add one (or more)
NodeRequirer.sublime-snippet
snippets. These will be something likerequire(${1:[module]})
. - Using on_modify/on_modify_async or maybe intercepting the commit_completion command we watch for a selection that matches
[module]
. - If that selection matches we look at the surrounding text to see if we're in the correct snippet result.
- If so we trigger the NodeRequirer panel.
From the user perspective it should look like:
- They started typing
require
. - A
showed up in their completions.
- They hit tab/enter, whatever is configured for completions.
- NodeRequirer popped up asking what module to require.