From ab4daaf4ce6ba6b20b1088e35be68253fcca51a2 Mon Sep 17 00:00:00 2001 From: Meng Zhuo Date: Thu, 20 Jun 2013 16:21:04 +0800 Subject: [PATCH] change blocks into sa --- UltiSnips/rst.snippets | 81 ++++++++---------------------------------- 1 file changed, 14 insertions(+), 67 deletions(-) diff --git a/UltiSnips/rst.snippets b/UltiSnips/rst.snippets index 0490c31..c70dccc 100644 --- a/UltiSnips/rst.snippets +++ b/UltiSnips/rst.snippets @@ -48,6 +48,14 @@ def get_popular_code_type(path): popular_type = "lua" # Don't break default return popular_type + +def complete(t, opts): + if t: + opts = [ m[len(t):] for m in opts if m.startswith(t) ] + if len(opts) == 1: + return opts[0] + return "({0})".format("|".join(opts)) + endglobal snippet part "Part" b @@ -157,74 +165,13 @@ snippet cont "Content Block" b $0 endsnippet -snippet tip "Tip Block" b -.. tip:: +#http://docutils.sourceforge.net/docs/ref/rst/directives.html#specific-admonitions +snippet sa "Specific Admonitions" b +.. $1`!p snip.rv =complete(t[1], ["attention", "caution", "danger", + "error", "hint", "important", "note", + "tip", "warning"])`:: - ${1:some tips} - -$0 -endsnippet - -snippet not "Note Block" b -.. note:: - - ${1:some notes} - -$0 -endsnippet - -snippet war "Warning Block" b -.. warning:: - - ${1:Warning!} - -$0 -endsnippet - -snippet imp "Important Block" b -.. important:: - - ${1:This is important} - -$0 -endsnippet - -snippet att "Attention " b -.. attention:: - - ${1:Attention!} - -$0 -endsnippet - -snippet dan "Danger" b -.. danger:: - - ${1:Danger} - -$0 -endsnippet - -snippet err "Error Block" b -.. error:: - - ${1:Errors!} - -$0 -endsnippet - -snippet cau "Cautions Block" b -.. caution:: - - ${1:Cautions!} - -$0 -endsnippet - -snippet top "Topic" b -.. topic:: ${1:title} - - ${2:contents} + ${2:Content} $0 endsnippet