2014-10-31 17:30:24 -04:00
|
|
|
if exists("g:go_loaded_gosnippets")
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
let g:go_loaded_gosnippets = 1
|
|
|
|
|
2017-12-13 09:05:24 -05:00
|
|
|
function! s:GoUltiSnips() abort
|
|
|
|
if get(g:, 'did_plugin_ultisnips') isnot 1
|
2016-06-26 07:12:36 -04:00
|
|
|
return
|
|
|
|
endif
|
|
|
|
|
|
|
|
if !exists("g:UltiSnipsSnippetDirectories")
|
|
|
|
let g:UltiSnipsSnippetDirectories = ["gosnippets/UltiSnips"]
|
|
|
|
else
|
|
|
|
let g:UltiSnipsSnippetDirectories += ["gosnippets/UltiSnips"]
|
|
|
|
endif
|
2014-10-31 17:30:24 -04:00
|
|
|
endfunction
|
|
|
|
|
2017-12-13 09:05:24 -05:00
|
|
|
function! s:GoNeosnippet() abort
|
|
|
|
if get(g:, 'loaded_neosnippet') isnot 1
|
2016-06-26 07:12:36 -04:00
|
|
|
return
|
|
|
|
endif
|
|
|
|
|
|
|
|
let g:neosnippet#enable_snipmate_compatibility = 1
|
|
|
|
|
2017-12-13 09:05:24 -05:00
|
|
|
let l:gosnippets_dir = globpath(&rtp, 'gosnippets/snippets')
|
2016-06-26 07:12:36 -04:00
|
|
|
if type(g:neosnippet#snippets_directory) == type([])
|
2017-12-13 09:05:24 -05:00
|
|
|
let g:neosnippet#snippets_directory += [l:gosnippets_dir]
|
2016-06-26 07:12:36 -04:00
|
|
|
elseif type(g:neosnippet#snippets_directory) == type("")
|
|
|
|
if strlen(g:neosnippet#snippets_directory) > 0
|
2017-12-13 09:05:24 -05:00
|
|
|
let g:neosnippet#snippets_directory = g:neosnippet#snippets_directory . "," . l:gosnippets_dir
|
2016-06-26 07:12:36 -04:00
|
|
|
else
|
2017-12-13 09:05:24 -05:00
|
|
|
let g:neosnippet#snippets_directory = l:gosnippets_dir
|
2016-06-26 07:12:36 -04:00
|
|
|
endif
|
|
|
|
endif
|
2014-10-31 17:30:24 -04:00
|
|
|
endfunction
|
|
|
|
|
2017-12-13 09:05:24 -05:00
|
|
|
function! s:GoMinisnip() abort
|
|
|
|
if get(g:, 'loaded_minisnip') isnot 1
|
|
|
|
return
|
|
|
|
endif
|
|
|
|
|
|
|
|
if exists('g:minisnip_dir')
|
|
|
|
let g:minisnip_dir .= ':' . globpath(&rtp, 'gosnippets/minisnip')
|
|
|
|
else
|
|
|
|
let g:minisnip_dir = globpath(&rtp, 'gosnippets/minisnip')
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
|
|
let s:engine = get(g:, 'go_snippet_engine', 'automatic')
|
|
|
|
if s:engine is? "automatic"
|
|
|
|
if get(g:, 'did_plugin_ultisnips') is 1
|
|
|
|
call s:GoUltiSnips()
|
|
|
|
elseif get(g:, 'loaded_neosnippet') is 1
|
|
|
|
call s:GoNeosnippet()
|
|
|
|
elseif get(g:, 'loaded_minisnip') is 1
|
|
|
|
call s:GoMinisnip()
|
|
|
|
endif
|
|
|
|
elseif s:engine is? "ultisnips"
|
2016-06-26 07:12:36 -04:00
|
|
|
call s:GoUltiSnips()
|
2017-12-13 09:05:24 -05:00
|
|
|
elseif s:engine is? "neosnippet"
|
2016-06-26 07:12:36 -04:00
|
|
|
call s:GoNeosnippet()
|
2017-12-13 09:05:24 -05:00
|
|
|
elseif s:engine is? "minisnip"
|
|
|
|
call s:GoMinisnip()
|
2014-10-31 17:30:24 -04:00
|
|
|
endif
|
2016-06-26 07:12:36 -04:00
|
|
|
|
|
|
|
" vim: sw=2 ts=2 et
|