Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cursorless-aware autofill option for snippet variables #1635

Open
josharian opened this issue Jul 14, 2023 · 1 comment
Open

cursorless-aware autofill option for snippet variables #1635

josharian opened this issue Jul 14, 2023 · 1 comment

Comments

@josharian
Copy link
Collaborator

Consider this snippet extract:

        "body": [
          "for $init; $condition; $post {",
          "\t$body",
          "}"
        ]

    "variables": {
      "body": {
        "wrapperScopeType": "statement"
      }
  },

The three variables other than $body are never populated. They're whitespace only, and getting to the right spot to fill them in often requires something like pre green ex semicolon.

I'd like to be able to autofill these with cursorless-aware placeholders. These would be strings that cursorless selects specifically to get good hats, in the current context.

(In a similar vein, in a thing I'm quietly working on, foo is hooked up to generate qwjkzy, because those are the six least commonly occurring letters in Go files, and thus likely to have nice hats.)

So instead of inserting:

for ; ; {
  // existing statement
}

It might insert something like:

for qwj8; zyk9; pmv7 {
  // existing statement
}

This is low priority, as I have a workaround I'm using:

        "body": [
          "for ${init:zq$RANDOM_HEX}; ${condition:jk$RANDOM_HEX}; ${post:wy$RANDOM_HEX} {",
          "\t$body",
          "}"
        ]

But it's a bit inferior, in that it over-indexes on hex digits, which are very common. Sample output:

for zqb7038b; jk58d501; wy8b3ea2 {
  // existing statement
}
@pokey
Copy link
Member

pokey commented Jul 15, 2023

Interesting idea! A couple quick reactions:

  • How come you don't use "tab" / "shift tab" to navigate snippet placeholders?
  • If the issue is that they are a bit fragile, eg if you navigate outside the snippet, see Stable snippets #443. Your suggestion / workaround seem like an easy way to get some of that stability

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants