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

Snippet placeholder with variables not expanding as expected #950

Open
2 tasks done
camiloaromero23 opened this issue Jan 8, 2025 · 3 comments
Open
2 tasks done
Labels
bug Something isn't working snippets Built-in provider and library for snippets

Comments

@camiloaromero23
Copy link

camiloaromero23 commented Jan 8, 2025

Make sure you have done the following

  • Updated to the latest version of blink.cmp
  • Searched for existing issues and documentation (try <C-k> on https://cmp.saghen.dev)

Bug Description

Given the following snippet, the variable placeholder is not handling the variable correctly (For ease of reading, the variable is TM_FILENAME_BASE).

{
  "reactArrowFunctionComponent": {
    "prefix": "rafc",
    "body": [
      "interface $2Props {}",
      "",
      "export const ${1:${TM_FILENAME_BASE}}: React.FC<${1:${TM_FILENAME_BASE}}Props> = () => {",
      "  return (",
      "    $0",
      "  )",
      "}"
    ],
    "description": "Creates a React Arrow Function Component with ES7 module system"
  }
}
image

However, if I add the variable add the beginning outside of any placeholder, it loads the placeholder anywhere else in the snippet.

{
  "reactArrowFunctionComponent": {
    "prefix": "rafc",
    "body": [
      "$TM_FILENAME_BASE", // Added line to make it "work"
      "interface $2Props {}",
      "",
      "export const ${1:${TM_FILENAME_BASE}}: React.FC<${1:${TM_FILENAME_BASE}}Props> = () => {",
      "  return (",
      "    $0",
      "  )",
      "}"
    ],
    "description": "Creates a React Arrow Function Component with ES7 module system"
  }
}
image

I'm showing the preview since I think it makes more sense to show the issue. Let me know if I can help you with anything else since I don't understand much of the codebase to fix this myself. Thanks for the nice project, keep up with the good work! 🚀🔥💪🏽

Relevant configuration

No response

neovim version

NVIM v0.11.0-dev Build type: Release LuaJIT 2.1.1713773202

blink.cmp version

v0.10.0

@camiloaromero23 camiloaromero23 added the bug Something isn't working label Jan 8, 2025
@camiloaromero23 camiloaromero23 changed the title Snippet placeholder with variables Snippet placeholder with variables not expanding variable Jan 8, 2025
@camiloaromero23 camiloaromero23 changed the title Snippet placeholder with variables not expanding variable Snippet placeholder with variables not expanding as expected Jan 8, 2025
@Saghen Saghen added the snippets Built-in provider and library for snippets label Jan 8, 2025
@Arjun31415
Copy link

A slightly offtopic question: How are you getting the snippet preview window ?. I do not get it automatically
image
This is how it looks for me, even after selecting the snippet the preview does not show up

@Saghen
Copy link
Owner

Saghen commented Jan 9, 2025

@Arjun31415 You can either press <C-space> while the menu is open or enable auto_show for it: https://cmp.saghen.dev/configuration/completion.html#documentation

@Arjun31415
Copy link

Arjun31415 commented Jan 9, 2025

@Arjun31415 You can either press <C-space> while the menu is open or enable auto_show for it: https://cmp.saghen.dev/configuration/completion.html#documentation

yeah, I have that, it only opens for functions, keywords but not for snippets

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working snippets Built-in provider and library for snippets
Projects
None yet
Development

No branches or pull requests

3 participants