Allow user 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.
ext install corvofeng.Vsnips
For details of Ultisnips, please refer here.
It's easy to write an UltiSnips sippets, for example, in
I usually use
import IPython; IPython.embed() for debugging.
And you could write snippts like this:
# Atention, this code must be put in python.snippets for `Python` code.
snippet dbg "Use IPython to debug"
# ---------- XXX: Can't GIT add [START] ---------- #
# ---------- XXX: Can't GIT add [END] ---------- #
The UltiSnips snippet bej
snippet, end with
The whole snippst is surrounded with
dbg is the triger, and
"Use IPython to debug" is
description for this snippet. At my vim:
In VScode, there is an origin snippets syntax to manage your own snippets. But I found it may not very easy to use:
- 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 have been too many snippets 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 wanna 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 Vimer, you had to
write snippets for these two editors, which bothers me.
How to use Vsnips
This plugin base on the snippet api in VScode, weather
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
after set that.
When you give the variable like
let g:snips_author="corvo", you could
use it like snippets below.
snippet full_title "Python title fully"
# -*- coding: utf-8 -*-
# vim: ts=4 sw=4 tw=99 et:
@Date : `!v strftime("%B %d, %Y")`
@Author : `!v g:snips_author`
- [x] Auto download the Ultisnips
- [x] Multi languate completions support
- [x] Allow user add their own Ultisnips.
- [x] From Ultisnips to VScode snippets.
- [x] Support strftime
- [x] Allow user define variables
- [x] Syntax highlight for snippets
- [x] Allow user define their own functions
- [x] Support autoDocstring for Python and TypeScript.
- [ ] Support extends and priority in Ultisnips
- [ ] Add support for golang function comments.
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
Vsnips could auto-generate the doc for the functions,
Which will refer to autoDocstring.