2014-10-31 21:30:24 +00:00
|
|
|
if exists("g:go_loaded_gosnippets")
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
let g:go_loaded_gosnippets = 1
|
|
|
|
|
|
|
|
" by default UltiSnips
|
|
|
|
if !exists("g:go_snippet_engine")
|
2016-06-26 11:12:36 +00:00
|
|
|
let g:go_snippet_engine = "ultisnips"
|
2014-10-31 21:30:24 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
function! s:GoUltiSnips()
|
2016-06-26 11:12:36 +00:00
|
|
|
if globpath(&rtp, 'plugin/UltiSnips.vim') == ""
|
|
|
|
return
|
|
|
|
endif
|
|
|
|
|
|
|
|
if !exists("g:UltiSnipsSnippetDirectories")
|
|
|
|
let g:UltiSnipsSnippetDirectories = ["gosnippets/UltiSnips"]
|
|
|
|
else
|
|
|
|
let g:UltiSnipsSnippetDirectories += ["gosnippets/UltiSnips"]
|
|
|
|
endif
|
2014-10-31 21:30:24 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! s:GoNeosnippet()
|
2016-06-26 11:12:36 +00:00
|
|
|
if globpath(&rtp, 'plugin/neosnippet.vim') == ""
|
|
|
|
return
|
|
|
|
endif
|
|
|
|
|
|
|
|
let g:neosnippet#enable_snipmate_compatibility = 1
|
|
|
|
|
|
|
|
let gosnippets_dir = globpath(&rtp, 'gosnippets/snippets')
|
|
|
|
if type(g:neosnippet#snippets_directory) == type([])
|
|
|
|
let g:neosnippet#snippets_directory += [gosnippets_dir]
|
|
|
|
elseif type(g:neosnippet#snippets_directory) == type("")
|
|
|
|
if strlen(g:neosnippet#snippets_directory) > 0
|
|
|
|
let g:neosnippet#snippets_directory = g:neosnippet#snippets_directory . "," . gosnippets_dir
|
|
|
|
else
|
|
|
|
let g:neosnippet#snippets_directory = gosnippets_dir
|
|
|
|
endif
|
|
|
|
endif
|
2014-10-31 21:30:24 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
if g:go_snippet_engine == "ultisnips"
|
2016-06-26 11:12:36 +00:00
|
|
|
call s:GoUltiSnips()
|
2014-10-31 21:30:24 +00:00
|
|
|
elseif g:go_snippet_engine == "neosnippet"
|
2016-06-26 11:12:36 +00:00
|
|
|
call s:GoNeosnippet()
|
2014-10-31 21:30:24 +00:00
|
|
|
endif
|
2016-06-26 11:12:36 +00:00
|
|
|
|
|
|
|
" vim: sw=2 ts=2 et
|