Skip to content

Commit

Permalink
Merge pull request #3603 from bhcleek/auto/ultisnip-nested
Browse files Browse the repository at this point in the history
auto: do not create anonymous snippet
  • Loading branch information
bhcleek authored Nov 19, 2023
2 parents 1401b57 + b5785d3 commit 8b7a4d2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions autoload/go/auto.vim
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ function! s:ExpandSnippet() abort
" the snippet may have a '{\}' in it. For UltiSnips, that should be spelled
" \{}. fmt.Printf is such a snippet that can be used to demonstrate.
let l:snippet = substitute(v:completed_item.word, '{\\}', '\{}', 'g')

" If there are no placeholders in the returned text, then do not expand
" the snippet, because Ultisnip does not support nested snippets, and the
" user may already be in an expanded snippet. While this isn't foolproof,
" because there may be placeholders in the snippet, it at least solves the
" simple case.
if stridx(l:snippet, '$') == -1
return
endif
call UltiSnips#Anon(l:snippet, v:completed_item.word, '', 'i')
" elseif l:engine is 'neosnippet'
" " TODO(bc): make the anonymous expansion for neosnippet work
Expand Down

0 comments on commit 8b7a4d2

Please sign in to comment.