Completion for UltiSnipsEdit. Patch by Zhao Cai.

This commit is contained in:
Holger Rapp 2013-04-21 17:18:14 +02:00
parent 40af7c8480
commit 61291ecd83
2 changed files with 25 additions and 5 deletions

View File

@ -1316,6 +1316,7 @@ Contributors listed in chronological order:
Stanislav Golovanov - JazzCore
David Briscoe - DavidBriscoe
Keith Welch - paralogiki
Zhao Cai - zhaocai
8.2 Snippets *UltiSnips-contrisnippets*

View File

@ -3,7 +3,7 @@
" Description: The Ultimate Snippets solution for Vim
"
" Testing Info: {{{
" See directions at the top of the test.py script located one
" See directions at the top of the test.py script located one
" directory above this file.
" }}}
@ -46,13 +46,13 @@ if !exists("g:UltiSnipsExpandTrigger")
let g:UltiSnipsExpandTrigger = "<tab>"
endif
" The trigger used to display all triggers that could possible
" 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.
" The trigger used to jump forward to the next placeholder.
" NOTE: expansion and forward jumping can, but needn't be the same trigger
if !exists("g:UltiSnipsJumpForwardTrigger")
let g:UltiSnipsJumpForwardTrigger = "<c-j>"
@ -80,7 +80,7 @@ if !exists("g:UltiSnipsEditSplit")
let g:UltiSnipsEditSplit = 'normal'
endif
" A list of directory names that are searched for snippets.
" A list of directory names that are searched for snippets.
if !exists("g:UltiSnipsSnippetDirectories")
let g:UltiSnipsSnippetDirectories = [ "UltiSnips" ]
endif
@ -107,7 +107,8 @@ function! UltiSnipsEdit(...)
endfunction
" edit snippets, default of current file type or the specified type
command! -nargs=? UltiSnipsEdit :call UltiSnipsEdit(<q-args>)
command! -nargs=? -complete=customlist,UltiSnipsFiletypeComplete UltiSnipsEdit
\ :call UltiSnipsEdit(<q-args>)
" Global Commands {{{
function! UltiSnipsAddFiletypes(filetypes)
@ -220,6 +221,24 @@ endf
function! UltiSnips_LeavingBuffer()
exec g:_uspy "UltiSnips_Manager.leaving_buffer()"
endf
" }}}
" COMPLETE FUNCTIONS {{{
function! UltiSnipsFiletypeComplete(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
" }}}
"" STARTUP CODE {{{