NodeRequirer icon indicating copy to clipboard operation
NodeRequirer copied to clipboard

Investiate alternate method of triggering NodeRequirer.

Open dantman opened this issue 9 years ago • 2 comments

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 like require(${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:

  1. They started typing require.
  2. A require - NodeRequirer showed up in their completions.
  3. They hit tab/enter, whatever is configured for completions.
  4. NodeRequirer popped up asking what module to require.

dantman avatar Feb 25 '15 22:02 dantman