From 5b4bb0d310ddd65417a19a89f14f7d5bb3bd0cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20L=C3=B3pez?= Date: Thu, 2 Jun 2016 22:03:22 +0000 Subject: [PATCH] Add g:snipmate_default_choice option --- doc/snipMate.txt | 9 ++++++++- plugin/snipMate.vim | 10 +++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/doc/snipMate.txt b/doc/snipMate.txt index 521235d9..a6e8e737 100644 --- a/doc/snipMate.txt +++ b/doc/snipMate.txt @@ -221,12 +221,19 @@ in the current buffer to show a list via |popupmenu-completion|. ============================================================================== SETTINGS *snipMate-settings* *g:snips_author* -The g:snips_author string (similar to $TM_FULLNAME in TextMate) should be set +The `g:snips_author string (similar to $TM_FULLNAME in TextMate) should be set to your name; it can then be used in snippets to automatically add it. E.g.: > let g:snips_author = 'Hubert Farnsworth' snippet name `g:snips_author` +< + *g:snipmate_default_choice* + +The `g:snipmate_default_choice` variable is provided to select in advance an +option when snipmate output several alternatives, by default it selects none > + + let g:snipmate_default_choice = 1 < *snipMate-expandtab* *snipMate-indenting* If you would like your snippets to be expanded using spaces instead of tabs, diff --git a/plugin/snipMate.vim b/plugin/snipMate.vim index ef03b12b..115992e1 100644 --- a/plugin/snipMate.vim +++ b/plugin/snipMate.vim @@ -223,14 +223,18 @@ fun s:GetSnippet(word, scope) endf fun s:ChooseSnippet(scope, trigger) - let snippet = [] + if !exists('g:snipmate_default_choice') | let snippet = [] | else | let snippet = "" | endif let i = 1 for snip in s:multi_snips[a:scope][a:trigger] - let snippet += [i.'. '.snip[0]] + if !exists('g:snipmate_default_choice') | let snippet += [i.'. '.snip[0]] | else | let snippet .= i.'. '.snip[0] . "\n" | endif let i += 1 endfor if i == 2 | return s:multi_snips[a:scope][a:trigger][0][1] | endif - let num = inputlist(snippet) - 1 + if !exists('g:snipmate_default_choice') | let num = inputlist(snippet) - 1 + else + let snippet .= 'Type number and or press to cancel: ' + let num = str2nr(input(snippet, g:snipmate_default_choice)) - 1 + endif return num == -1 ? '' : s:multi_snips[a:scope][a:trigger][num][1] endf