Fixed vim and zsh
This commit is contained in:
148
vim/plugins/ultisnips/autoload/UltiSnips.vim
Normal file
148
vim/plugins/ultisnips/autoload/UltiSnips.vim
Normal file
@ -0,0 +1,148 @@
|
||||
if exists("b:did_autoload_ultisnips") || !exists("g:_uspy")
|
||||
finish
|
||||
endif
|
||||
let b:did_autoload_ultisnips = 1
|
||||
|
||||
" 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"
|
||||
|
||||
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()
|
||||
exec g:_uspy "UltiSnips_Manager._cursor_moved()"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! UltiSnips#Edit(bang, ...)
|
||||
if a:0 == 1 && a:1 != ''
|
||||
let type = a:1
|
||||
else
|
||||
let type = ""
|
||||
endif
|
||||
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
|
||||
|
||||
let mode = 'e'
|
||||
if exists('g:UltiSnipsEditSplit')
|
||||
if g:UltiSnipsEditSplit == 'vertical'
|
||||
let mode = 'vs'
|
||||
elseif g:UltiSnipsEditSplit == 'horizontal'
|
||||
let mode = 'sp'
|
||||
elseif g:UltiSnipsEditSplit == 'context'
|
||||
let mode = 'vs'
|
||||
if winwidth(0) <= 2 * (&tw ? &tw : 80)
|
||||
let mode = 'sp'
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
exe ':'.mode.' '.escape(file, ' ')
|
||||
endfunction
|
||||
|
||||
function! UltiSnips#AddFiletypes(filetypes)
|
||||
exec g:_uspy "UltiSnips_Manager.add_buffer_filetypes('" . a:filetypes . "')"
|
||||
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
|
||||
|
||||
function! UltiSnips#SnippetsInCurrentScope(...)
|
||||
let g:current_ulti_dict = {}
|
||||
let all = get(a:, 1, 0)
|
||||
if all
|
||||
let g:current_ulti_dict_info = {}
|
||||
endif
|
||||
exec g:_uspy "UltiSnips_Manager.snippets_in_current_scope(" . all . ")"
|
||||
return g:current_ulti_dict
|
||||
endfunction
|
||||
|
||||
function! UltiSnips#SaveLastVisualSelection() range
|
||||
exec g:_uspy "UltiSnips_Manager._save_last_visual_selection()"
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
function! UltiSnips#Anon(value, ...)
|
||||
" Takes the same arguments as SnippetManager.expand_anon:
|
||||
" (value, trigger="", description="", options="")
|
||||
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()
|
||||
exec g:_uspy "UltiSnips_Manager._cursor_moved()"
|
||||
endf
|
||||
|
||||
function! UltiSnips#LeavingBuffer()
|
||||
exec g:_uspy "UltiSnips_Manager._leaving_buffer()"
|
||||
endf
|
||||
|
||||
function! UltiSnips#LeavingInsertMode()
|
||||
exec g:_uspy "UltiSnips_Manager._leaving_insert_mode()"
|
||||
endfunction
|
||||
|
||||
function! UltiSnips#TrackChange()
|
||||
exec g:_uspy "UltiSnips_Manager._track_change()"
|
||||
endfunction
|
||||
" }}}
|
72
vim/plugins/ultisnips/autoload/UltiSnips/map_keys.vim
Normal file
72
vim/plugins/ultisnips/autoload/UltiSnips/map_keys.vim
Normal file
@ -0,0 +1,72 @@
|
||||
if exists("b:did_autoload_ultisnips_map_keys") || !exists("g:_uspy")
|
||||
finish
|
||||
endif
|
||||
let b:did_autoload_ultisnips_map_keys = 1
|
||||
|
||||
" The trigger used to expand a snippet.
|
||||
" NOTE: expansion and forward jumping can, but needn't be the same trigger
|
||||
if !exists("g:UltiSnipsExpandTrigger")
|
||||
let g:UltiSnipsExpandTrigger = "<tab>"
|
||||
endif
|
||||
|
||||
" The trigger used to display all triggers that could possible
|
||||
" match in the current position.
|
||||
if !exists("g:UltiSnipsListSnippets")
|
||||
let g:UltiSnipsListSnippets = "<c-tab>"
|
||||
endif
|
||||
|
||||
" The trigger used to jump forward to the next placeholder.
|
||||
" NOTE: expansion and forward jumping can be the same trigger.
|
||||
if !exists("g:UltiSnipsJumpForwardTrigger")
|
||||
let g:UltiSnipsJumpForwardTrigger = "<c-j>"
|
||||
endif
|
||||
|
||||
" The trigger to jump backward inside a snippet
|
||||
if !exists("g:UltiSnipsJumpBackwardTrigger")
|
||||
let g:UltiSnipsJumpBackwardTrigger = "<c-k>"
|
||||
endif
|
||||
|
||||
" Should UltiSnips unmap select mode mappings automagically?
|
||||
if !exists("g:UltiSnipsRemoveSelectModeMappings")
|
||||
let g:UltiSnipsRemoveSelectModeMappings = 1
|
||||
end
|
||||
|
||||
" If UltiSnips should remove Mappings, which should be ignored
|
||||
if !exists("g:UltiSnipsMappingsToIgnore")
|
||||
let g:UltiSnipsMappingsToIgnore = []
|
||||
endif
|
||||
|
||||
" UltiSnipsEdit will use this variable to decide if a new window
|
||||
" is opened when editing. default is "normal", allowed are also
|
||||
" "vertical", "horizontal", and "context".
|
||||
if !exists("g:UltiSnipsEditSplit")
|
||||
let g:UltiSnipsEditSplit = 'normal'
|
||||
endif
|
||||
|
||||
" A list of directory names that are searched for snippets.
|
||||
if !exists("g:UltiSnipsSnippetDirectories")
|
||||
let g:UltiSnipsSnippetDirectories = [ "UltiSnips" ]
|
||||
endif
|
||||
|
||||
" Enable or Disable snipmate snippet expansion.
|
||||
if !exists("g:UltiSnipsEnableSnipMate")
|
||||
let g:UltiSnipsEnableSnipMate = 1
|
||||
endif
|
||||
|
||||
function! UltiSnips#map_keys#MapKeys()
|
||||
if g:UltiSnipsExpandTrigger == g:UltiSnipsJumpForwardTrigger
|
||||
exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=UltiSnips#ExpandSnippetOrJump()<cr>"
|
||||
exec "snoremap <silent> " . g:UltiSnipsExpandTrigger . " <Esc>:call UltiSnips#ExpandSnippetOrJump()<cr>"
|
||||
else
|
||||
exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=UltiSnips#ExpandSnippet()<cr>"
|
||||
exec "snoremap <silent> " . g:UltiSnipsExpandTrigger . " <Esc>:call UltiSnips#ExpandSnippet()<cr>"
|
||||
endif
|
||||
exec "xnoremap <silent> " . g:UltiSnipsExpandTrigger. " :call UltiSnips#SaveLastVisualSelection()<cr>gvs"
|
||||
exec "inoremap <silent> " . g:UltiSnipsListSnippets . " <C-R>=UltiSnips#ListSnippets()<cr>"
|
||||
exec "snoremap <silent> " . g:UltiSnipsListSnippets . " <Esc>:call UltiSnips#ListSnippets()<cr>"
|
||||
|
||||
snoremap <silent> <BS> <c-g>c
|
||||
snoremap <silent> <DEL> <c-g>c
|
||||
snoremap <silent> <c-h> <c-g>c
|
||||
snoremap <c-r> <c-g>"_c<c-r>
|
||||
endf
|
@ -0,0 +1,32 @@
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
let s:source = {
|
||||
\ 'name' : 'ultisnips',
|
||||
\ 'kind' : 'keyword',
|
||||
\ 'mark' : '[US]',
|
||||
\ 'rank' : 8,
|
||||
\ 'matchers' :
|
||||
\ (g:neocomplete#enable_fuzzy_completion ?
|
||||
\ ['matcher_fuzzy'] : ['matcher_head']),
|
||||
\ }
|
||||
|
||||
function! s:source.gather_candidates(context)
|
||||
let suggestions = []
|
||||
let snippets = UltiSnips#SnippetsInCurrentScope()
|
||||
for trigger in keys(snippets)
|
||||
let description = get(snippets, trigger)
|
||||
call add(suggestions, {
|
||||
\ 'word' : trigger,
|
||||
\ 'menu' : self.mark . ' '. description
|
||||
\ })
|
||||
endfor
|
||||
return suggestions
|
||||
endfunction
|
||||
|
||||
function! neocomplete#sources#ultisnips#define()
|
||||
return s:source
|
||||
endfunction
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
82
vim/plugins/ultisnips/autoload/unite/sources/ultisnips.vim
Normal file
82
vim/plugins/ultisnips/autoload/unite/sources/ultisnips.vim
Normal file
@ -0,0 +1,82 @@
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
let s:unite_source = {
|
||||
\ 'name': 'ultisnips',
|
||||
\ 'hooks': {},
|
||||
\ 'action_table': {},
|
||||
\ 'syntax' : 'uniteSource__Ultisnips',
|
||||
\ 'default_action': 'expand',
|
||||
\ }
|
||||
|
||||
let s:unite_source.action_table.preview = {
|
||||
\ 'description' : 'ultisnips snippets',
|
||||
\ 'is_quit' : 0,
|
||||
\ }
|
||||
|
||||
function! s:unite_source.hooks.on_syntax(args, context) abort
|
||||
syntax case ignore
|
||||
syntax match uniteSource__UltisnipsHeader /^.*$/
|
||||
\ containedin=uniteSource__Ultisnips
|
||||
syntax match uniteSource__UltisnipsTrigger /\v^\s.{-}\ze\s/ contained
|
||||
\ containedin=uniteSource__UltisnipsHeader
|
||||
\ nextgroup=uniteSource__UltisnipsDescription
|
||||
syntax match uniteSource__UltisnipsDescription /\v.{3}\s\zs\w.*$/ contained
|
||||
\ containedin=uniteSource__UltisnipsHeader
|
||||
|
||||
highlight default link uniteSource__UltisnipsTrigger Identifier
|
||||
highlight default link uniteSource__UltisnipsDescription Statement
|
||||
endfunction
|
||||
|
||||
function! s:unite_source.action_table.preview.func(candidate)
|
||||
" no nice preview at this point, cannot get snippet text
|
||||
let snippet_preview = a:candidate['word']
|
||||
echo snippet_preview
|
||||
endfunction
|
||||
|
||||
let s:unite_source.action_table.expand = {
|
||||
\ 'description': 'expand the current snippet',
|
||||
\ 'is_quit': 1
|
||||
\}
|
||||
|
||||
function! s:unite_source.action_table.expand.func(candidate)
|
||||
let delCurrWord = (getline(".")[col(".")-1] == " ") ? "" : "diw"
|
||||
exe "normal " . delCurrWord . "a" . a:candidate['trigger'] . " "
|
||||
call UltiSnips#ExpandSnippet()
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! s:unite_source.get_longest_snippet_len(snippet_list)
|
||||
let longest = 0
|
||||
for snip in items(a:snippet_list)
|
||||
if strlen(snip['word']) > longest
|
||||
let longest = strlen(snip['word'])
|
||||
endif
|
||||
endfor
|
||||
return longest
|
||||
endfunction
|
||||
|
||||
function! s:unite_source.gather_candidates(args, context)
|
||||
let default_val = {'word': '', 'unite__abbr': '', 'is_dummy': 0, 'source':
|
||||
\ 'ultisnips', 'unite__is_marked': 0, 'kind': 'command', 'is_matched': 1,
|
||||
\ 'is_multiline': 0}
|
||||
let snippet_list = UltiSnips#SnippetsInCurrentScope()
|
||||
let max_len = s:unite_source.get_longest_snippet_len(snippet_list)
|
||||
let canditates = []
|
||||
for snip in items(snippet_list)
|
||||
let curr_val = copy(default_val)
|
||||
let curr_val['word'] = printf('%-*s', max_len, snip[0]) . " " . snip[1]
|
||||
let curr_val['trigger'] = snip[0]
|
||||
call add(canditates, curr_val)
|
||||
endfor
|
||||
return canditates
|
||||
endfunction
|
||||
|
||||
function! unite#sources#ultisnips#define()
|
||||
return s:unite_source
|
||||
endfunction
|
||||
|
||||
"unlet s:unite_source
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
Reference in New Issue
Block a user