Code Monkey home page Code Monkey logo

vim-vsnip's Introduction

vim-vsnip

VSCode(LSP)'s snippet feature in vim/nvim.

Features

  • Nested placeholders
    • You can define snippet like console.log($1${2:, $1})$0
  • Nested snippet expansion
    • You can expand snippet even if you already activated other snippet (it will be merged as one snippet)
  • Load snippet from VSCode extension
    • If you install VSCode extension via Plug 'golang/vscode-go', vsnip will load those snippets.
  • Support many LSP-client & completion-engine by vim-vsnip-integ
  • Vim script interpolation
    • You can use Vim script interpolation as ${VIM:...Vim script expression...}.
  • SnipMate-like syntax support
    • Snippet files in SnipMate format with the extension .snippets can be load.
    • NOTE: Full compatibility is not guaranteed. It is intended to easily create user-defined snippets.

Concept

  • Pure Vim script
  • Well tested (neovim/0.4.4, vim/8.0.1567)
  • Support VSCode snippet format
  • Provide integration with many plugins

Related repository

friendly-snippets - Set of preconfigured snippets for all kind of programming languages that integrates really well with vim-vsnip, so all users can benefit from them and not to worry about setting up snippets on their own.

Usage

1. Install

You can use your favorite plugin managers to install this plugin.

Plug 'hrsh7th/vim-vsnip'
Plug 'hrsh7th/vim-vsnip-integ'

call dein#add('hrsh7th/vim-vsnip')
call dein#add('hrsh7th/vim-vsnip-integ')

NeoBundle 'hrsh7th/vim-vsnip'
NeoBundle 'hrsh7th/vim-vsnip-integ'

2. Setting

" NOTE: You can use other key to expand snippet.

" Expand
imap <expr> <C-j>   vsnip#expandable()  ? '<Plug>(vsnip-expand)'         : '<C-j>'
smap <expr> <C-j>   vsnip#expandable()  ? '<Plug>(vsnip-expand)'         : '<C-j>'

" Expand or jump
imap <expr> <C-l>   vsnip#available(1)  ? '<Plug>(vsnip-expand-or-jump)' : '<C-l>'
smap <expr> <C-l>   vsnip#available(1)  ? '<Plug>(vsnip-expand-or-jump)' : '<C-l>'

" Jump forward or backward
imap <expr> <Tab>   vsnip#jumpable(1)   ? '<Plug>(vsnip-jump-next)'      : '<Tab>'
smap <expr> <Tab>   vsnip#jumpable(1)   ? '<Plug>(vsnip-jump-next)'      : '<Tab>'
imap <expr> <S-Tab> vsnip#jumpable(-1)  ? '<Plug>(vsnip-jump-prev)'      : '<S-Tab>'
smap <expr> <S-Tab> vsnip#jumpable(-1)  ? '<Plug>(vsnip-jump-prev)'      : '<S-Tab>'

" Select or cut text to use as $TM_SELECTED_TEXT in the next snippet.
" See https://github.com/hrsh7th/vim-vsnip/pull/50
nmap        s   <Plug>(vsnip-select-text)
xmap        s   <Plug>(vsnip-select-text)
nmap        S   <Plug>(vsnip-cut-text)
xmap        S   <Plug>(vsnip-cut-text)

" If you want to use snippet for multiple filetypes, you can `g:vsnip_filetypes` for it.
let g:vsnip_filetypes = {}
let g:vsnip_filetypes.javascriptreact = ['javascript']
let g:vsnip_filetypes.typescriptreact = ['typescript']

3. Create your own snippet

Snippet file will store to g:vsnip_snippet_dir per filetype.

  1. Open some file (example: Sample.js)
  2. Invoke :VsnipOpen command.
  3. Edit snippet.
{
  "Class": {
    "prefix": ["class"],
    "body": [
      "/**",
      " * @author ${VIM:\\$USER}",
      " */",
      "class $1 ${2:extends ${3:Parent} }{",
      "\tconstructor() {",
      "\t\t$0",
      "\t}",
      "}"
    ],
    "description": "Class definition template."
  }
}

The snippet format was described in here or here.

Recipe

$TM_FILENAME_BASE

You can insert the filename via fname\<Plug>(vsnip-expand).

{
  "filename": {
    "prefix": ["fname"],
    "body": "$TM_FILENAME_BASE"
  }
}

Log $TM_SELECTED_TEXT

You can fill $TM_SELECTED_TEXT by <Plug>(vsnip-select-text) or <Plug>(vsnip-cut-text).

{
  "log": {
    "prefix": ["log"],
    "body": "console.log(${1:$TM_SELECTED_TEXT});"
  }
}

Insert environment vars

You can insert value by Vim script expression.

{
  "user": {
    "prefix": "username",
    "body": "${VIM:\\$USER}"
  }
}

Insert UUID via python

You can insert UUID via python.

{
  "uuid": {
    "prefix": "uuid",
    "body": [
      "${VIM:system('python -c \"import uuid, sys;sys.stdout.write(str(uuid.uuid4()))\"')}"
    ]
  }
}

NOTE: $VIM is only in vsnip. So that makes to lost the snippet portability.

DEMO

LSP integration

Nested snippet expansion

<Plug(vsnip-cut-text) with $TM_SELECTED_TEXT

<Plug&rt;(vsnip-cut-text) with $TM_SELECTED_TEXT

Development

How to run test it?

You can run npm run test after install vim-themis.

How sync same tabstop placeholders?

  1. compute the user-diff ... s:Session.flush_changes
  2. reflect the user-diff to snippet ast ... s:Snippet.follow
  3. reflect the sync-diff to buffer content ... s:Snippet.sync & s:Session.flush_changes

vim-vsnip's People

Contributors

aca avatar adrian5 avatar artanikin avatar girishji avatar hokorobi avatar hrsh7th avatar ironsigma avatar jandamm avatar kitagry avatar kuuote avatar lunush avatar matsui54 avatar mg979 avatar mityu avatar mrnugget avatar muniftanjim avatar nivanchenko avatar phongnh avatar raafatturki avatar rafamadriz avatar refractalize avatar seandewar avatar svermeulen avatar uga-rosa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-vsnip's Issues

Bug: Can't enable vsnip when some snippet exists

about

Can't enable vsnip when some snippet exists.

NVIM v0.4.3
deoplete latest at 2020/07/17
vsnip latest at 2020/07/17

minimal repro

in python.json

{
	"Quicksort": {
		"prefix": ["quicksort"],
		"body": [
			"def quicksort(l):",
			"	if len(l) <= 1:",
			"		return l",
			"	else:",
   			"	    pivot = l.pop()",
   			"	    greater, lesser = [], []",
   			"	    for el in l:",
   			"	        if el > pivot:",
   			"	            greater.append(el)",
   			"	        else:",
   			"	            lesser.append(el)",
   			"	    return quicksort(lesser) + [pivot] + quicksort(greater)"
		]
	}
}

with this, vsnip doesn't run nor show all other snippets in deoplete.

....However, below works.

{
	"Quicksort": {
		"prefix": ["quicksort"],
		"body": [
			"def quicksort(l):"
		]
	}
}

I thought maybe : in last sentence makes wrong, but not. Below works.

	"Def": {
		"prefix": ["def"],
		"body": [
			"def ${1:defname}($2):",
			"    $0"
		]
	}

Any suggestion is appreciated. I look into code but couldn't find any causes...

Doc Issue: *vsnip-variable*

The let commands in the vsnip-variable section all end in ~. I don't think that should be there and Vim (8.2) complains if it is there.

Scripting support

This feature would be useful.
But I worry to the feature makes it lose portability.

How to use the same snippets for different filetypes?

I'm trying to see if I can migrate from UltiSnips & in UltiSnips you can extend multiple snippets to be included for the current filetype you have. For example:

html.snippets

snippet html
<!DOCTYPE html>
<html>
	<head>
		<title>${1:Title}</title>
		<meta charset="utf8">
		<meta name="viewport" content="initial-scale=1, width=device-width">
		<link rel="stylesheet" href="${2:style.css}">
	</head>
	<body>
		$0
		<script src="${3:bundle.js}"></script>
	</body>
</html>
endsnippet

jinja.snippets

extend html 

snippet for
{% for ${1} in ${2} %}
	${0:${VISUAL}}
{% endfor %}
endsnippet

I can also do this for django templating since it is nearly identical to jinja

htmldjango.snippets

extend html, jinja

or

extend jinja

Can this be done or not? (I assume no, but wanted to check)

Visual mode snippet expansion

I'm currently migrating from UltiSnips.
It is possible to use $VISUAL there which is the text which was selected when triggering the snippet:
You select text, type an expansion keystroke, type the snippet and then again the keystroke (in insert)
Then the snippet is expanded and every appearance of $VISUAL is replaced. Not literally - using VISUAL as a placeholder was supported as well.

Reading the docs from Microsoft $TM_SELECTED_TEXT should be the equivalent. But I haven't got it to work yet.
Is this supported yet?

Can't escape \n

minimal reproduce

	"PrintArrayWithBreak": {
		"prefix": ["printarraywithbreak"],
		"body": [
			"print($1, sep='\\n')$0"
		]
	},

    # ideal output that vscode does
    # print(, sep='\n') 

    # Actual output
    # print(, sep='n') 

I thought it can be fixed here,

# autoload/vsnip.vim
function! vsnip#get_context() abort
  let l:before_text = getline('.')[0 : col('.') - 2]
  for l:source in vsnip#source#find(&filetype)
    for l:snippet in l:source
      for l:prefix in (l:snippet.prefix + l:snippet.prefix_alias)
        let l:match = matchlist(l:before_text, printf('\%(\(\k\+\)\V%s\m\)\=\<\(\V%s\m\)\>$',
              \   escape(g:vsnip_auto_select_trigger, '\'),
              \   escape(l:prefix, '\'),
              \ ))

but sorry, I can't understand the \%(\(\k\+\)\V%s\m\)\=\<\(\V%s\m\)\>$ part... so I couldn't fix.
Do you think it's able to fix?

[Question] How to call s:jump(1) from vimrc?

Thank you for this great plugin.

I like to map the same key with deoplete and ultisnips, and I succeeded with Expand like below. (I map enter to expand.)

fun! DeoEnter()
        if vsnip#available(1)
                call vsnip#expand()
                return "\<c-y>"
        endif

        call UltiSnips#ExpandSnippetOrJump()
        if g:ulti_expand_or_jump_res > 0
                return ""
        endif

        if pumvisible()
                return "\<c-y> "
        endif

        return "\n"
endfun
ino <CR> <C-R>=DeoEnter()<CR>

However, I couldn't achieve to Jump because I have no idea to call s:jump(1) from vimrc. Below is my try.

fun! DeoTab()
        if vsnip#available(1)
                "" I want to call s:jump(1) here.
                return ""
        endif

        if pumvisible()
                return "\<C-n> "
        endif

        return "\<Tab>"
endfun
ino <Tab> <C-R>=DeoTab()<CR>

Do you have an any idea?

I've found this article https://groups.google.com/forum/#!topic/vim_use/bUE3yaAQXRc, and it shows like

" referencee.vim:
    function Scope()
      return s:
    endfunction
    let s:mile = 'XD'

" referencer.vim:
    let s = Scope()
    echo s['mile']
    " ==> 'XD'

From above, I think it's good to offer scope from plugin maybe...? If it's good to you, I will send PR.

Provide a default value for TM_SELECTED_TEXT

Using ${TM_SELECTED_TEXT:abc} in a snippet, I would expect abc to be inserted when I haven't selected any text.
Instead '' (empty string) is inserted.

Is this an issue with Vsnips or is this the expected behavior from VSCode?

Incorrect placeholder selection

When the place holder has only 1 character

  "test": {
    "prefix": "dt",
    "body": "const { ${1:a} } = ${2:props};${0}"
  }

The selection expand to the beginning of line
image

But if the placeholder has more than 1 character

  "test": {
    "prefix": "dt",
    "body": "const { ${1:name} } = ${2:props};${0}"
  },

It works correctly

image

Lua error

I get the Lua error when I try to do anything with vsnips. I have the latest vsnips installed.

The two screenshots show the error and my vim version. I only have the following defined in my vimrc:

let g:vsnip_snippet_dir = expand('C:/Vim/vimfiles/vsnip')
imap <expr> <S-Tab> vsnip#available(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>'
smap <expr> <S-Tab> vsnip#available(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>'
imap <expr> <Tab> vsnip#available() ? '<Plug>(vsnip-expand-or-jump)' : '<Tab>'
smap <expr> <Tab> vsnip#available() ? '<Plug>(vsnip-expand-or-jump)' : '<Tab>'
vim_version
vsnips_error

Incorrect tabstop placement

Hi, I tried the following snippet:

  "test": {
    "prefix": "test",
    "body": [
        "name ${1:test}",
        "id ${2:test}"
    ],
    "description": "test"
  }

When expanding the snippet I get:

imagen

As you can see the cursor and the visual selection is one column ahead from the placeholder

Read &runtime/snippets/*.json

Hi, @hrsh7th. Thank you for nice plugin.
I would like to use existing vscode snippets. And, I don't want to install unnecessary files. So, I created repository which includes only snippets.
But, vsnip doesn't load &runtimepath/snippets/*.json. So, users should write g:vsnip_snippet_dirs for the path. If you like this idea, wouldn't you change vsnip to load these?

If you don't like this idea, Please close this issue.
Thank you!

Question: using snippets from vscode plugins

Hi,

The readme states that one can seemingly use snippets defined from vscode plugins.
As written, I've added Plug 'microsoft/vscode-go' to my init.vim file, though I don't know how to trigger the expansion of a snippet prefix to an actual snippet.

If i write iferr - a prefix defined in the abovementioned vscode plugin, how do I go about turning it into actual code afterwards?

Escaping $ doesn't work

I have the following snippet:

"USAGE of function parameters": { "prefix": "usage", "body": [ "##################################################", "# If the arguments passed to the script equal 0", "# show the usage or help for the script.", "##################################################", "if [ $# -eq 0 ]; then", " ${1:#code}", " exit", "fi" ], "description": "Show usage or help if no parameters" },

The snippet expansion stops in the if statement because of the $ (i.e. $#). I tried escaping it with a slash (i.e. $#) but that didn't work.

I see nothing in the docs that covers this.

Create integration tests

The users of vsnip is increasing a little so we should write integration tests.

Currently, I don't know how write it in vim-themis but I think it can be wrote by hack with feedkey.

feature requests

Hi, thanks for the plugin, I think the following features would be very interesting:

  • deoplete integration
  • search for plugin in runtime path so plugin developers can add snippets in their plugins
  • integration with neovim built-in LSP client (lua)

Automatic select feature invoke unexpectedly

{
  "map": {
    "prefix": "map",
    "body": ["map(() => { $1 })"]
  }
}

array.map#<Tab>

Then vsnip remove until 'array' that behavior is not expected.

I will introduce g:vsnip_select_trigger that's default value is empty.

Jump vs Expand

Currently implementation says "prefer jump than expand".
But it is not expected spec (just implementation).

I think vsnip should use expand instead of jump.

Question: Is it possible to jump when current text is still selected?

I'm trying to figure out how to do something using the example snippet linked in the readme:

{
  "Class": {
    "prefix": ["class"],
    "body": [
      "class $1 ${2:extends ${3:Parent} }{",
      "\tconstructor() {",
      "\t\t$0",
      "\t}",
      "}"
    ],
    "description": "Class definition template."
  }
}

What I'd like to do is be able to jump past "extends" when it hops to there after the first expand.

Maybe a little more clear:

Step 1:

class

Step 2: Expand

class | extends Parent {
    constructor() {
        
    }
}

Step 3: Type in name:

class MyClass extends Parent {
    constructor() {
        
    }
}

Step 4: Jump to next

class MyClass |extends Parent| {
    constructor() {
        
    }
}

(extends parent is highlighted)

My question is how to jump to the next placeholder without changing or typing anything here (for me, it does not seem that vsnip-jump-next works the way I expect).

In other words I'd like to be able to cycle forward and backward on the placeholders without typing anything other than "jump-next".

$0 doesn't work if it isn't the last item.

I have a shell script snippet defined as:

"WHILE Loop with file input": { "prefix": "whilef", "body": [ "while read f; do", " $0", "done < ${1:file_to_read}" ], "description": "While loop with read file snippet" }

When the snippet runs, it takes me to $1 where I insert the file name and then when I tab nothing happens.

I would expect the cursor to end up wherever the $0 is defined in the snippet.

Snippets can be overwritten with LSP

If I have a snippet with the same name as the LSP completion item, the snippet will not be displayed in the list of auto-completion items.
Steps to reproduce:

  1. Create the following snippet
{
  "test": {
    "prefix": ["set"],
    "body": [
      "set test ${1:element}"
    ],
    "description": "test"
  }
}
  1. Open .vim file with vim-language-server enabled.
  2. Type "se".

Actual behavior:
Auto-completion show only "set" completion from LSP.

Expected behavior:
Auto-completion show "set" from LSP and "set" from vim-vsnip.

Note:
If you change snippet name to something like "mysnippet", auto-completion will show it. I have the same issue with clangd that shows functions with the same names (but with different overloads). It would be very useful to add snippets with the same nave (like snippet overloads). For example, C++ have two for loops, range-based and index-based. Also clangd provides only one for snippet that is not very useful and I would like to create my own.
Is it even possible to fix? And is this the right place for the issue?
I tested it in asyncomplete and vim-lsp.

Improve internal variable handling

Currently, vsnip does convert variable-node to text-node when initializing snippet.

I think we should change this approach to the below.

  1. Don't convert variable-node to text-node
  2. Support transform feature that defined in spec
  3. Add ability to customize variable-resolver (builtin variables should be realized by it)

E212: Can't open file for writing

system: windows 10

repetition: After installing the plug-in, use the "VsnipOpe" command in vim as required by Readme.

I've created a directory of "~\.vsnip" and everything is fine.

Snippet deactivated after nested completion

Steps to reproduce:

  1. Download akd (small project with few files, just for example)
  2. Open main.cpp.
  3. Add #include <algorithm>.
  4. type std::string test;.
  5. Try to pass it into std::generate. This function accept iterators. If I pass just test - snippet will not deactivated. But if I pass test.begin() iterator - snippet will be deactivated.

Tested with asyncomplete and vim-lsp.

Video:
asciicast

vsnip configuration:

let g:vsnip_snippet_dir = expand('~/.config/nvim/vsnip')
let g:vsnip_integ_config = {}
let g:vsnip_integ_config.auto_expand = v:true

imap <expr> <Tab> pumvisible() ? '<Down>' : vsnip#available(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>'
smap <expr> <Tab> pumvisible() ? '<Down>' : vsnip#available(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>'
imap <expr> <C-Tab> pumvisible() ? '<Up>' : '<Plug>(vsnip-jump-prev)'
smap <expr> <C-Tab> pumvisible() ? '<Up>' : '<Plug>(vsnip-jump-prev)'

`s:Snippet.follow` does not handle nested placeholder correctly

For example, the below go's struct field snippet corrupted when edited $4 placeholder.

  "struct-prop": {
    "prefix": ["sp", "struct-prop"],
    "body": [
      "${1:key-name} ${2:type-name} ${3:`json:\"${4:$1}${5:,omitempty}\"`}$0"
    ]
  }

I think it caused by s:Snippet.follow...

Snippet expansion in clangd headers

When I #include <header> snippet (provided by clangd) it suggest headers with >. So, when i using autocomplete I have one extra symbol inserted. Is it vim-vsnip issue?
asciicast

snippet showing twice

Any reason why it shows the snippet twice?

And with vsnip:class and another one just class? I would like to avoid using vsnip:....

image

Regex + transformations are not supported?

I can't get this to work it throws an error, $TM_FILENAME_BASE by itself works fine

{
  "test": {
    "prefix": "test",
    "body": "${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}"
  }
}
Error detected while processing function
<SNR>101_expand[1]
vsnip#expand[7]
vsnip#anonymous[4]
33[1]
17[1]
vsnip#snippet#parser#parse[7]
E605: Exception not caught: {"result": [false, null, 0], "text": "${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}"}
Error detected while processing function
<SNR>101_expand[1]
vsnip#expand[7]
E171: Missing :endif

Creating code snippets is tedious.

I found that when the code fragment exceeds 18 lines, it is extremely cumbersome to write. Is there a way to solve this problem?
The following content, I want to save as ``xor binary classification'' code for demonstration, but I can not find the skills related to the big code segment in vsCode docs, because most of the "deep learning" code The composition is all repetitive code, only some internal changes are required.

CLICK ME
import torch
import torch.nn as nn
from torch.utils.data import IterableDataset, DataLoader

from ignite.engine import Events, create_supervised_trainer, create_supervised_evaluator
from ignite.metrics import Accuracy, Loss 

from ignite.contrib.handlers.visdom_logger import *

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.fc1 = nn.Linear(2,3,True)
        self.fc2 = nn.Linear(3,1,True)

    def forward(self, x):
        x= torch.sigmoid(self.fc1(x))
        x = self.fc2(x)
        return x 

class XorDataset(IterableDataset):
    def __init__(self):
        super(XorDataset).__init__()
        self.inputs = [[0,0],[0,1],[1,0],[1,1]]
        self.targets = [[0],[1],[1],[0]]
        self.inputs = list(map(torch.Tensor, self.inputs))
        self.targets = list(map(torch.Tensor, self.targets))

    def __iter__(self):
        result = (i for i in zip(self.inputs, self.targets))
        return result

def get_data_loaders():
    xor_dataset = XorDataset()
    train_loader = val_looader = xor_dataloader = DataLoader(xor_dataset)
    return train_loader, val_looader


if __name__ == "__main__":
    net = Net()
    train_loader, val_loader = get_data_loaders()
    optimizer = torch.optim.SGD(net.parameters(), lr=0.01)
    criterion = nn.MSELoss()

    trainer = create_supervised_trainer(net, optimizer, criterion)
    
    def thresholded_output_transform(output):
        y_pred, y = output
        y_pred = torch.round(y_pred)
        return y_pred, y

    val_metrics = {
        "accuracy": Accuracy(thresholded_output_transform),
        "nll": Loss(criterion)
    }
    
    evaluator = create_supervised_evaluator(net, metrics=val_metrics)

    @trainer.on(Events.ITERATION_COMPLETED(every=5000))
    def log_training_loss(trainer):
        print("Epoch[{}] Loss: {:.2f}".format(trainer.state.epoch, trainer.state.output))

    @trainer.on(Events.EPOCH_COMPLETED)
    def log_training_results(trainer):
        evaluator.run(train_loader)
        # metrics = evaluator.state.metrics
        # print("Training Results - Epoch: {}  Avg accuracy: {:.2f} Avg loss: {:.2f}"
        #   .format(trainer.state.epoch, metrics["accuracy"], metrics["nll"]))

    @trainer.on(Events.EPOCH_COMPLETED)
    def log_validation_results(trainer):
        evaluator.run(val_loader)
        # metrics = evaluator.state.metrics
        # print("Validation Results - Epoch: {}  Avg accuracy: {:.2f} Avg loss: {:.2f}"
        #   .format(trainer.state.epoch, metrics["accuracy"], metrics["nll"]))

    vd_logger = VisdomLogger()
    vd_logger.attach_output_handler(
        evaluator,
        event_name=Events.EPOCH_COMPLETED,
        tag="training",
        metric_names=["nll", "accuracy"],
        global_step_transform=global_step_from_engine(trainer),
    )
    

    trainer.run(train_loader, max_epochs=20000)

compatibility with older vim?

Is there a reason why it's using getbufline() and related functions, instead of getline()?
Are there cases where the working buffer is not the current buffer?

Add snippets preview

I would like to suggest to add a preview for snippets. Is it possible? For example, QtCreator have this feature:
изображение

P.S. Sorry for a lot of issues :)

Write integration tests.

I want to add integration test.

But currently vim-vsnip uses feedkeys and select-mode.
I don't know how to write those features tests...

Escape backslash?

Is it possible to escape backslashes?

	"Test": {
		"prefix": ["test"],
		"body": [
			"Test\\nShould be on a single line$0"
		],
		"description": ""
	}

I would like Test snippet to be expanded to:

Test\nShould be on a single line

But I get error like:
image

Change snippet deactivation appeoach

Currently, vsnip will deactivate when received diff that out of range for snippet.

This approach has problem that related to other plugin modification.

So I think we should change the approach to use InsertEnter position instead of TextChanged range.

I should know InsertEnter timing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.