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

Space within an element breaks the snippet flow #254

Open
ubitux opened this issue Aug 27, 2022 · 1 comment
Open

Space within an element breaks the snippet flow #254

ubitux opened this issue Aug 27, 2022 · 1 comment

Comments

@ubitux
Copy link

ubitux commented Aug 27, 2022

In (C) friendly snippets, we can see the following mal snippet:

  "Allocate memory using malloc": {
    "prefix": "mal",
    "body": [
      "${1:int} *${2:v} = malloc(${3:1} * sizeof($1));",
      "",
      "if (!$2) {",
      "\tfprintf(stderr, \"Memory allocation failed!\\n\");",
      "\t$4;",
      "}",
      "$0",
      "free($2);"
    ],
    "description": "Allocates memory to a pointer variable using malloc(), then deallocates using free()."
  },

For the first item (${1:int}), if need to use a struct type such as struct foobar, the presence of the <SPACE> between struct and foobar will actually prevent jumping to the next item.

I'm not sure if that's a bug or a known limitation, but since this is a very common pattern to use in C I thought it was worth raising it up.

@hrsh7th
Copy link
Owner

hrsh7th commented Oct 7, 2022

Sorry. It's documented.

https://github.com/hrsh7th/vim-vsnip/blob/master/doc/vsnip.txt#L251

tomtomjhj added a commit to tomtomjhj/init.vim that referenced this issue Nov 19, 2022
* vsnip is very buggy. hrsh7th/vim-vsnip#254
* luasnip loads too many files at startup. Lazy-load it at InsertEnter
  and <C-l>.
* My patch to break undo sequence before expanding. Upstream it?
* Make vsnip snippets available for luasnip.
* Port some advanced vsnip snippets to luasnip.
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