1
0
mirror of https://github.com/gryf/snipmate.vim.git synced 2025-12-27 17:02:36 +01:00

significantly refactored code, and added support for file-based snippets and delimeters before snippet triggers.

This commit is contained in:
Michael Sanders
2009-02-25 15:02:34 -05:00
parent 465abbe37e
commit 48b5d02a89
31 changed files with 552 additions and 1920 deletions

View File

@@ -1,7 +1,7 @@
if !exists('g:loaded_snips') || exists('b:did_c_snips')
if !exists('loaded_snips') || exists('s:did_'.&ft.'_snips')
fini
en
let b:did_c_snips = 1
let s:did_{&ft}_snips = 1
" main()
exe "Snipp main int main (int argc, char const* argv[])\n{\n\t${1}\n\treturn 0;\n}"
@@ -39,7 +39,7 @@ exe 'Snipp td typedef ${1:int} ${2:MyCustomType};'
" Struct
exe "Snipp st struct ${1:`Filename('$1_t', 'name')`} {\n\t${2:/* data */}\n}${3: /* optional variable list */};${4}"
" Typedef struct
exe "Snipp tds typedef struct {\n\t${2:/* data */}\n} ${1:`Filename('$1_t', 'name')`};"
exe "Snipp tds typedef struct ${2:$1 }{\n\t${3:/* data */}\n} ${1:`Filename('$1_t', 'name')`};"
" Class
exe "Snipp cl class ${1:`Filename('$1_t', 'name')`} {\npublic:\n\t$1 (${2:arguments});\n\tvirtual ~$1 ();\n\nprivate:\n\t${3:/* data */}\n};"
" Namespace

View File

@@ -1,7 +1,7 @@
if !exists('g:loaded_snips') || exists('b:did_html_snips')
if !exists('g:loaded_snips') || exists('s:did_'.&ft.'_snips')
fini
en
let b:did_html_snips = 1
let s:did_{&ft}_snips = 1
" automatically add a closing '/' to the end of xhtml tags
let c = &ft == 'xhtml' ? ' /' : ''
@@ -42,6 +42,7 @@ exe 'Snipp escape ⎋'
" Generic Doctype
exe "Snipp! doctype \"HTML 4.01 Strict\" <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\"\n\"http://www.w3.org/TR/html4/strict.dtd\">"
exe "Snipp! doctype \"HTML 4.01 Transitional\" <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\"\n\"http://www.w3.org/TR/html4/loose.dtd\">"
exe "Snipp! doctype \"HTML 5\" <!DOCTYPE HTML>"
exe "Snipp! doctype \"XHTML 1.0 Frameset\" <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
exe "Snipp! doctype \"XHTML 1.0 Strict\" <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
exe "Snipp! doctype \"XHTML 1.0 Transitional\" <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
@@ -50,6 +51,8 @@ exe "Snipp! doctype \"XHTML 1.1\" <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1/
exe "Snipp docts <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\"\n\"http://www.w3.org/TR/html4/strict.dtd\">"
" HTML Doctype 4.01 Transitional
exe "Snipp doct <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\"\n\"http://www.w3.org/TR/html4/loose.dtd\">"
" HTML Doctype 5
exe 'Snipp doct5 <!DOCTYPE HTML>'
" XHTML Doctype 1.0 Frameset
exe "Snipp docxf <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">"
" XHTML Doctype 1.0 Strict
@@ -58,6 +61,7 @@ exe "Snipp docxs <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n\"h
exe "Snipp docxt <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
" XHTML Doctype 1.1
exe "Snipp docx <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\n\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">"
exe "Snipp html <html>\n${1}\n</html>"
exe "Snipp xhtml <html xmlns=\"http://www.w3.org/1999/xhtml\">\n${1}\n</html>"
exe "Snipp body <body>\n\t${1}\n</body>"
exe "Snipp head <head>\n\t<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"".c.">\n\t"

View File

@@ -1,7 +1,7 @@
if !exists('loaded_snips') || exists('b:did_java_snips')
if !exists('loaded_snips') || exists('s:did_java_snips')
fini
en
let b:did_java_snips = 1
let s:did_java_snips = 1
exe "Snipp main public static void main (String [] args)\n{\n\t${1:/* code */}\n}"
exe 'Snipp pu public'

View File

@@ -1,7 +1,7 @@
if !exists('loaded_snips') || exists('b:did_js_snips')
if !exists('loaded_snips') || exists('s:did_js_snips')
fini
en
let b:did_js_snips = 1
let s:did_js_snips = 1
" Prototype
exe "Snipp proto ${1:class_name}.prototype.${2:method_name} =\nfunction(${3:first_argument}) {\n\t${4:// body...}\n};"

View File

@@ -1,7 +1,7 @@
if !exists('loaded_snips') || exists('b:did_js_snips')
if !exists('loaded_snips') || exists('s:did_objc_snips')
fini
en
let b:did_js_snips = 1
let s:did_objc_snips = 1
" #import <...>
exe 'Snipp imp #import <${1:Cocoa/Cocoa.h}>${2}'
@@ -15,26 +15,40 @@ exe 'Snipp log NSLog(@"${1}"${2});${3}'
exe "Snipp objc @interface ${1:`Filename('', 'object')`} : ${2:NSObject}\n{\n}\n@end\n\n@implementation $1\n- (id) init\n{\n\tif (self = [super init])"
\."\n\t{${3}\n\t}\n\treturn self\n}\n@end"
" Class Interface
exe "Snipp cli @interface ${1:ClassName} : ${2:NSObject}\n{${3}\n}\n${4}\n@end"
exe "Snipp clh @interface ${1:ClassName} : ${2:NSObject}\n{${3}\n}\n${4}\n@end"
exe 'Snipp ibo IBOutlet ${1:NSSomeClass} *${2:$1};'
" Category
exe "Snipp cat @interface ${1:NSObject} (${2:Category})\n@end\n\n@implementation $1 ($2)\n${3}\n@end"
" Category Interface
exe "Snipp cati @interface ${1:NSObject} (${2:Category})\n${3}\n@end"
exe "Snipp cath @interface ${1:NSObject} (${2:Category})\n${3}\n@end"
" NSArray
exe 'Snipp array NSMutableArray *${1:array} = [NSMutable array];${2}'
" NSDictionary
exe 'Snipp dict NSMutableDictionary *${1:dict} = [NSMutableDictionary dictionary];${2}'
" NSBezierPath
exe 'Snipp bez NSBezierPath *${1:path} = [NSBezierPath bezierPath];${2}'
" Method
exe "Snipp m - (${1:id})${2:method}\n{\n\t${3:return self;}\n}"
" Method declaration
exe "Snipp md - (${1:id})${2:method};${3}"
" Class Method
exe "Snipp M + (${1:id}) ${2:method}\n{${3}\n\treturn nil;\n}"
exe "Snipp M + (${1:id})${2:method}\n{${3}\n\treturn nil;\n}"
" Sub-method (Call super)
exe "Snipp sm - (${1:id}) ${2:method}:(${3:id})${4:anArgument}\n{\n\t$1 res = [super $2:$4];${5}\n\treturn res;\n}"
exe "Snipp sm - (${1:id})${2:method}\n{\n\t[super $2];${3}\n\treturn self;\n}"
" Method: Initialize
exe "Snipp I + (void) initialize\n{\n\t[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWIthObjectsAndKeys:\n\t\t${1}@\"value\", @\"key\",\n\t\tnil]];\n}"
" Accessor Methods For:
" Object
exe "Snipp objacc - (${1:id})${2:thing}\n{\n\treturn $2;\n}\n\n- (void) set$2:($1)\n{\n\t$1 old$2 = $2;\n\t$2 = [aValue retain];\n\t[old$2 release];\n}"
exe "Snipp forarray unsigned int\t${1:object}Count = [${2:array} count];\n\nfor (unsigned int index = 0; index < $1Count; index++)\n{\n\t${3:id}\t$1 = [$2 $1AtIndex:index];\n\t${4}\n}"
" IBOutlet
" @property (Objective-C 2.0)
exe "Snipp prop @property (${1:retain}) ${2:NSSomeClass} *${3:$2};${4}"
" @synthesize (Objective-C 2.0)
exe "Snipp syn @synthesize ${1:NSSomeClass};${2}"
" [[ alloc] init]
exe 'Snipp alloc [[${1:foo} alloc] init]${2};${3}'
" retain
exe 'Snipp ret [${1:foo} retain];${2}'
" release
exe 'Snipp rel [${1:foo} release];${2}'

View File

@@ -1,7 +1,7 @@
if !exists('loaded_snips') || exists('b:did_perl_snips')
if !exists('loaded_snips') || exists('s:did_perl_snips')
fini
en
let b:did_perl_snips = 1
let s:did_perl_snips = 1
" Hash Pointer
exe 'Snipp . =>'

View File

@@ -1,7 +1,7 @@
if !exists('loaded_snips') || exists('b:did_php_snips')
if !exists('loaded_snips') || exists('s:did_php_snips')
fini
en
let b:did_php_snips = 1
let s:did_php_snips = 1
exe "Snipp php <?php\n${1}\n?>"
exe 'Snipp ec echo "${1:string}"${2};'

View File

@@ -1,7 +1,7 @@
if !exists('loaded_snips') || exists('b:did_python_snips')
if !exists('loaded_snips') || exists('s:did_python_snips')
fini
en
let b:did_python_snips = 1
let s:did_python_snips = 1
" New Class
exe "Snipp cl class ${1:ClassName}(${2:object}):\n\t\"\"\"${3:docstring for $1}\"\"\"\n\tdef __init__(self, ${4:arg}):\n\t\t${5:super($1, self).__init__()}\n\t\tself.$4 = $4\n\t\t${6}"
@@ -10,7 +10,7 @@ exe "Snipp def def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):\n\t\"\"\"${3:do
" New Method
exe "Snipp defs def ${1:mname}(self, ${2:arg})):\n\t${3:pass}"
" New Property
exe "Snipp property def def ${1:foo}():\n\tdoc = \"${2:The $1 property.}\"\n\tdef fget(self):\n\t\t\t${3:return self._$1}\n\tdef fset(self, value):\n\t\t"
exe "Snipp property def ${1:foo}():\n\tdoc = \"${2:The $1 property.}\"\n\tdef fget(self):\n\t\t\t${3:return self._$1}\n\tdef fset(self, value):\n\t\t"
\."${4:self._$1 = value}\n\tdef fdel(self):\n\t\t\t${5:del self._$1}\n\treturn locals()\n$1 = property(**$1())${6}"
" Self
exe 'Snipp . self.'
@@ -19,9 +19,9 @@ exe "Snipp try try:\n\t${1:pass}\nexcept ${2:Exception}, ${3:e}:\n\t${4:raise $3
" Try/Except/Else
exe "Snipp trye try:\n\t${1:pass}\nexcept ${2:Exception}, ${3:e}:\n\t${4:raise $3}\nelse:\n\t${5:pass}"
" Try/Except/Finally
exe "Snipp tryf try:\n\t${1:pass}\nexcept ${2:Exception}, ${3:e}:\n\t${4:raise $3}\nfinally:\n${5:pass}"
exe "Snipp tryf try:\n\t${1:pass}\nexcept ${2:Exception}, ${3:e}:\n\t${4:raise $3}\nfinally:\n\t${5:pass}"
" Try/Except/Else/Finally
exe "Snipp tryef try:\n\t${1:pass}\nexcept ${2:Exception}, ${3:e}:\n\t${4:raise $3}\nelse:\n\t${5:pass}\nfinally:\n${6:pass}"
exe "Snipp tryef try:\n\t${1:pass}\nexcept ${2:Exception}, ${3:e}:\n\t${4:raise $3}\nelse:\n\t${5:pass}\nfinally:\n\t${6:pass}"
" if __name__ == '__main__':
exe "Snipp ifmain if __name__ == '__main__':\n\t${1:main()}"
" __magic__

View File

@@ -1,7 +1,7 @@
if !exists('loaded_snips') || exists('b:did_ruby_snips')
if !exists('loaded_snips') || exists('s:did_ruby_snips')
fini
en
let b:did_ruby_snips = 1
let s:did_ruby_snips = 1
" New Block
exe "Snipp =b =begin rdoc\n\t${1}\n=end"

View File

@@ -1,7 +1,7 @@
if !exists('loaded_snips') || exists('b:did_sh_snips')
if !exists('loaded_snips') || exists('s:did_sh_snips')
fini
en
let b:did_sh_snips = 1
let s:did_sh_snips = 1
exe "Snipp if if [[ ${1:condition} ]]; then\n\t${2:#statements}\nfi"
exe "Snipp elif elif [[ ${1:condition} ]]; then\n\t${2:#statements}"

View File

@@ -1,7 +1,7 @@
if !exists('loaded_snips') || exists('b:did_tex_snips')
if !exists('loaded_snips') || exists('s:did_tex_snips')
fini
en
let b:did_tex_snips = 1
let s:did_tex_snips = 1
" \begin{}...\end{}
exe "Snipp begin \\begin{${1:env}}\n\t${2}\n\\end{$1}"
@@ -41,9 +41,9 @@ exe "Snipp subs \\subsubsection{${1:subsubsection name}} % (fold)\n\\label{ssub:
exe "Snipp par \\paragraph{${1:paragraph name}} % (fold)\n\\label{par:${2:$1}}\n${3}\n% paragraph $2 (end)"
" Sub Paragraph
exe "Snipp subp \\subparagraph{${1:subparagraph name}} % (fold)\n\\label{subp:${2:$1}}\n${3}\n% subparagraph $2 (end)"
exe 'Snipp itd \\item[${1:description}] ${2:item}'
exe 'Snipp figure ${1:Figure}~\\ref{${2:fig:}}${3}'
exe 'Snipp table ${1:Table}~\\ref{${2:tab:}}${3}'
exe 'Snipp listing ${1:Listing}~\\ref{${2:list}}${3}'
exe 'Snipp section ${1:Section}~\\ref{${2:sec:}}${3}'
exe 'Snipp page ${1:page}~\\pageref{${2}}${3}'
exe 'Snipp itd \item[${1:description}] ${2:item}'
exe 'Snipp figure ${1:Figure}~\ref{${2:fig:}}${3}'
exe 'Snipp table ${1:Table}~\ref{${2:tab:}}${3}'
exe 'Snipp listing ${1:Listing}~\ref{${2:list}}${3}'
exe 'Snipp section ${1:Section}~\ref{${2:sec:}}${3}'
exe 'Snipp page ${1:page}~\pageref{${2}}${3}'