Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to list all the available snippets? #201

Open
navxio opened this issue Jul 3, 2021 · 1 comment
Open

Is there a way to list all the available snippets? #201

navxio opened this issue Jul 3, 2021 · 1 comment

Comments

@navxio
Copy link

navxio commented Jul 3, 2021

for the given file type of course

@felixr
Copy link

felixr commented Oct 4, 2021

Have a look at

let l:sources = vsnip#source#find(bufnr('%'))
" Search prefix
for l:source in l:sources
for l:snippet in l:source
for l:prefix in l:snippet.prefix
let l:prefix_len = strchars(l:prefix)
if strcharpart(l:before_text, l:before_text_len - l:prefix_len, l:prefix_len) !=# l:prefix
continue
endif
if l:prefix =~# '^\h' && l:before_text !~# '\<\V' . escape(l:prefix, '\/?') . '\m$'
continue
endif
return s:create_context(l:snippet, l:before_text_len, l:prefix_len)
endfor
endfor
endfor

The code calls vsnip#source#find(bufnr('%')) to get all snippets from all sources for the current buffer (`bufnr('%')). It returns a list of list of snipped (ie [ [ snip, snip], [snip, ...] ]) and each snippet is a dictionary matching the JSON

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants