2015-07-11 10:17:50 -04:00
|
|
|
if exists("b:did_autoload_ultisnips") || !exists("g:_uspy")
|
2015-08-10 16:46:05 -04:00
|
|
|
finish
|
2014-02-11 01:56:56 -05:00
|
|
|
endif
|
2015-07-11 10:17:50 -04:00
|
|
|
let b:did_autoload_ultisnips = 1
|
2014-02-11 01:56:56 -05:00
|
|
|
|
2015-07-11 10:17:50 -04:00
|
|
|
" Also import vim as we expect it to be imported in many places.
|
|
|
|
exec g:_uspy "import vim"
|
|
|
|
exec g:_uspy "from UltiSnips import UltiSnips_Manager"
|
2014-02-11 01:56:56 -05:00
|
|
|
|
|
|
|
function! s:compensate_for_pum()
|
|
|
|
""" The CursorMovedI event is not triggered while the popup-menu is visible,
|
|
|
|
""" and it's by this event that UltiSnips updates its vim-state. The fix is
|
|
|
|
""" to explicitly check for the presence of the popup menu, and update
|
|
|
|
""" the vim-state accordingly.
|
|
|
|
if pumvisible()
|
2014-02-14 17:58:00 -05:00
|
|
|
exec g:_uspy "UltiSnips_Manager._cursor_moved()"
|
2014-02-11 01:56:56 -05:00
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
2014-03-06 03:10:48 -05:00
|
|
|
function! UltiSnips#Edit(bang, ...)
|
2014-02-11 01:56:56 -05:00
|
|
|
if a:0 == 1 && a:1 != ''
|
|
|
|
let type = a:1
|
|
|
|
else
|
2014-03-15 10:55:03 -04:00
|
|
|
let type = ""
|
2014-02-11 01:56:56 -05:00
|
|
|
endif
|
2014-03-06 03:10:48 -05:00
|
|
|
exec g:_uspy "vim.command(\"let file = '%s'\" % UltiSnips_Manager._file_to_edit(vim.eval(\"type\"), vim.eval('a:bang')))"
|
|
|
|
|
|
|
|
if !len(file)
|
|
|
|
return
|
|
|
|
endif
|
2014-02-11 01:56:56 -05:00
|
|
|
|
|
|
|
let mode = 'e'
|
|
|
|
if exists('g:UltiSnipsEditSplit')
|
|
|
|
if g:UltiSnipsEditSplit == 'vertical'
|
|
|
|
let mode = 'vs'
|
|
|
|
elseif g:UltiSnipsEditSplit == 'horizontal'
|
|
|
|
let mode = 'sp'
|
2018-04-01 02:49:15 -04:00
|
|
|
elseif g:UltiSnipsEditSplit == 'tabdo'
|
|
|
|
let mode = 'tabedit'
|
2014-08-28 08:34:33 -04:00
|
|
|
elseif g:UltiSnipsEditSplit == 'context'
|
|
|
|
let mode = 'vs'
|
|
|
|
if winwidth(0) <= 2 * (&tw ? &tw : 80)
|
|
|
|
let mode = 'sp'
|
|
|
|
endif
|
2014-02-11 01:56:56 -05:00
|
|
|
endif
|
|
|
|
endif
|
2014-09-13 19:15:59 -04:00
|
|
|
exe ':'.mode.' '.escape(file, ' ')
|
2014-02-11 01:56:56 -05:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! UltiSnips#AddFiletypes(filetypes)
|
2016-09-07 08:51:16 -04:00
|
|
|
exec g:_uspy "UltiSnips_Manager.add_buffer_filetypes('" . a:filetypes . "')"
|
2014-02-11 01:56:56 -05:00
|
|
|
return ""
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! UltiSnips#FileTypeComplete(arglead, cmdline, cursorpos)
|
|
|
|
let ret = {}
|
|
|
|
let items = map(
|
|
|
|
\ split(globpath(&runtimepath, 'syntax/*.vim'), '\n'),
|
|
|
|
\ 'fnamemodify(v:val, ":t:r")'
|
|
|
|
\ )
|
|
|
|
call insert(items, 'all')
|
|
|
|
for item in items
|
|
|
|
if !has_key(ret, item) && item =~ '^'.a:arglead
|
|
|
|
let ret[item] = 1
|
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
|
|
|
|
return sort(keys(ret))
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! UltiSnips#ExpandSnippet()
|
|
|
|
exec g:_uspy "UltiSnips_Manager.expand()"
|
|
|
|
return ""
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! UltiSnips#ExpandSnippetOrJump()
|
|
|
|
call s:compensate_for_pum()
|
|
|
|
exec g:_uspy "UltiSnips_Manager.expand_or_jump()"
|
|
|
|
return ""
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! UltiSnips#ListSnippets()
|
|
|
|
exec g:_uspy "UltiSnips_Manager.list_snippets()"
|
|
|
|
return ""
|
|
|
|
endfunction
|
|
|
|
|
2015-12-28 07:01:26 -05:00
|
|
|
function! UltiSnips#SnippetsInCurrentScope(...)
|
2014-02-11 01:56:56 -05:00
|
|
|
let g:current_ulti_dict = {}
|
2015-12-28 07:01:26 -05:00
|
|
|
let all = get(a:, 1, 0)
|
|
|
|
if all
|
2016-01-11 10:58:42 -05:00
|
|
|
let g:current_ulti_dict_info = {}
|
2015-12-28 07:01:26 -05:00
|
|
|
endif
|
|
|
|
exec g:_uspy "UltiSnips_Manager.snippets_in_current_scope(" . all . ")"
|
2014-02-11 01:56:56 -05:00
|
|
|
return g:current_ulti_dict
|
|
|
|
endfunction
|
|
|
|
|
2015-06-17 01:51:54 -04:00
|
|
|
function! UltiSnips#SaveLastVisualSelection() range
|
2014-02-14 17:58:00 -05:00
|
|
|
exec g:_uspy "UltiSnips_Manager._save_last_visual_selection()"
|
2014-02-11 01:56:56 -05:00
|
|
|
return ""
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! UltiSnips#JumpBackwards()
|
|
|
|
call s:compensate_for_pum()
|
|
|
|
exec g:_uspy "UltiSnips_Manager.jump_backwards()"
|
|
|
|
return ""
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! UltiSnips#JumpForwards()
|
|
|
|
call s:compensate_for_pum()
|
|
|
|
exec g:_uspy "UltiSnips_Manager.jump_forwards()"
|
|
|
|
return ""
|
|
|
|
endfunction
|
|
|
|
|
2014-02-19 15:04:52 -05:00
|
|
|
function! UltiSnips#AddSnippetWithPriority(trigger, value, description, options, filetype, priority)
|
|
|
|
exec g:_uspy "trigger = vim.eval(\"a:trigger\")"
|
|
|
|
exec g:_uspy "value = vim.eval(\"a:value\")"
|
|
|
|
exec g:_uspy "description = vim.eval(\"a:description\")"
|
|
|
|
exec g:_uspy "options = vim.eval(\"a:options\")"
|
|
|
|
exec g:_uspy "filetype = vim.eval(\"a:filetype\")"
|
|
|
|
exec g:_uspy "priority = vim.eval(\"a:priority\")"
|
|
|
|
exec g:_uspy "UltiSnips_Manager.add_snippet(trigger, value, description, options, filetype, priority)"
|
|
|
|
return ""
|
|
|
|
endfunction
|
|
|
|
|
2014-02-11 01:56:56 -05:00
|
|
|
function! UltiSnips#Anon(value, ...)
|
|
|
|
" Takes the same arguments as SnippetManager.expand_anon:
|
2014-02-19 15:04:52 -05:00
|
|
|
" (value, trigger="", description="", options="")
|
2014-02-11 01:56:56 -05:00
|
|
|
exec g:_uspy "args = vim.eval(\"a:000\")"
|
|
|
|
exec g:_uspy "value = vim.eval(\"a:value\")"
|
|
|
|
exec g:_uspy "UltiSnips_Manager.expand_anon(value, *args)"
|
|
|
|
return ""
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! UltiSnips#CursorMoved()
|
2014-02-14 17:58:00 -05:00
|
|
|
exec g:_uspy "UltiSnips_Manager._cursor_moved()"
|
2014-02-11 01:56:56 -05:00
|
|
|
endf
|
|
|
|
|
|
|
|
function! UltiSnips#LeavingBuffer()
|
2014-02-14 17:58:00 -05:00
|
|
|
exec g:_uspy "UltiSnips_Manager._leaving_buffer()"
|
2014-02-11 01:56:56 -05:00
|
|
|
endf
|
|
|
|
|
|
|
|
function! UltiSnips#LeavingInsertMode()
|
2014-02-14 17:58:00 -05:00
|
|
|
exec g:_uspy "UltiSnips_Manager._leaving_insert_mode()"
|
2014-02-11 01:56:56 -05:00
|
|
|
endfunction
|
2015-06-17 12:56:46 -04:00
|
|
|
|
|
|
|
function! UltiSnips#TrackChange()
|
|
|
|
exec g:_uspy "UltiSnips_Manager._track_change()"
|
|
|
|
endfunction
|
2018-04-10 18:52:48 -04:00
|
|
|
|
|
|
|
function! UltiSnips#RefreshSnippets()
|
|
|
|
exec g:_uspy "UltiSnips_Manager._refresh_snippets()"
|
|
|
|
endfunction
|
2015-06-17 12:56:46 -04:00
|
|
|
" }}}
|