Open NCSantos opened 6 years ago
That function does not work at all for me. When I type lor<C-l>
, I get lolorem
as result. Can you try with a lorem ipsum snippet too?
In what filetype that snippet should work?
My real goal here is to create a function that expands if there is only 1 match (its what that function does) or lists snippets if there is more than 1.
@NCSantos Try this one: https://github.com/honza/vim-snippets/blob/master/UltiSnips/all.snippets#L59, just copy & paste it into all.snippets.
I understand the motivation for this, however as said the snippet in the documentation does not work for me at all. I need to repro in a cleaner env eventually.
@SirVer For me the lorem snippet expands ok.
@NCSantos For me it only works in the first line of a file. Weird... See screencast below:
@SirVer For me it works every where.
The problem is that Ultisnips is moving 1 char back.
For example you only have this snippets:
snippet f1 "f1" b
f1
endsnippet
snippet f2 "f2" b
f2
endsnippet
snippet b1 "b1" b
b1
endsnippet
On vim in insert mode you do:
f<trigger>
This will show a list with all snippets, f1, f2 and b1.
If you,e.g., choose f1 snippet from the list it will insert in vim:
f1f
If on vim in insert mode you do:
f1<trigger>
It will show a list with snippets f1 and f2.
Again if you coose f1 snippet from the list it will insert in vim:
f1f
It is moving 1 char back,
Sorry forgot the function:
function! s:ListSnip()
call UltiSnips#ListSnippets()
return ""
endfunction
inoremap <silent> <leader>s <ESC>:call <SID>ListSnip()<CR>
@NCSantos I understand your problem, but I am unable to repro because it does not work for me in the first place :/.
@SirVer Tried it in a new vim install and it works as I mentioned.
~$ tree -L 4 .vim/
.vim/
└── pack
└── plugins
└── start
├── ultisnips
└── vim-snippets
5 directories, 0 files
.vimrc
set nocompatible
filetype plugin on
let mapleader = ","
function! s:ListSnip()
call UltiSnips#ListSnippets()
return ""
endfunction
inoremap <silent> <leader>s <ESC>:call <SID>ListSnip()<CR>
On vim, c file, I insert:
func<trigger>
<trigger>
being the function ListSnip() keymap.
From menu I choose 1 and get:
void function_name()
{
}c
As you can see it goes a char back and puts 'c' in the end.
I was able to reproduce both the original post & the problem described in the last post at c4bb89495a2af3ed41a510db9a2f589748643801 inside of make repro
. The problem seems more involved to fix, it seems bad interplay between Vim & python execution timing.
Using the function described on Ultisnips help:
It adds a space to the end of the snippet, like:
<space>
beeing only " ".Is there a way to prevent this?
Thanks.