blink.cmp icon indicating copy to clipboard operation
blink.cmp copied to clipboard

Snippet placeholder with variables not expanding as expected

Open camiloaromero23 opened this issue 11 months ago • 5 comments

Make sure you have done the following

  • [X] Updated to the latest version of blink.cmp
  • [X] 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 avatar Jan 08 '25 14:01 camiloaromero23

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

Arjun31415 avatar Jan 09 '25 11:01 Arjun31415

@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

saghen avatar Jan 09 '25 18:01 saghen

@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

Arjun31415 avatar Jan 09 '25 18:01 Arjun31415

Could you open a separate issue with your configuration?

saghen avatar Jan 09 '25 18:01 saghen

Also, I know it is off-topic but I have been having problems with <C-space> 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 🫠

camiloaromero23 avatar Jan 10 '25 14:01 camiloaromero23

You can try using :imap <key> to find what mappings are being assigned to each key, see :h :imap

saghen avatar Jul 23 '25 19:07 saghen