(news)2022-04-12, we support vscode web extension, and you can install it when you use
vscode.dev
orgithub.dev
.
Here is the project: https://github.com/corvofeng/Vsnips
1 | ext install corvofeng.Vsnips |
Allows you to use Ultisnips in vscode.
It is under development, although I can’t guarantee that all ultisnips functions can be used in vscode, I will try my best. Please feel free to give an issue or pull requests.
Please: refer to the docs: https://vsnips.corvo.fun/
UltiSnips
For details of Ultisnips, please refer here.
.
It’s easy to write an UltiSnips snippets, for example, in Python
,
I usually use import IPython; IPython.embed()
for debugging.
And you could write snippts like this:
python.snippets
1 | snippet dbg "Use IPython to debug" |
The whole snippst is surrounded with snippet
and endsnippet
,
while the dbg
is the triger, and "Use IPython to debug"
is
description for this snippet. This is what it looks like when you use the snippet:
VSCode snippets
VSCode has it’s own implementation for snippets which lets you create your own. But I found it difficult to use and lacking in feature set, for example:
- If there is a multi-line snippet,
json
is not very well for storing. - It’s hard for many PC sync the snippets. Because of this, there is already too many snippet extensions for different languages, like, C/C++ Snippets, Bootstrap 3 Snippets.
I do not mean that it’s bad for different language having their own extension. But you must admit that if you want to add snippets for a language, you need to learn how to write an extension and how to add snippets. and what’s most important is that if you are an vimmer, you had to write snippets for these two editors, which bothers me.
How to use Vsnips
This plugin based on the snippet api in VSCode, whether you have used UltiSnips or not, it’s easy to start. I have adapted some UltiSnips snippets to VSCode and used it by default.
If you have already use UltiSnips, and even have your own snippets,
you can add own snippets dir in settings, and use the variable in VarFiles
to set that.
1 | { |
When you give the variable like let g:snips_author="corvo"
, you could
use it like snippets below.
1 | snippet full_title "Python title fully" |
Completed Tasks
- Auto download the Ultisnips
- Multi language completions support
- Allow user add their own Ultisnips.
- From Ultisnips to VSCode snippets.
- Support strftime
- Allow user define variables
- Allow some functions(Rewrite by javascript)
- Syntax highlight for snippets
- Allow user define their own functions
- Support autoDocstring for Python and TypeScript.
- Add support for golang function comments.
Work in Progress
- Support extends and priority in Ultisnips
May not work
The UltiSnips in vim could adjust the doc according to the
python function argument. But the Vsnips is based on VSCode
CompletionItemProvider
, it may be hard to support this feature.
So, I change to another solution, after the user triggers the keys like v-doc
,
Vsnips could auto-generate the doc for the functions,
Which will refer to autoDocstring.