From 61291ecd838361dc6b418e65a91e19124ce18c40 Mon Sep 17 00:00:00 2001 From: Holger Rapp Date: Sun, 21 Apr 2013 17:18:14 +0200 Subject: [PATCH] Completion for UltiSnipsEdit. Patch by Zhao Cai. --- doc/UltiSnips.txt | 1 + plugin/UltiSnips.vim | 29 ++++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/doc/UltiSnips.txt b/doc/UltiSnips.txt index c469404..9d75b86 100644 --- a/doc/UltiSnips.txt +++ b/doc/UltiSnips.txt @@ -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* diff --git a/plugin/UltiSnips.vim b/plugin/UltiSnips.vim index e71b385..f5acf4c 100644 --- a/plugin/UltiSnips.vim +++ b/plugin/UltiSnips.vim @@ -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 = "" 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 = "" 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 = "" @@ -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() +command! -nargs=? -complete=customlist,UltiSnipsFiletypeComplete UltiSnipsEdit + \ :call UltiSnipsEdit() " 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 {{{