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 · 5 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

This comment was marked as off-topic.

@Saghen

This comment was marked as off-topic.

@Arjun31415

This comment was marked as off-topic.

@Saghen
Copy link
Owner

Saghen commented Jan 9, 2025

Could you open a separate issue with your configuration?

@camiloaromero23
Copy link
Author

Also, I know it is off-topic but I have been having problems with mapping for a time, it does not work (neither for nvim-cmp before). Do you know where can I look for to solve this? I know it is not related to the plugin itself but cannot find any useful info on this 🫠

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