Adds 'priority' keyword and removes '!' option.
This commit is contained in:
parent
d6ebf85fc8
commit
c1b41d0fbf
@ -1,6 +1,8 @@
|
||||
# This file contains snippets that are always defined. I personally
|
||||
# have snippets for signatures and often needed texts
|
||||
|
||||
priority -50
|
||||
|
||||
##############
|
||||
# NICE BOXES #
|
||||
##############
|
||||
@ -91,15 +93,15 @@ snip.rv = box[2] + '\n' + box[3]`
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet fold "Insert a vim fold marker" !b
|
||||
snippet fold "Insert a vim fold marker" b
|
||||
`!p snip.rv = _get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]`${2:1} `!p snip.rv = _get_comment_format()[2]`
|
||||
endsnippet
|
||||
|
||||
snippet foldc "Insert a vim fold close marker" !b
|
||||
snippet foldc "Insert a vim fold close marker" b
|
||||
`!p snip.rv = _get_comment_format()[0]` ${2:1}`!p snip.rv = foldmarker()[1]` `!p snip.rv = _get_comment_format()[2]`
|
||||
endsnippet
|
||||
|
||||
snippet foldp "Insert a vim fold marker pair" !b
|
||||
snippet foldp "Insert a vim fold marker pair" b
|
||||
`!p snip.rv = _get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]` `!p snip.rv = _get_comment_format()[2]`
|
||||
${2:${VISUAL:Content}}
|
||||
`!p snip.rv = _get_comment_format()[0]` `!p snip.rv = foldmarker()[1]` $1 `!p snip.rv = _get_comment_format()[2]`
|
||||
|
@ -1,3 +1,5 @@
|
||||
priority -50
|
||||
|
||||
snippet online "Online resource" b
|
||||
@online{${1:name},
|
||||
author={${2:author}},
|
||||
|
@ -1,3 +1,5 @@
|
||||
priority -50
|
||||
|
||||
global !p
|
||||
def newsoa():
|
||||
import datetime
|
||||
|
@ -2,6 +2,8 @@
|
||||
# TextMate Snippets #
|
||||
###########################################################################
|
||||
|
||||
priority -50
|
||||
|
||||
snippet def "#define ..."
|
||||
#define ${1}
|
||||
endsnippet
|
||||
@ -12,7 +14,7 @@ snippet ifndef "#ifndef ... #define ... #endif"
|
||||
#endif
|
||||
endsnippet
|
||||
|
||||
snippet #if "#if #endif" !b
|
||||
snippet #if "#if #endif" b
|
||||
#if ${1:0}
|
||||
${VISUAL}${0:${VISUAL/(.*)/(?1::code)/}}
|
||||
#endif
|
||||
|
@ -1,5 +1,7 @@
|
||||
# From the TextMate bundle
|
||||
|
||||
priority -50
|
||||
|
||||
snippet fun "Function" b
|
||||
${1:name} = (${2:args}) ->
|
||||
${0:# body...}
|
||||
@ -87,4 +89,3 @@ endsnippet
|
||||
snippet log "Log" b
|
||||
console.log ${1:"${2:msg}"}
|
||||
endsnippet
|
||||
|
||||
|
@ -2,8 +2,12 @@
|
||||
# CoffeeScript versions -- adapted from the JS TextMate bundle + additions
|
||||
# for some jasmine-jquery matchers
|
||||
#
|
||||
priority -50
|
||||
|
||||
extends coffee
|
||||
|
||||
priority -49
|
||||
|
||||
snippet des "Describe (coffee)" b
|
||||
describe '${1:description}', ->
|
||||
$0
|
||||
@ -160,4 +164,3 @@ endsnippet
|
||||
snippet noscw "expect was not called with (coffee)" b
|
||||
expect(${1:target}).wasNotCalledWith(${2:arguments})
|
||||
endsnippet
|
||||
|
||||
|
@ -1,5 +1,10 @@
|
||||
priority -50
|
||||
|
||||
extends c
|
||||
|
||||
# We want to overwrite everything in parent ft.
|
||||
priority -49
|
||||
|
||||
###########################################################################
|
||||
# TextMate Snippets #
|
||||
###########################################################################
|
||||
|
@ -2,6 +2,7 @@
|
||||
# C# Snippets for UltiSnips #
|
||||
#######################################################################
|
||||
|
||||
priority -50
|
||||
|
||||
#########################
|
||||
# classes and structs #
|
||||
@ -325,4 +326,3 @@ snippet /// "XML comment" b
|
||||
/// $1
|
||||
/// </summary>
|
||||
endsnippet
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
# Most of these came from TextMate #
|
||||
###########################################################################
|
||||
|
||||
priority -50
|
||||
|
||||
snippet ! "!important CSS (!)"
|
||||
${1:!important}
|
||||
endsnippet
|
||||
|
@ -1,5 +1,7 @@
|
||||
# Simple shortcuts
|
||||
|
||||
priority -50
|
||||
|
||||
snippet imp "import (imp)" b
|
||||
import ${1:std.stdio};
|
||||
endsnippet
|
||||
@ -265,11 +267,11 @@ this(${1:/*args*/})
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet get "getter property (get)" !
|
||||
snippet get "getter property (get)"
|
||||
@property ${1:/*type*/} ${2:/*member_name*/}() const pure nothrow {return ${3:$2_};}
|
||||
endsnippet
|
||||
|
||||
snippet set "setter property (set)" !
|
||||
snippet set "setter property (set)"
|
||||
@property void ${1:/*member_name*/}(${2:/*type*/} rhs) pure nothrow {${3:$1_} = rhs;}
|
||||
endsnippet
|
||||
|
||||
@ -490,12 +492,11 @@ endsnippet
|
||||
# Comments
|
||||
|
||||
|
||||
snippet todo "TODO (todo)" !
|
||||
snippet todo "TODO (todo)"
|
||||
// TODO: ${1}
|
||||
endsnippet
|
||||
|
||||
|
||||
|
||||
# DDoc
|
||||
|
||||
snippet doc "generic ddoc block (doc)" b
|
||||
|
@ -1,3 +1,5 @@
|
||||
priority -50
|
||||
|
||||
# Generic Tags
|
||||
snippet %
|
||||
{% ${1} %}${2}
|
||||
|
@ -2,6 +2,8 @@
|
||||
# TEXTMATE SNIPPETS #
|
||||
###########################################################################
|
||||
|
||||
priority -50
|
||||
|
||||
snippet pat "Case:Receive:Try Clause"
|
||||
${1:pattern}${2: when ${3:guard}} ->;
|
||||
${4:body}
|
||||
|
@ -1,3 +1,5 @@
|
||||
priority -50
|
||||
|
||||
# TextMate added these variables to cope with changes in ERB handling
|
||||
# in different versions of Rails -- for instance, Rails 3 automatically
|
||||
# strips whitespace so that it's no longer necessary to use a form like
|
||||
|
@ -1,5 +1,7 @@
|
||||
# Snippets for Go
|
||||
|
||||
priority -50
|
||||
|
||||
# when to abbriviate and when not?
|
||||
# b doesn't work here, because it ignores whitespace
|
||||
# optional local name?
|
||||
@ -44,42 +46,42 @@ type ${1:Interface} interface {
|
||||
endsnippet
|
||||
|
||||
# statements
|
||||
snippet for "For loop" !b
|
||||
snippet for "For loop" b
|
||||
for ${1:condition}${1/(.+)/ /}{
|
||||
${0:${VISUAL}}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet forr "For range loop" !b
|
||||
snippet forr "For range loop" b
|
||||
for ${2:name} := range ${1:collection} {
|
||||
${0:${VISUAL}}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet if "If statement" !b
|
||||
snippet if "If statement" b
|
||||
if ${1:condition}${1/(.+)/ /}{
|
||||
${0:${VISUAL}}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet switch "Switch statement" !b
|
||||
snippet switch "Switch statement" b
|
||||
switch ${1:expression}${1/(.+)/ /}{
|
||||
case${0}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet select "Select statement" !b
|
||||
snippet select "Select statement" b
|
||||
select {
|
||||
case${0}
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet case "Case clause" !b
|
||||
snippet case "Case clause" b
|
||||
case ${1:condition}:
|
||||
${0:${VISUAL}}
|
||||
endsnippet
|
||||
|
||||
snippet default "Default clause" !b
|
||||
snippet default "Default clause" b
|
||||
default:
|
||||
${0:${VISUAL}}
|
||||
endsnippet
|
||||
@ -104,19 +106,19 @@ func ${1:name}(${2:params})${3/(.+)/ /}${3:type} {
|
||||
endsnippet
|
||||
|
||||
# types and variables
|
||||
snippet map "Map type" !b
|
||||
snippet map "Map type" b
|
||||
map[${1:keytype}]${2:valtype}
|
||||
endsnippet
|
||||
|
||||
snippet : "Variable declaration :=" !b
|
||||
snippet : "Variable declaration :=" b
|
||||
${1:name} := ${0:value}
|
||||
endsnippet
|
||||
|
||||
snippet var "Variable declaration" !b
|
||||
snippet var "Variable declaration" b
|
||||
var ${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value}}
|
||||
endsnippet
|
||||
|
||||
snippet vars "Variables declaration" !b
|
||||
snippet vars "Variables declaration" b
|
||||
var (
|
||||
${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value} }
|
||||
)
|
||||
|
@ -1,3 +1,5 @@
|
||||
priority -50
|
||||
|
||||
snippet if "if ... then ... else ..."
|
||||
if ${1:condition}
|
||||
then ${2:expression}
|
||||
|
@ -1,5 +1,7 @@
|
||||
# Snippets for VIM Help Files
|
||||
|
||||
priority -50
|
||||
|
||||
global !p
|
||||
def sec_title(snip, t):
|
||||
file_start = snip.fn.split('.')[0]
|
||||
|
@ -1,3 +1,5 @@
|
||||
priority -50
|
||||
|
||||
###########################################################################
|
||||
# TextMate Snippets #
|
||||
###########################################################################
|
||||
|
@ -1 +1,3 @@
|
||||
priority -50
|
||||
|
||||
extends html, django
|
||||
|
@ -1 +1,3 @@
|
||||
priority -50
|
||||
|
||||
extends html, jinja2
|
||||
|
@ -1,6 +1,4 @@
|
||||
###########################################################################
|
||||
# TEXTMATE SNIPPETS #
|
||||
###########################################################################
|
||||
priority -50
|
||||
|
||||
# Many of the snippets here use a global option called
|
||||
# "g:ultisnips_java_brace_style" which, if set to "nl" will put a newline
|
||||
@ -31,7 +29,7 @@ def camel(word):
|
||||
|
||||
endglobal
|
||||
|
||||
snippet sleep "try sleep catch" !b
|
||||
snippet sleep "try sleep catch" b
|
||||
try {
|
||||
Thread.sleep(${1:1000});
|
||||
} catch (InterruptedException e){
|
||||
@ -39,16 +37,16 @@ try {
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet /i|n/ "new primitive or int" !br
|
||||
snippet /i|n/ "new primitive or int" br
|
||||
${1:int} ${2:i} = ${3:1};
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet /o|v/ "new Object or variable" !br
|
||||
snippet /o|v/ "new Object or variable" br
|
||||
${1:Object} ${2:var} = new $1(${3});
|
||||
endsnippet
|
||||
|
||||
snippet f "field" !b
|
||||
snippet f "field" b
|
||||
${1:private} ${2:String} ${3:`!p snip.rv = t[2].lower()`};
|
||||
endsnippet
|
||||
|
||||
@ -60,15 +58,15 @@ snippet as "assert" b
|
||||
assert ${1:test}${2/(.+)/(?1: \: ")/}${2:Failure message}${2/(.+)/(?1:")/};$0
|
||||
endsnippet
|
||||
|
||||
snippet at "assert true" !b
|
||||
snippet at "assert true" b
|
||||
assertTrue(${1:actual});
|
||||
endsnippet
|
||||
|
||||
snippet af "assert false" !b
|
||||
snippet af "assert false" b
|
||||
assertFalse(${1:actual});$0
|
||||
endsnippet
|
||||
|
||||
snippet ae "assert equals" !b
|
||||
snippet ae "assert equals" b
|
||||
assertEquals(${1:expected}, ${2:actual});
|
||||
endsnippet
|
||||
|
||||
@ -96,7 +94,7 @@ snip.rv = snip.basename or "untitled"`} ${2:extends ${3:Parent} }${4:implements
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet clc "class with constructor, fields, setter and getters" !b
|
||||
snippet clc "class with constructor, fields, setter and getters" b
|
||||
public class `!p
|
||||
snip.rv = snip.basename or "untitled"` {
|
||||
`!p
|
||||
@ -242,11 +240,11 @@ snippet map "Collections Map" b
|
||||
Map<${1:String}, ${2:String}> ${3:map} = new ${4:Hash}Map<$1, $2>();
|
||||
endsnippet
|
||||
|
||||
snippet set "Collections Set" !b
|
||||
snippet set "Collections Set" b
|
||||
Set<${1:String}> ${2:set} = new ${3:Hash}Set<$1>();
|
||||
endsnippet
|
||||
|
||||
snippet /Str?|str/ "String" !br
|
||||
snippet /Str?|str/ "String" br
|
||||
String $0
|
||||
endsnippet
|
||||
|
||||
@ -298,7 +296,7 @@ public static void main(String[] args)`!p nl(snip)`{
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet try "try/catch" !b
|
||||
snippet try "try/catch" b
|
||||
try {
|
||||
$1
|
||||
} catch(${2:Exception} ${3:e}){
|
||||
@ -306,7 +304,7 @@ try {
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet mt "method throws" b!
|
||||
snippet mt "method throws" b
|
||||
${1:private} ${2:void} ${3:method}(${4}) ${5:throws $6 }{
|
||||
$0
|
||||
}
|
||||
@ -318,7 +316,7 @@ ${1:private} ${2:void} ${3:method}(${4}) {
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet md "Method With javadoc" !b
|
||||
snippet md "Method With javadoc" b
|
||||
/**
|
||||
* ${7:Short Description}`!p
|
||||
for i in getArgs(t[4]):
|
||||
@ -338,19 +336,19 @@ ${1:public} ${2:void} ${3:method}($4) ${5:throws $6 }{
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet /get(ter)?/ "getter" !br
|
||||
snippet /get(ter)?/ "getter" br
|
||||
public ${1:String} get${2:Name}() {
|
||||
return `!p snip.rv = t[2].lower()`;
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet /set(ter)?/ "setter" !br
|
||||
snippet /set(ter)?/ "setter" br
|
||||
public void set${1:Name}(${2:String} $1) {
|
||||
return this.`!p snip.rv = t[1].lower()` = `!p snip.rv = t[1].lower()`;
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet /se?tge?t|ge?tse?t|gs/ "setter and getter" !br
|
||||
snippet /se?tge?t|ge?tse?t|gs/ "setter and getter" br
|
||||
public void set${1:Name}(${2:String} `!p snip.rv = t[1].lower()`) {
|
||||
this.`!p snip.rv = t[1].lower()` = `!p snip.rv = t[1].lower()`;
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
priority -50
|
||||
|
||||
###########################################################################
|
||||
# TextMate Snippets #
|
||||
###########################################################################
|
||||
|
@ -1,8 +1,10 @@
|
||||
#
|
||||
priority -50
|
||||
extends javascript
|
||||
priority -49
|
||||
|
||||
# JavaScript versions -- from the TextMate bundle + some additions
|
||||
# for jasmine-jquery matchers
|
||||
#
|
||||
extends javascript
|
||||
|
||||
snippet des "Describe (js)" b
|
||||
describe('${1:description}', function() {
|
||||
@ -165,4 +167,3 @@ endsnippet
|
||||
snippet noscw "expect was not called with (js)" b
|
||||
expect(${1:target}).wasNotCalledWith(${2:arguments});
|
||||
endsnippet
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
priority -50
|
||||
|
||||
# JSDoc snippets
|
||||
|
||||
snippet /* "A JSDoc comment" b
|
||||
|
@ -1,3 +1,4 @@
|
||||
priority -50
|
||||
|
||||
# http://jinja.pocoo.org/
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
priority -50
|
||||
|
||||
snippet s "String" b
|
||||
"${1:key}": "${0:value}",
|
||||
endsnippet
|
||||
|
@ -1,3 +1,5 @@
|
||||
priority -50
|
||||
|
||||
snippet t "Transaction" b
|
||||
${1:`!v strftime("%Y")`}-${2:`!v strftime("%m")`}-${3:`!v strftime("%d")`} ${4:*} ${5:Payee}
|
||||
${6:Expenses} \$${7:0.00}
|
||||
|
@ -1,2 +1,3 @@
|
||||
extends haskell
|
||||
priority -50
|
||||
|
||||
extends haskell
|
||||
|
@ -1,3 +1,5 @@
|
||||
priority -50
|
||||
|
||||
#################################
|
||||
# Snippets for the Lua language #
|
||||
#################################
|
||||
|
@ -1,3 +1,5 @@
|
||||
priority -50
|
||||
|
||||
#################
|
||||
# From snipmate #
|
||||
#################
|
||||
|
@ -1,6 +1,4 @@
|
||||
###########################################################################
|
||||
# SNIPPETS for MARKDOWN #
|
||||
###########################################################################
|
||||
priority -50
|
||||
|
||||
###########################
|
||||
# Sections and Paragraphs #
|
||||
|
@ -1,3 +1,5 @@
|
||||
priority -50
|
||||
|
||||
###########################################################################
|
||||
# TextMate Snippets #
|
||||
###########################################################################
|
||||
|
@ -1,3 +1,5 @@
|
||||
priority -50
|
||||
|
||||
snippet rs "raise" b
|
||||
raise (${1:Not_found})
|
||||
endsnippet
|
||||
|
@ -1,3 +1,5 @@
|
||||
priority -50
|
||||
|
||||
###########################################################################
|
||||
# TextMate Snippets #
|
||||
###########################################################################
|
||||
|
@ -1,3 +1,5 @@
|
||||
priority -50
|
||||
|
||||
## Snippets from SnipMate, taken from
|
||||
## https://github.com/scrooloose/snipmate-snippets.git
|
||||
|
||||
@ -93,7 +95,7 @@ snippet var "var"
|
||||
var_export(${1});${2}
|
||||
endsnippet
|
||||
|
||||
snippet getter "PHP Class Getter" !b
|
||||
snippet getter "PHP Class Getter" b
|
||||
/*
|
||||
* Getter for $1
|
||||
*/
|
||||
@ -104,7 +106,7 @@ public function get${1/\w+\s*/\u$0/}()
|
||||
$4
|
||||
endsnippet
|
||||
|
||||
snippet setter "PHP Class Setter" !b
|
||||
snippet setter "PHP Class Setter" b
|
||||
/*
|
||||
* Setter for $1
|
||||
*/
|
||||
@ -116,7 +118,7 @@ public function set${1/\w+\s*/\u$0/}($$1)
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet gs "PHP Class Getter Setter" !b
|
||||
snippet gs "PHP Class Getter Setter" b
|
||||
/*
|
||||
* Getter for ${1/(\w+)\s*;/$1/}
|
||||
*/
|
||||
@ -136,7 +138,7 @@ public function set${1/(\w+)\s*;/\u$1/}($${1/(\w+)\s*;/$1/})
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet pub "Public function" !b
|
||||
snippet pub "Public function" b
|
||||
public function ${1:name}(${2:$param})
|
||||
{
|
||||
${VISUAL}${3:return null;}
|
||||
@ -144,7 +146,7 @@ public function ${1:name}(${2:$param})
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet pro "Protected function" !b
|
||||
snippet pro "Protected function" b
|
||||
protected function ${1:name}(${2:$param})
|
||||
{
|
||||
${VISUAL}${3:return null;}
|
||||
@ -152,7 +154,7 @@ protected function ${1:name}(${2:$param})
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet pri "Private function" !b
|
||||
snippet pri "Private function" b
|
||||
private function ${1:name}(${2:$param})
|
||||
{
|
||||
${VISUAL}${3:return null;}
|
||||
@ -160,7 +162,7 @@ private function ${1:name}(${2:$param})
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet pubs "Public static function" !b
|
||||
snippet pubs "Public static function" b
|
||||
public static function ${1:name}(${2:$param})
|
||||
{
|
||||
${VISUAL}${3:return null;}
|
||||
@ -168,7 +170,7 @@ public static function ${1:name}(${2:$param})
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet pros "Protected static function" !b
|
||||
snippet pros "Protected static function" b
|
||||
protected static function ${1:name}(${2:$param})
|
||||
{
|
||||
${VISUAL}${3:return null;}
|
||||
@ -176,7 +178,7 @@ protected static function ${1:name}(${2:$param})
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet pris "Private static function" !b
|
||||
snippet pris "Private static function" b
|
||||
private static function ${1:name}(${2:$param})
|
||||
{
|
||||
${VISUAL}${3:return null;}
|
||||
@ -184,7 +186,7 @@ private static function ${1:name}(${2:$param})
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet fu "Function snip" !b
|
||||
snippet fu "Function snip" b
|
||||
function ${1:name}(${2:$param})
|
||||
{
|
||||
${VISUAL}${3:return null;}
|
||||
@ -199,7 +201,7 @@ foreach ($${1:variable} as $${3:value}){
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet new "New class instance" !b
|
||||
snippet new "New class instance" b
|
||||
$$1 = new $1($2);
|
||||
$0
|
||||
endsnippet
|
||||
@ -213,7 +215,7 @@ if (${1:/* condition */}) {
|
||||
$0
|
||||
endsnippet
|
||||
|
||||
snippet class "Class declaration template" !b
|
||||
snippet class "Class declaration template" b
|
||||
/**
|
||||
* Class ${1:`!p snip.rv=snip.fn.split('.')[0]`}
|
||||
* @author ${2:`!v g:snips_author`}
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Snippets for Puppet
|
||||
priority -50
|
||||
|
||||
#########################################################################
|
||||
# Python helper code #
|
||||
@ -129,23 +129,23 @@ endsnippet
|
||||
# See http://docs.puppetlabs.com/references/latest/function.html #
|
||||
########################################################################
|
||||
|
||||
snippet alert "Alert Function" !b
|
||||
snippet alert "Alert Function" b
|
||||
alert("${1:message}")${0}
|
||||
endsnippet
|
||||
|
||||
snippet crit "Crit Function" !b
|
||||
snippet crit "Crit Function" b
|
||||
crit("${1:message}")${0}
|
||||
endsnippet
|
||||
|
||||
snippet debug "Debug Function" !b
|
||||
snippet debug "Debug Function" b
|
||||
debug("${1:message}")${0}
|
||||
endsnippet
|
||||
|
||||
snippet defined "Defined Function" !b
|
||||
snippet defined "Defined Function" b
|
||||
defined(${1:Resource}["${2:name}"])${0}
|
||||
endsnippet
|
||||
|
||||
snippet emerg "Emerg Function" !b
|
||||
snippet emerg "Emerg Function" b
|
||||
emerg("${1:message}")${0}
|
||||
endsnippet
|
||||
|
||||
@ -161,7 +161,7 @@ snippet extlookup "Extlookup with defaults and custom data file" b
|
||||
$${1:Variable} = extlookup("${2:Lookup}", ${3:Default}, ${4:Data Source})${0}
|
||||
endsnippet
|
||||
|
||||
snippet fail "Fail Function" !b
|
||||
snippet fail "Fail Function" b
|
||||
fail("${1:message}")${0}
|
||||
endsnippet
|
||||
|
||||
@ -193,39 +193,39 @@ snippet hiera_include "Hiera Include Function" b
|
||||
hiera_include("${1:Lookup}")${0}
|
||||
endsnippet
|
||||
|
||||
snippet include "Include Function" !b
|
||||
snippet include "Include Function" b
|
||||
include ${1:classname}${0}
|
||||
endsnippet
|
||||
|
||||
snippet info "Info Function" !b
|
||||
snippet info "Info Function" b
|
||||
info("${1:message}")${0}
|
||||
endsnippet
|
||||
|
||||
snippet inline_template "Inline Template Function" !b
|
||||
snippet inline_template "Inline Template Function" b
|
||||
inline_template("<%= ${1:template} %>")${0}
|
||||
endsnippet
|
||||
|
||||
snippet notice "Notice Function" !b
|
||||
snippet notice "Notice Function" b
|
||||
notice("${1:message}")${0}
|
||||
endsnippet
|
||||
|
||||
snippet realize "Realize Function" !b
|
||||
snippet realize "Realize Function" b
|
||||
realize(${1:Resource}["${2:name}"])${0}
|
||||
endsnippet
|
||||
|
||||
snippet regsubst "Regsubst Function" !b
|
||||
snippet regsubst "Regsubst Function" b
|
||||
regsubst($${1:Target}, '${2:regexp}', '${3:replacement}')${0}
|
||||
endsnippet
|
||||
|
||||
snippet split "Split Function" !b
|
||||
snippet split "Split Function" b
|
||||
$${1:Variable} = split($${1:Target}, '${2:regexp}')${0}
|
||||
endsnippet
|
||||
|
||||
snippet versioncmp "Version Compare Function" !b
|
||||
snippet versioncmp "Version Compare Function" b
|
||||
$${1:Variable} = versioncmp('${1:version}', '${2:version}')${0}
|
||||
endsnippet
|
||||
|
||||
snippet warning "Warning Function" !b
|
||||
snippet warning "Warning Function" b
|
||||
warning("${1:message}")${0}
|
||||
endsnippet
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
priority -50
|
||||
|
||||
###########################################################################
|
||||
# TEXTMATE SNIPPETS #
|
||||
###########################################################################
|
||||
|
@ -1,6 +1,4 @@
|
||||
###########################################################################
|
||||
# GENERATED FROM get_tm_snippets.py #
|
||||
###########################################################################
|
||||
priority -50
|
||||
|
||||
snippet anaf "accepts_nested_attributes_for"
|
||||
accepts_nested_attributes_for :${1:association_name}${2:${3:, :allow_destroy => true}${4:, :reject_if => proc \{ |obj| ${5:obj.blank?} \}}}
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
priority -50
|
||||
|
||||
###########################################################################
|
||||
# General Stuff #
|
||||
|
@ -1,3 +1,5 @@
|
||||
priority -50
|
||||
|
||||
snippet "^#!" "#!/usr/bin/env ruby" r
|
||||
#!/usr/bin/env ruby
|
||||
$0
|
||||
|
@ -1,3 +1,5 @@
|
||||
priority -50
|
||||
|
||||
snippet /@?imp/ "@import '...';" br
|
||||
@import '${1:file}';
|
||||
endsnippet
|
||||
|
@ -1,3 +1,5 @@
|
||||
priority -50
|
||||
|
||||
global !p
|
||||
import vim
|
||||
|
||||
|
@ -1,16 +1,14 @@
|
||||
#########################
|
||||
# SNIPPETS for SNIPPETS #
|
||||
#########################
|
||||
priority -50
|
||||
|
||||
# We use a little hack so that the snippet is expanded
|
||||
# and parsed correctly
|
||||
snippet snip "Snippet definition" !
|
||||
`!p snip.rv = "snippet"` ${1:Tab_trigger} "${2:Description}" ${3:!b}
|
||||
snippet snip "Snippet definition" b
|
||||
`!p snip.rv = "snippet"` ${1:Tab_trigger} "${2:Description}" ${3:b}
|
||||
$0
|
||||
`!p snip.rv = "endsnippet"`
|
||||
endsnippet
|
||||
|
||||
snippet global "Global snippet" !
|
||||
snippet global "Global snippet" b
|
||||
`!p snip.rv = "global"` !p
|
||||
$0
|
||||
`!p snip.rv = "endglobal"`
|
||||
|
@ -1,3 +1,5 @@
|
||||
priority -50
|
||||
|
||||
###########################################################################
|
||||
# TEXTMATE SNIPPETS #
|
||||
###########################################################################
|
||||
|
@ -1,3 +1,5 @@
|
||||
priority -50
|
||||
|
||||
extends texmath
|
||||
|
||||
snippet "b(egin)?" "begin{} / end{}" br
|
||||
|
@ -1,3 +1,5 @@
|
||||
priority -50
|
||||
|
||||
##############
|
||||
# MATH STUFF #
|
||||
##############
|
||||
|
@ -1,3 +1,5 @@
|
||||
priority -50
|
||||
|
||||
###########################################################################
|
||||
# SnipMate Snippets #
|
||||
###########################################################################
|
||||
|
@ -1 +1,3 @@
|
||||
priority -50
|
||||
|
||||
extends html
|
||||
|
@ -1,3 +1,5 @@
|
||||
priority -50
|
||||
|
||||
snippet xml "XML declaration" b
|
||||
<?xml version="1.0"?>
|
||||
|
||||
|
@ -1,11 +1,15 @@
|
||||
priority -50
|
||||
|
||||
extends sh
|
||||
|
||||
snippet #! "shebang" !
|
||||
priority -49
|
||||
|
||||
snippet #! "shebang" b
|
||||
#!/bin/zsh
|
||||
|
||||
endsnippet
|
||||
|
||||
snippet !env "#!/usr/bin/env (!env)" !
|
||||
snippet !env "#!/usr/bin/env (!env)" b
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
endsnippet
|
||||
|
@ -130,9 +130,10 @@ function! UltiSnips#FileTypeChanged()
|
||||
return ""
|
||||
endfunction
|
||||
|
||||
|
||||
function! UltiSnips#AddSnippet(trigger, value, description, options, ...)
|
||||
" Takes the same arguments as SnippetManager.add_snippet:
|
||||
" (trigger, value, description, options, ft = "all", globals = None)
|
||||
" Takes the same arguments as SnippetManager.add_snippet.
|
||||
echoerr "Deprecated UltiSnips#AddSnippet called. Please use UltiSnips#AddSnippetWithPriority." | sleep 1
|
||||
exec g:_uspy "args = vim.eval(\"a:000\")"
|
||||
exec g:_uspy "trigger = vim.eval(\"a:trigger\")"
|
||||
exec g:_uspy "value = vim.eval(\"a:value\")"
|
||||
@ -142,9 +143,20 @@ function! UltiSnips#AddSnippet(trigger, value, description, options, ...)
|
||||
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="", globals = None)
|
||||
" (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)"
|
||||
|
@ -16,7 +16,7 @@ UltiSnips *snippet* *snippets* *UltiSnips*
|
||||
3.3 Snippet Search Path |UltiSnips-snippet-search-path|
|
||||
3.4 Warning About Select Mode Mappings |UltiSnips-warning-smappings|
|
||||
3.5 Functions |UltiSnips-functions|
|
||||
3.5.1 UltiSnips#AddSnippet |UltiSnips#AddSnippet|
|
||||
3.5.1 UltiSnips#AddSnippetWithPriority |UltiSnips#AddSnippetWithPriority|
|
||||
3.5.2 UltiSnips#Anon |UltiSnips#Anon|
|
||||
3.5.3 UltiSnips#SnippetsInCurrentScope |UltiSnips#SnippetsInCurrentScope|
|
||||
3.6 Missing python support |UltiSnips-python-warning|
|
||||
@ -373,13 +373,14 @@ complete definition as listed by the |:smap| command. >
|
||||
UltiSnips provides some functions for extending core functionality.
|
||||
|
||||
|
||||
3.5.1 UltiSnips#AddSnippet *UltiSnips#AddSnippet*
|
||||
3.5.1 UltiSnips#AddSnippetWithPriority *UltiSnips#AddSnippetWithPriority*
|
||||
|
||||
The first function is UltiSnips#AddSnippet(trigger, value, description,
|
||||
options, filetyp="all"). It adds a new snippet with the provided trigger, value,
|
||||
The first function is UltiSnips#AddSnippetWithPriority(trigger, value, description,
|
||||
options, filetyp, priority). It adds a new snippet with the provided trigger, value,
|
||||
description, and options to the current list of snippets. See
|
||||
|UltiSnips-syntax| for details on the meaning of the function arguments. All
|
||||
arguments are strings.
|
||||
|UltiSnips-syntax| for details on the meaning of the function arguments. The
|
||||
Priority is a number that defines which snippet should be preferred over
|
||||
others. See the priority keyword in|UltiSnips-add-snippets|.
|
||||
|
||||
|
||||
3.5.2 UltiSnips#Anon *UltiSnips#Anon*
|
||||
@ -390,9 +391,9 @@ discarded again. Anonymous snippets are not added to the global list of
|
||||
snippets, so they cannot be expanded a second time unless the function is
|
||||
called again. The function takes three optional arguments, in order: trigger,
|
||||
description, options. Arguments coincide with the arguments of the
|
||||
|UltiSnips#AddSnippet| function of the same name. The trigger and options
|
||||
arguments can change the way the snippet expands. The description is unused at
|
||||
this point.
|
||||
|UltiSnips#AddSnippetWithPriority| function of the same name. The trigger and
|
||||
options arguments can change the way the snippet expands. The description is
|
||||
unused at this point.
|
||||
|
||||
An example use case might be this line from a reStructuredText plugin file:
|
||||
|
||||
@ -504,14 +505,13 @@ a dotted filetype for the CUDA C++ framework, e.g. ":set ft=cuda.cpp", then
|
||||
UltiSnips will search for and activate snippets for both the cuda and cpp
|
||||
filetypes.
|
||||
|
||||
UltiSnips doesn't understand multiple filetypes in snippet filenames, so a
|
||||
snippet file named "cuda.cpp.snippets" won't match the "cuda" or "cpp"
|
||||
filetypes, which means it won't be activated for files with the dotted
|
||||
filetype "cuda.cpp" either.
|
||||
The snippets file syntax is simple. All lines starting with a # character are
|
||||
considered comments. Comments are ignored by UltiSnips. Use them to document
|
||||
snippets.
|
||||
|
||||
The extends directive provides an alternative way of combining snippet files.
|
||||
When the extends directive is included in a snippet file, it instructs
|
||||
UltiSnips to include all snippets from the indicated filetypes.
|
||||
A line beginning with the keyword 'extends' provides a way of combining
|
||||
snippet files. When the 'extends' directive is included in a snippet file, it
|
||||
instructs UltiSnips to include all snippets from the indicated filetypes.
|
||||
|
||||
The syntax looks like this: >
|
||||
extends ft1, ft2, ft3
|
||||
@ -520,12 +520,17 @@ For example, the first line in cpp.snippets looks like this: >
|
||||
extends c
|
||||
When UltiSnips activates snippets for a cpp file, it first looks for all c
|
||||
snippets and activates them as well. This is a convenient way to create
|
||||
specialized snippet files from more general ones. Multiple "extends" lines are
|
||||
specialized snippet files from more general ones. Multiple 'extends' lines are
|
||||
permitted in a snippet file, and they can be included anywhere in the file.
|
||||
|
||||
The snippets file syntax is simple. All lines starting with a # character are
|
||||
considered comments. Comments are ignored by UltiSnips. Use them to document
|
||||
snippets.
|
||||
|
||||
A line beginning with the keyword 'priority' sets the priority for all
|
||||
snippets defined in the current file after this line. The default priority for
|
||||
a file is always 0. When a snippet should be expanded, UltiSnips will collect
|
||||
all snippet definitons from all sources that match the trigger and keep only
|
||||
the ones with the highest priority. For example, all shipped snippets have a
|
||||
priority < 0, so that user defined snippets always overwrite shipped snippets.
|
||||
|
||||
|
||||
A line beginning with the keyword 'snippet' marks the beginning of snippet
|
||||
definition and a line starting with the keyword 'endsnippet' marks the end.
|
||||
@ -575,15 +580,6 @@ single characters. The 'options' characters for a snippet are combined into
|
||||
a word without spaces.
|
||||
|
||||
The options currently supported are: >
|
||||
! Overwrite - A snippet with this option will overwrite all previously
|
||||
defined snippets with an identical tab trigger. What previously means
|
||||
in this context depends on the order UltiSnips traverses the
|
||||
'runtimepath'. (Compare g:UltiSnipsDontReverseSearchPath). This might
|
||||
depend on your installation type (Pathogen, Bzr, Vundle). The default
|
||||
behavior is to display list of snippets matching the tab trigger and
|
||||
let the user pick the one they want. Use this option to overwrite
|
||||
bundled snippets with user defined ones.
|
||||
|
||||
b Beginning of line - A snippet with this option is expanded only if the
|
||||
tab trigger is the first word on the line. In other words, if only
|
||||
whitespace precedes the tab trigger, expand. The default is to expand
|
||||
|
@ -43,7 +43,7 @@ function! UltiSnips_JumpForwards()
|
||||
endfunction
|
||||
|
||||
function! UltiSnips_AddSnippet(...)
|
||||
echoerr "Deprecated UltiSnips_AddSnippet called. Please use UltiSnips#AddSnippet." | sleep 1
|
||||
echoerr "Deprecated UltiSnips_AddSnippet called. Please use UltiSnips#AddSnippetWithPriority." | sleep 1
|
||||
return call(function('UltiSnips#AddSnippet'), a:000)
|
||||
endfunction
|
||||
|
||||
|
@ -20,23 +20,7 @@ class SnippetProvider(object):
|
||||
found_snippets = []
|
||||
for ft in filetypes:
|
||||
found_snippets += self._find_snippets(ft, before, possible)
|
||||
|
||||
# Search if any of the snippets overwrites the previous
|
||||
# Dictionary allows O(1) access for easy overwrites
|
||||
snippets = {}
|
||||
for snip in found_snippets:
|
||||
if (snip.trigger not in snippets) or snip.overwrites_previous:
|
||||
snippets[snip.trigger] = []
|
||||
snippets[snip.trigger].append(snip)
|
||||
|
||||
# Transform dictionary into flat list of snippets
|
||||
selected_snippets = set(
|
||||
[item for sublist in snippets.values() for item in sublist])
|
||||
# Return snippets to their original order
|
||||
snippets = [snip for snip in found_snippets if
|
||||
snip in selected_snippets]
|
||||
|
||||
return snippets
|
||||
return found_snippets
|
||||
|
||||
def _find_snippets(self, ft, trigger, potentially=False, seen=None):
|
||||
"""Find snippets matching 'trigger' for 'ft'. If 'potentially' is True,
|
||||
|
@ -1,8 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
"""Handles manually added snippets through UltiSnips#AddSnippet or
|
||||
UltiSnips_Manager.add_snippet()."""
|
||||
"""Handles manually added snippets UltiSnips_Manager.add_snippet()."""
|
||||
|
||||
from UltiSnips.providers._base import SnippetProvider
|
||||
|
||||
|
@ -148,6 +148,7 @@ class UltiSnipsFileProvider(SnippetProvider):
|
||||
def _parse_snippets(self, ft, filename):
|
||||
"""Parse the file 'filename' for the given 'ft' and watch it for
|
||||
changes in the future. 'file_data' can be injected in tests."""
|
||||
current_snippet_priority = 0
|
||||
self._snippets[ft].addfile(filename)
|
||||
file_data = open(filename, "r").read()
|
||||
for event, data in parse_snippets_file(file_data):
|
||||
@ -167,11 +168,14 @@ class UltiSnipsFileProvider(SnippetProvider):
|
||||
filetypes, = data
|
||||
self._add_extending_info(ft, filetypes)
|
||||
elif event == "snippet":
|
||||
trigger, value, description, options, globals = data
|
||||
trigger, value, description, options, global_pythons = data
|
||||
self._snippets[ft].add_snippet(
|
||||
SnippetDefinition(trigger, value, description, options,
|
||||
globals), filename
|
||||
SnippetDefinition(current_snippet_priority, trigger, value,
|
||||
description, options, global_pythons), filename
|
||||
)
|
||||
elif event == "priority":
|
||||
priority, = data
|
||||
current_snippet_priority = priority
|
||||
else:
|
||||
assert False, "Unhandled %s: %r" % (event, data)
|
||||
|
||||
|
@ -115,5 +115,11 @@ def parse_snippets_file(data):
|
||||
yield snippet
|
||||
elif head == "clearsnippets":
|
||||
yield "clearsnippets", (tail.split(),)
|
||||
elif head == "priority":
|
||||
try:
|
||||
priority = int(tail.split()[0])
|
||||
yield "priority", (priority,)
|
||||
except (ValueError, IndexError):
|
||||
yield "error", ("Invalid priority %r" % tail, lines.line_index)
|
||||
elif head and not head.startswith('#'):
|
||||
yield "error", ("Invalid line %r" % line.rstrip(), lines.line_index)
|
||||
|
@ -39,7 +39,8 @@ class SnippetDefinition(object):
|
||||
_INDENT = re.compile(r"^[ \t]*")
|
||||
_TABS = re.compile(r"^\t*")
|
||||
|
||||
def __init__(self, trigger, value, description, options, globals):
|
||||
def __init__(self, priority, trigger, value, description, options, globals):
|
||||
self._priority = priority
|
||||
self._trigger = as_unicode(trigger)
|
||||
self._value = as_unicode(value)
|
||||
self._description = as_unicode(description)
|
||||
@ -49,8 +50,8 @@ class SnippetDefinition(object):
|
||||
self._globals = globals
|
||||
|
||||
def __repr__(self):
|
||||
return "SnippetDefinition(%s,%s,%s)" % (
|
||||
self._trigger, self._description, self._opts)
|
||||
return "SnippetDefinition(%r,%s,%s,%s)" % (
|
||||
self._priority, self._trigger, self._description, self._opts)
|
||||
|
||||
def _re_match(self, trigger):
|
||||
""" Test if a the current regex trigger matches
|
||||
@ -160,16 +161,17 @@ class SnippetDefinition(object):
|
||||
|
||||
return match
|
||||
|
||||
@property
|
||||
def overwrites_previous(self):
|
||||
"""Does this snippet overwrite previous with the same trigger?"""
|
||||
return "!" in self._opts
|
||||
|
||||
@property
|
||||
def description(self):
|
||||
"""Descriptive text for this snippet."""
|
||||
return ("(%s) %s" % (self._trigger, self._description)).strip()
|
||||
|
||||
@property
|
||||
def priority(self):
|
||||
"""The snippets priority, which defines which snippet will be preferred
|
||||
over others with the same trigger."""
|
||||
return self._priority
|
||||
|
||||
@property
|
||||
def trigger(self):
|
||||
"""The trigger text for the snippet."""
|
||||
|
@ -169,21 +169,17 @@ class SnippetManager(object):
|
||||
|
||||
@err_to_scratch_buffer
|
||||
def add_snippet(self, trigger, value, description,
|
||||
options, ft="all", globals=None):
|
||||
options, ft="all", priority=0):
|
||||
"""Add a snippet to the list of known snippets of the given 'ft'."""
|
||||
self._added_snippets_provider.add_snippet(ft, SnippetDefinition(
|
||||
trigger, value, description, options, globals or {})
|
||||
priority, trigger, value, description, options, {})
|
||||
)
|
||||
|
||||
@err_to_scratch_buffer
|
||||
def expand_anon(self, value, trigger="", description="",
|
||||
options="", globals=None):
|
||||
def expand_anon(self, value, trigger="", description="", options=""):
|
||||
"""Expand an anonymous snippet right here."""
|
||||
if globals is None:
|
||||
globals = {}
|
||||
|
||||
before = _vim.buf.line_till_cursor
|
||||
snip = SnippetDefinition(trigger, value, description, options, globals)
|
||||
snip = SnippetDefinition(0, trigger, value, description, options, {})
|
||||
|
||||
if not trigger or snip.matches(before):
|
||||
self._do_snippet(snip, before)
|
||||
@ -403,7 +399,12 @@ class SnippetManager(object):
|
||||
snippets = []
|
||||
for provider in self._snippet_providers:
|
||||
snippets.extend(provider.get_snippets(filetypes, before, possible))
|
||||
return snippets
|
||||
if not snippets:
|
||||
return []
|
||||
|
||||
# Only keep the snippets with the highest priority.
|
||||
highest_priority = max(snip.priority for snip in snippets)
|
||||
return [s for s in snippets if s.priority == highest_priority]
|
||||
|
||||
def _do_snippet(self, snippet, before):
|
||||
"""Expands the given snippet, and handles everything
|
||||
|
@ -17,7 +17,7 @@ syn match snipString '"[^"]*"'
|
||||
syn match snipTabsOnly "^\t\+$"
|
||||
syn match snipLeadingSpaces "^\t* \+"
|
||||
|
||||
syn match snipKeyword "\(\<\(end\)\?\(snippet\|global\)\>\)\|extends\|clearsnippets" contained
|
||||
syn match snipKeyword "\(\<\(end\)\?\(snippet\|global\)\>\)\|extends\|clearsnippets\|priority" contained
|
||||
|
||||
" extends definitions
|
||||
syn match snipExtends "^extends.*" contains=snipKeyword
|
||||
@ -40,6 +40,7 @@ syn region snipGlobal fold keepend start="^global" end="^endglobal" contains=sni
|
||||
|
||||
" snippet clearing
|
||||
syn match snipClear "^clearsnippets"
|
||||
syn match snipPriority "^priority"
|
||||
|
||||
" highlighting rules
|
||||
|
||||
@ -66,5 +67,6 @@ hi link snipGlobalEnd Statement
|
||||
hi link snipGlobal Normal
|
||||
|
||||
hi link snipClear Statement
|
||||
hi link snipPriority Statement
|
||||
|
||||
let b:current_syntax = "snippet"
|
||||
|
110
test.py
110
test.py
@ -327,16 +327,19 @@ class _VimTest(unittest.TestCase):
|
||||
self.snippets = ( self.snippets, )
|
||||
|
||||
for s in self.snippets:
|
||||
sv,content = s[:2]
|
||||
sv, content = s[:2]
|
||||
description = ""
|
||||
options = ""
|
||||
priority = 0
|
||||
if len(s) > 2:
|
||||
description = s[2]
|
||||
if len(s) > 3:
|
||||
options = s[3]
|
||||
if len(s) > 4:
|
||||
priority = s[4]
|
||||
|
||||
self.send_py("UltiSnips_Manager.add_snippet(%r, %r, %r, %r)" %
|
||||
(sv, content, description, options))
|
||||
self.send_py("UltiSnips_Manager.add_snippet(%r, %r, %r, %r, priority=%i)" %
|
||||
(sv, content, description, options, priority))
|
||||
|
||||
ft, file_data = self.snippets_test_file
|
||||
self._temporary_directory = ""
|
||||
@ -403,6 +406,22 @@ class ParseSnippets_UnknownDirective(_VimTest):
|
||||
wanted = "testsnip" + EX
|
||||
expected_error = r"Invalid line 'unknown directive' in \S+:2"
|
||||
|
||||
class ParseSnippets_InvalidPriorityLine(_VimTest):
|
||||
snippets_test_file = ("all", r"""
|
||||
priority - 50
|
||||
""")
|
||||
keys = "testsnip" + EX
|
||||
wanted = "testsnip" + EX
|
||||
expected_error = r"Invalid priority '- 50' in \S+:2"
|
||||
|
||||
class ParseSnippets_InvalidPriorityLine1(_VimTest):
|
||||
snippets_test_file = ("all", r"""
|
||||
priority
|
||||
""")
|
||||
keys = "testsnip" + EX
|
||||
wanted = "testsnip" + EX
|
||||
expected_error = r"Invalid priority '' in \S+:2"
|
||||
|
||||
class ParseSnippets_ExtendsWithoutFiletype(_VimTest):
|
||||
snippets_test_file = ("all", r"""
|
||||
extends
|
||||
@ -2034,33 +2053,86 @@ class Multiple_ManySnippetsOneTrigger_ECR(_VimTest):
|
||||
keys = "test" + EX + " " + ESC + ESC + "ahi"
|
||||
wanted = "testhi"
|
||||
# End: Selecting Between Same Triggers #}}}
|
||||
# Snippet Options {{{#
|
||||
class SnippetOptions_OverwriteExisting_ECR(_VimTest):
|
||||
# Snippet Priority {{{#
|
||||
class SnippetPriorities_MultiWordTriggerOverwriteExisting(_VimTest):
|
||||
snippets = (
|
||||
("test me", "${1:Hallo}", "Types Hallo"),
|
||||
("test me", "${1:World}", "Types World"),
|
||||
("test me", "We overwrite", "Overwrite the two", "", 1),
|
||||
)
|
||||
keys = "test me" + EX
|
||||
wanted = "We overwrite"
|
||||
class SnippetPriorities_DoNotCareAboutNonMatchings(_VimTest):
|
||||
snippets = (
|
||||
("test1", "Hallo", "Types Hallo"),
|
||||
("test2", "We overwrite", "Overwrite the two", "", 1),
|
||||
)
|
||||
keys = "test1" + EX
|
||||
wanted = "Hallo"
|
||||
class SnippetPriorities_OverwriteExisting(_VimTest):
|
||||
snippets = (
|
||||
("test", "${1:Hallo}", "Types Hallo"),
|
||||
("test", "${1:World}", "Types World"),
|
||||
("test", "We overwrite", "Overwrite the two", "!"),
|
||||
("test", "We overwrite", "Overwrite the two", "", 1),
|
||||
)
|
||||
keys = "test" + EX
|
||||
wanted = "We overwrite"
|
||||
class SnippetOptions_OverwriteTwice_ECR(_VimTest):
|
||||
class SnippetPriorities_OverwriteTwice_ECR(_VimTest):
|
||||
snippets = (
|
||||
("test", "${1:Hallo}", "Types Hallo"),
|
||||
("test", "${1:World}", "Types World"),
|
||||
("test", "We overwrite", "Overwrite the two", "!"),
|
||||
("test", "again", "Overwrite again", "!"),
|
||||
("test", "We overwrite", "Overwrite the two", "", 1),
|
||||
("test", "again", "Overwrite again", "", 2),
|
||||
)
|
||||
keys = "test" + EX
|
||||
wanted = "again"
|
||||
class SnippetOptions_OverwriteThenChoose_ECR(_VimTest):
|
||||
class SnippetPriorities_OverwriteThenChoose_ECR(_VimTest):
|
||||
snippets = (
|
||||
("test", "${1:Hallo}", "Types Hallo"),
|
||||
("test", "${1:World}", "Types World"),
|
||||
("test", "We overwrite", "Overwrite the two", "!"),
|
||||
("test", "No overwrite", "Not overwritten", ""),
|
||||
("test", "We overwrite", "Overwrite the two", "", 1),
|
||||
("test", "No overwrite", "Not overwritten", "", 1),
|
||||
)
|
||||
keys = "test" + EX + "1\n\n" + "test" + EX + "2\n"
|
||||
wanted = "We overwrite\nNo overwrite"
|
||||
class SnippetPriorities_AddedHasHigherThanFile(_VimTest):
|
||||
snippets_test_file = ("all", r"""
|
||||
snippet test "Test Snippet" b
|
||||
This is a test snippet
|
||||
endsnippet
|
||||
""")
|
||||
snippets = (
|
||||
("test", "We overwrite", "Overwrite the two", "", 1),
|
||||
)
|
||||
keys = "test" + EX
|
||||
wanted = "We overwrite"
|
||||
class SnippetPriorities_FileHasHigherThanAdded(_VimTest):
|
||||
snippets_test_file = ("all", r"""
|
||||
snippet test "Test Snippet" b
|
||||
This is a test snippet
|
||||
endsnippet
|
||||
""")
|
||||
snippets = (
|
||||
("test", "We do not overwrite", "Overwrite the two", "", -1),
|
||||
)
|
||||
keys = "test" + EX
|
||||
wanted = "This is a test snippet"
|
||||
class SnippetPriorities_FileHasHigherThanAdded(_VimTest):
|
||||
snippets_test_file = ("all", r"""
|
||||
priority -3
|
||||
snippet test "Test Snippet" b
|
||||
This is a test snippet
|
||||
endsnippet
|
||||
""")
|
||||
snippets = (
|
||||
("test", "We overwrite", "Overwrite the two", "", -5),
|
||||
)
|
||||
keys = "test" + EX
|
||||
wanted = "This is a test snippet"
|
||||
# End: Snippet Priority #}}}
|
||||
|
||||
|
||||
# Snippet Options {{{#
|
||||
class SnippetOptions_OnlyExpandWhenWSInFront_Expand(_VimTest):
|
||||
snippets = ("test", "Expand me!", "", "b")
|
||||
keys = "test" + EX
|
||||
@ -2278,14 +2350,6 @@ class MultiWordSnippet_Simple(_VimTest):
|
||||
snippets = ("test me", "Expand me!")
|
||||
keys = "test me" + EX
|
||||
wanted = "Expand me!"
|
||||
class MultiWord_SnippetOptions_OverwriteExisting_ECR(_VimTest):
|
||||
snippets = (
|
||||
("test me", "${1:Hallo}", "Types Hallo"),
|
||||
("test me", "${1:World}", "Types World"),
|
||||
("test me", "We overwrite", "Overwrite the two", "!"),
|
||||
)
|
||||
keys = "test me" + EX
|
||||
wanted = "We overwrite"
|
||||
class MultiWord_SnippetOptions_OnlyExpandWhenWSInFront_Expand(_VimTest):
|
||||
snippets = ("test it", "Expand me!", "", "b")
|
||||
keys = "test it" + EX
|
||||
@ -2395,16 +2459,16 @@ class Anon_Trigger_Opts(_AnonBase):
|
||||
class _AddFuncBase(_VimTest):
|
||||
args = ""
|
||||
def _options_on(self):
|
||||
self.send(":call UltiSnips#AddSnippet("
|
||||
self.send(":call UltiSnips#AddSnippetWithPriority("
|
||||
+ self.args + ')\n')
|
||||
|
||||
class AddFunc_Simple(_AddFuncBase):
|
||||
args = '"test", "simple expand", "desc", ""'
|
||||
args = '"test", "simple expand", "desc", "", "all", 0'
|
||||
keys = "abc test" + EX
|
||||
wanted = "abc simple expand"
|
||||
|
||||
class AddFunc_Opt(_AddFuncBase):
|
||||
args = '".*test", "simple expand", "desc", "r"'
|
||||
args = '".*test", "simple expand", "desc", "r", "all", 0'
|
||||
keys = "abc test" + EX
|
||||
wanted = "simple expand"
|
||||
# End: AddSnippet Function #}}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user