ultisnips
ultisnips copied to clipboard
Option to select a default snippet when there are multiple matches
I'm using snippets for both TypeScript and Javascript and I want to use the console.log
snippet that is defined in both languages. I'm ok with choosing one of both, but Ultisnips asks me everytime which one I want to use.
1: (clv) "console.log variable" (/.../.vim/bundle/vim-react-snippets/UltiSnips/typescript.snippets:72)
2: (clv) "console.log variable" (/.../.vim/bundle/vim-react-snippets/UltiSnips/javascript.snippets:72)
Type number and <Enter> or click with the mouse (q or empty cancels):
Expected behavior: It would be great to have an option to specify a priority for this particular conflict, or a general "language" priority so I can set TypeScript as the preferred option for this case. I'm ok with anything that solves this issue so Ultisnips stops asking me which snippet I want to use.
Maybe you mean priority
?
You can use priority
syntax for snippets set followed.
priority 100
snippet a
aaa
endsnippet
snippet b
bbb
endsnippet
priority -100
snippet c
ccc
endsnippet
Or you want to always choose the first one? #1012 may help you.
But I'm confused that why both snippets are triggered. Actually, it should trigger the corresponding language or all
snippets.
Sorry for the delay. I got this issue with the typescriptreact
filetype. Here's the log:
1: (clv) "console.log variable" (/.../vim-react-snippets/UltiSnips/typescript.snippets:76)
2: (clv) "console.log variable" (/.../vim-react-snippets/UltiSnips/javascript.snippets:76)
The snippets are from mlaursen/vim-react-snippets. I can see that both TypeScript and JavaScript snippets are being included. There's a way to set the priority for this package? Or should I reach them to fix the issue?
I copy snippets in that repo but I can not reproduce the issue. Maybe you can change the priority matually.
Could be the file extension? I'm getting this error on .tsx
and .ts
files (that resolves to the typescriptreact
filetype) but not on .js
files (that resolves to the javascript
filetype). Looks like TypeScript, being a superset of JavaScript, is the culprit in some way.