draivin / hsnips

HyperSnips: a powerful snippet engine for VS Code, inspired by vim's UltiSnips
MIT License
154 stars 25 forks source link

placeholder disappears when using the automatic snippet #78

Open cht33 opened 3 years ago

cht33 commented 3 years ago

Hello, I've got a problem that behaves kind of like https://github.com/draivin/hsnips/issues/38, but I don't know how to fix it. I have this two snippets

snippet lim "auto limit" w
\lim\limits_{${1:n} \to ${2:\infty}} $0
endsnippet

`(?<=\b|\d+)(?<!\\)(tau)` "greek" wA
\\``rv = m[1]``$0
endsnippet

When I'm in the lim snippet, and then I type in tau, it will change into \tau but make the placeholer disappear. Snipaste_2021-09-28_22-08-25 Snipaste_2021-09-28_22-08-44

Could anyone gives some tips about that problem?

yfzhao20 commented 3 years ago

I think that your snippet should be:

snippet lim "auto limit" w
\lim\limits_{${1:n} \to ${2:\infty}} $0
endsnippet

snippet `(?<=\b|\d+)(?<!\\)(tau)` "greek" wA
\\``rv = m[1]``$0
endsnippet

but I think everything is okay...

1111

Can you provide more information? or...🤔

cht33 commented 3 years ago

Can you provide more information? or...🤔

@yfzhao20 Hello! Actually I'm working on my math homework, one is with latex in wsl2-Ubuntu20.04 and another one is with markdown in Win10. I've fully tested on both systems and found something really strange:

  1. When I'm using latex in WSL2, hypersnips works quite well, like that: latex

  2. However when I'm using markdown in Win10, the strange behaviour described above happened: markdown

Maybe the cause is the difference between these two languages? I've no idea about how to fix this problem..

cht33 commented 3 years ago

I've tested this problem again in Win10 (at least in WSL2 everything is fine). This problem happens only when the auto completion is triggered, if I use tab to complete there is no problem.

I doubt that there maybe some conflicts between hypersnips and vim.

  1. I tested latex in Win10 and the problem still exists, so I think the language doesn't matter.
  2. I disabled most of my extentions, and the problem was gone.
  3. Finally I found that when I enabled the vim extention, the problem came again!
  4. However, in the remote-wsl mode, I enabled all my extentions and there was no such problem.

The testing procedure is as follows: markdown_latex

yfzhao20 commented 3 years ago

Sorry but I don't use "vim" as editor. So maybe I have tried my best 😂 Maybe you can check your snippets in "Vim"?

cht33 commented 3 years ago

Sorry but I don't use "vim" as editor. So maybe I have tried my best 😂 Maybe you can check your snippets in "Vim"?

I delete all my vscode-vim configuration in the settings.json, but the problem still exists... So there must be some conflicts between these two extensions. Actually I'm trying to use vscode to write latex/markdown, so I choose the vscode-vim + hypersnips extensions in substitution for vim + UltiSnips. However there are quite a lot of difference between hypersnips and UltiSnips, maybe the author knows how to fix this problem. Anyway, thanks a lot! @yfzhao20

changxvv commented 3 years ago

I also use VScodeVim+hypersnips, and I got the same problem 😂

yunus-sun commented 3 years ago

I also have the same problem. But it will be fine trying the plug named VSCode Neovim to replace the Vim plug.

gruvw commented 2 years ago

Same here with simple snippets:

snippet ab "Ab" A
a $1 b
endsnippet

snippet cc "Cc" A
cc
endsnippet

Typing abcc lock me at | in a cc| b and I can't use tab to go to the end (a cc b|) once the cc snippet expanded.

Using Vscode + Vim + Hsnips.

draivin commented 2 years ago

So, I looked into it, the placeholder disappearance is caused by a workaround we are currently using to get around a VsCodeVim issue.

History time:

sleepymalc commented 2 years ago

This is exactly my problem with hsnips. This is quite annoying tbh, and this causes so much headache for my workload. But at this moment, this is still the best snippets extension I can find... hope this can be fixed in a near future.

su-stephen commented 2 years ago

I've noticed that if we use a $2 tabstop instead of a $0 tabstop, tabs continue to work even with expansions. The only issue is that it's difficult to "end the snippet" (see https://github.com/draivin/hsnips/issues/1) which results in continuous highlighting of text after the tab (see https://github.com/draivin/hsnips/issues/106) and requiring two "esc" keys to go into vim normal mode.

snippet mk "inline math" wA
\$$1\$ $2
endsnippet

Is there a way to end the snippet easily if we use a $2 tabstop?

XRay71 commented 8 months ago

I would like to bump this issue, they started disappearing for me starting last update (v0.2.9), exactly as described above. I am not using Vim or anything similar, and su-stephen's $2 workaround does not work for me either.

Edit: I have just tried downgrading to v0.2.8, and looks like they're not working on earlier versions anymore either... might be a VSCode thing.

dromeldar commented 5 months ago

Same here. With no vim extension still I have the issue of disappearing tab-stobs in nested snips and the $2 hack does not solve this either. Also on v0.2.9.

FlynnFehre commented 3 months ago

I also have the problem without the vim extension. Even without all extensions except hyperscopes and hypersnips the problem is still there.