Skip to content
Ultisnips for vscode
TypeScript
Branch: master
Clone or download
corvofeng Debug the tokenizer function.
Signed-off-by: corvofeng <corvofeng@gmail.com>
Latest commit c50d1ed Aug 16, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode v0.0.8 vscode must need .vscode dir. Jul 26, 2019
images Add icon. Jun 19, 2019
src Debug the tokenizer function. Aug 16, 2019
syntaxes Add syntax highlight for snippets. Jul 21, 2019
.gitignore Init the project. Jun 16, 2019
.vscodeignore Init the project. Jun 16, 2019
CHANGELOG.md Update the changelog. Aug 14, 2019
README-zh_CN.md Update zh_CN readme. Aug 4, 2019
README.md Update readme, add icon. Aug 3, 2019
package-lock.json Unify the kv_store variable name. Jul 28, 2019
package.json
tsconfig.json Init the project. Jun 16, 2019
tslint.json Init the project. Jun 16, 2019
yarn.lock Update the parser for ultisnips. Jun 16, 2019

README.md

Vsnips

中文文档

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

Vsnips

UltiSnips

For details of Ultisnips, please refer here.

ultisnips.

It's easy to write an UltiSnips sippets, for example, in Python, 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] ---------- #
import IPython
IPython.embed(using=False)
# ---------- XXX: Can't GIT add  [END]  ---------- #
endsnippet

The UltiSnips snippet bej snippet, end with endsnippets

The whole snippst is surrounded with snippet and endsnippets, while the dbg is the triger, and "Use IPython to debug" is description for this snippet. At my vim:

3

VScode snippets

In VScode, there is an origin snippets syntax to manage your own snippets. But I found it may not very easy to use:

  1. If there is a multi-line snippet, json is not very well for storing.
  2. 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 VarFiles after set that.

{
    "Vsnips.VarFiles": [
        "/home/corvo/.vimrc",
        "/home/corvo/.vim/common.vim",
    ],
    "Vsnips.SnipsDir": [
        "/home/corvo/.vim/UltiSnips"
    ]
}

When you give the variable like let g:snips_author="corvo", you could use it like snippets below.

snippet full_title "Python title fully"
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: ts=4 sw=4 tw=99 et:

"""
@Date   : `!v strftime("%B %d, %Y")`
@Author : `!v g:snips_author`

"""

endsnippet

Have done

  • Auto download the Ultisnips
  • Multi languate 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

Doing

  • Allow user define their own functions
  • Support autoDocstring for python
  • 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.

You can’t perform that action at this time.