mirror of
https://github.com/gryf/snipmate.vim.git
synced 2025-12-20 21:08:01 +01:00
fixed objc/cpp command-based snippets
This commit is contained in:
@@ -2,8 +2,7 @@ if !exists('loaded_snips') || exists('s:did_c_snips')
|
||||
fini
|
||||
en
|
||||
let s:did_c_snips = 1
|
||||
let ft = &ft
|
||||
let &ft ='c'
|
||||
let snippet_filetype = 'c'
|
||||
|
||||
" main()
|
||||
exe "Snipp main int main (int argc, char const* argv[])\n{\n\t${1}\n\treturn 0;\n}"
|
||||
@@ -56,4 +55,3 @@ exe "Snipp vector std::vector<${1:char}> v${2};"
|
||||
exe 'Snipp pr printf("${1:%s}\n"${2});${3}'
|
||||
" fprintf (again, this isn't as nice as TextMate's version, but it works)
|
||||
exe 'Snipp fpr fprintf(${1:stderr}, "${2:%s}\n"${3});${4}'
|
||||
let &ft = ft
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
let filetype = stridx(&ft, 'xhtml') > -1 ? 'xhtml' : 'html'
|
||||
if !exists('g:loaded_snips') || exists('s:did_'.filetype.'_snips')
|
||||
let snippet_filetype = stridx(&ft, 'xhtml') > -1 ? 'xhtml' : 'html'
|
||||
if !exists('g:loaded_snips') || exists('s:did_'.snippet_filetype.'_snips')
|
||||
fini
|
||||
en
|
||||
let s:did_{filetype}_snips = 1
|
||||
let ft = &ft
|
||||
let &ft = filetype
|
||||
let s:did_{snippet_filetype}_snips = 1
|
||||
|
||||
" automatically add a closing '/' to the end of xhtml tags
|
||||
let c = filetype == 'xhtml' ? ' /' : ''
|
||||
let c = snippet_filetype == 'xhtml' ? ' /' : ''
|
||||
|
||||
" Some useful Unicode entities
|
||||
" Non-Breaking Space
|
||||
@@ -95,4 +93,3 @@ exe 'Snipp optt <option>${1:option}</option>${2}'
|
||||
exe "Snipp select <select name=\"${1:some_name}\" id=\"${2:$1}\">\n\t<option value=\"${3:option}\">${4:$3}</option>\n</select>${5}"
|
||||
exe "Snipp table <table border=\"${1:0}\">\n\t<tr><th>${2:Header}</th></tr>\n\t<tr><th>${3:Data}</th></tr>\n</table>${4}"
|
||||
exe 'Snipp textarea <textarea name="${1:Name}" rows="${2:8}" cols="${3:40}">${4}</textarea>${5}'
|
||||
let &ft = ft
|
||||
|
||||
@@ -2,8 +2,7 @@ if !exists('loaded_snips') || exists('s:did_java_snips')
|
||||
fini
|
||||
en
|
||||
let s:did_java_snips = 1
|
||||
let ft = &ft
|
||||
let &ft ='java'
|
||||
let snippet_filetype = 'java'
|
||||
|
||||
exe "Snipp main public static void main (String [] args)\n{\n\t${1:/* code */}\n}"
|
||||
exe 'Snipp pu public'
|
||||
@@ -41,5 +40,3 @@ exe 'Snipp v ${1:String} ${2:var}${3: = null}${4};${5}'
|
||||
exe 'Snipp co static public final ${1:String} ${2:var} = ${3};${4}'
|
||||
exe 'Snipp cos static public final String ${1:var} = "${2}";${3}'
|
||||
exe 'Snipp as assert ${1:test} : "${2:Failure message}";${3}'
|
||||
|
||||
let &ft = ft
|
||||
|
||||
@@ -2,8 +2,7 @@ if !exists('loaded_snips') || exists('s:did_js_snips')
|
||||
fini
|
||||
en
|
||||
let s:did_js_snips = 1
|
||||
let ft = &ft
|
||||
let &ft ='javascript'
|
||||
let snippet_filetype = 'javascript'
|
||||
|
||||
" Prototype
|
||||
exe "Snipp proto ${1:class_name}.prototype.${2:method_name} =\nfunction(${3:first_argument}) {\n\t${4:// body...}\n};"
|
||||
@@ -37,5 +36,3 @@ exe 'Snipp timeout setTimeout(function() {${3}}${2}, ${1:10};'
|
||||
exe "Snipp get getElementsBy${1:TagName}('${2}')${3}"
|
||||
" Get Element
|
||||
exe "Snipp gett getElementBy${1:Id}('${2}')${3}"
|
||||
|
||||
let &ft = ft
|
||||
|
||||
@@ -2,8 +2,7 @@ if !exists('loaded_snips') || exists('s:did_objc_snips')
|
||||
fini
|
||||
en
|
||||
let s:did_objc_snips = 1
|
||||
let ft = &ft
|
||||
let &ft ='objc'
|
||||
let snippet_filetype = 'objc'
|
||||
|
||||
" #import <...>
|
||||
exe 'Snipp imp #import <${1:Cocoa/Cocoa.h}>${2}'
|
||||
@@ -54,5 +53,3 @@ exe 'Snipp alloc [[${1:foo} alloc] init]${2};${3}'
|
||||
exe 'Snipp ret [${1:foo} retain];${2}'
|
||||
" release
|
||||
exe 'Snipp rel [${1:foo} release];${2}'
|
||||
|
||||
let &ft = ft
|
||||
|
||||
@@ -2,8 +2,7 @@ if !exists('loaded_snips') || exists('s:did_perl_snips')
|
||||
fini
|
||||
en
|
||||
let s:did_perl_snips = 1
|
||||
let ft = &ft
|
||||
let &ft ='perl'
|
||||
let snippet_filetype = 'perl'
|
||||
|
||||
" Hash Pointer
|
||||
exe 'Snipp . =>'
|
||||
@@ -37,5 +36,3 @@ exe 'Snipp xfore ${1:expression} foreach @${2:array};${3}'
|
||||
exe "Snipp cl package ${1:ClassName};\n\nuse base qw(${2:ParentClass});\n\nsub new {\n\tmy $class = shift;\n\t$class = ref $class if ref $class;\n\tmy $self = bless {}, $class;\n\t$self;\n}\n\n1;${3}"
|
||||
" Read File
|
||||
exe "Snipp slurp my $${1:var};\n{ local $/ = undef; local *FILE; open FILE, \"<${2:file}\"; $$1 = <FILE>; close FILE }${2}"
|
||||
|
||||
let &ft = ft
|
||||
|
||||
@@ -2,8 +2,7 @@ if !exists('loaded_snips') || exists('s:did_php_snips')
|
||||
fini
|
||||
en
|
||||
let s:did_php_snips = 1
|
||||
let ft = &ft
|
||||
let &ft ='php'
|
||||
let snippet_filetype = 'php'
|
||||
|
||||
exe "Snipp php <?php\n${1}\n?>"
|
||||
exe 'Snipp ec echo "${1:string}"${2};'
|
||||
@@ -67,4 +66,3 @@ exe "Snipp foreach foreach ($${1:variable} as $${2:key}) {\n\t${3:// code...}\n}
|
||||
exe "Snipp fun ${1:public }function ${2:FunctionName}(${3})\n{\n\t${4:// code...}\n}"
|
||||
" $... = array (...)
|
||||
exe "Snipp array $${1:arrayName} = array('${2}' => ${3});${4}"
|
||||
let &ft = ft
|
||||
|
||||
@@ -2,8 +2,7 @@ if !exists('loaded_snips') || exists('s:did_python_snips')
|
||||
fini
|
||||
en
|
||||
let s:did_python_snips = 1
|
||||
let ft = &ft
|
||||
let &ft ='python'
|
||||
let snippet_filetype = 'python'
|
||||
|
||||
" 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}"
|
||||
@@ -28,5 +27,3 @@ exe "Snipp tryef try:\n\t${1:pass}\nexcept ${2:Exception}, ${3:e}:\n\t${4:raise
|
||||
exe "Snipp ifmain if __name__ == '__main__':\n\t${1:main()}"
|
||||
" __magic__
|
||||
exe 'Snipp _ __${1:init}__${2}'
|
||||
|
||||
let &ft = ft
|
||||
|
||||
@@ -2,8 +2,7 @@ if !exists('loaded_snips') || exists('s:did_ruby_snips')
|
||||
fini
|
||||
en
|
||||
let s:did_ruby_snips = 1
|
||||
let ft = &ft
|
||||
let &ft ='ruby'
|
||||
let snippet_filetype = 'ruby'
|
||||
|
||||
" New Block
|
||||
exe "Snipp =b =begin rdoc\n\t${1}\n=end"
|
||||
@@ -167,4 +166,3 @@ exe 'Snipp clafn split("::").inject(Object) { |par, const| par.const_get(const)
|
||||
exe 'Snipp sinc class << self; self end'
|
||||
exe "Snipp nam namespace :${1:`Filename()`} do\n\t${2}\nend"
|
||||
exe "Snipp tas desc \"${1:Task description\}\"\ntask :${2:task_name => [:dependent, :tasks]} do\n\t${3}\nend"
|
||||
let &ft = ft
|
||||
|
||||
@@ -2,8 +2,7 @@ if !exists('loaded_snips') || exists('s:did_sh_snips')
|
||||
fini
|
||||
en
|
||||
let s:did_sh_snips = 1
|
||||
let ft = &ft
|
||||
let &ft = 'sh'
|
||||
let snippet_filetype = 'sh'
|
||||
|
||||
exe "Snipp if if [[ ${1:condition} ]]; then\n\t${2:#statements}\nfi"
|
||||
exe "Snipp elif elif [[ ${1:condition} ]]; then\n\t${2:#statements}"
|
||||
@@ -11,5 +10,3 @@ exe "Snipp for for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do\n\t${3:#statement
|
||||
exe "Snipp wh while [[ ${1:condition} ]]; do\n\t${2:#statements}\ndone"
|
||||
exe "Snipp until [[ ${1:condition} ]]; do\n\t${2:#statements}\ndone"
|
||||
exe "Snipp case case ${1:word} in\n\t${2:pattern})\n\t\t${3};;\nesac"
|
||||
|
||||
let &ft = ft
|
||||
|
||||
@@ -2,8 +2,7 @@ if !exists('loaded_snips') || exists('s:did_tex_snips')
|
||||
fini
|
||||
en
|
||||
let s:did_tex_snips = 1
|
||||
let ft = &ft
|
||||
let &ft = 'tex'
|
||||
let snippet_filetype = 'tex'
|
||||
|
||||
" \begin{}...\end{}
|
||||
exe "Snipp begin \\begin{${1:env}}\n\t${2}\n\\end{$1}"
|
||||
@@ -49,5 +48,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}'
|
||||
|
||||
let &ft = ft
|
||||
|
||||
@@ -2,8 +2,7 @@ if !exists('g:loaded_snips') || exists('s:did_vim_snips')
|
||||
fini
|
||||
en
|
||||
let s:did_vim_snips = 1
|
||||
let ft = &ft
|
||||
let &ft = 'vim'
|
||||
let snippet_filetype = 'vim'
|
||||
|
||||
" snippets for making snippets :)
|
||||
exe 'Snipp snip exe "Snipp ${1:trigger}"${2}'
|
||||
@@ -16,5 +15,3 @@ exe "Snipp for for ${1:needle} in ${2:haystack}\n\t${3:\" code}\nendfor"
|
||||
exe "Snipp wh wh ${1:condition}\n\t${2:\" code}\nendw"
|
||||
exe "Snipp if if ${1:condition}\n\t${2:\" code}\nendif"
|
||||
exe "Snipp ife if ${1:condition}\n\t${2}\nelse\n\t${3}\nendif"
|
||||
|
||||
let &ft = ft
|
||||
|
||||
@@ -12,7 +12,7 @@ snor ' b<bs>'
|
||||
snor <right> <esc>a
|
||||
snor <left> <esc>bi
|
||||
|
||||
au FileType objc,cpp,cs let &ft .= '.c'
|
||||
au FileType objc,cpp,cs let &ft = expand('<amatch>').'.c'
|
||||
|
||||
" By default load snippets in ~/.vim/snippets/<filetype>
|
||||
if !exists('snippets_dir')
|
||||
|
||||
@@ -16,7 +16,7 @@ endif
|
||||
let loaded_snips = 1
|
||||
if !exists('snips_author') | let snips_author = 'Me' | endif
|
||||
|
||||
com! -nargs=+ -bang Snipp call s:MakeSnippet(<q-args>, &ft, <bang>0)
|
||||
com! -nargs=+ -bang Snipp call s:MakeSnippet(<q-args>, snippet_filetype, <bang>0)
|
||||
com! -nargs=+ -bang GlobalSnip call s:MakeSnippet(<q-args>, '_', <bang>0)
|
||||
|
||||
let s:snippets = {} | let s:multi_snips = {}
|
||||
@@ -133,9 +133,8 @@ fun! TriggerSnippet()
|
||||
let col = col('.')-len(word)
|
||||
sil exe 's/'.escape(word, '.^$/\*[]').'\%#//'
|
||||
return s:ExpandSnippet(col)
|
||||
elseif exists('s:snipPos')
|
||||
return s:JumpTabStop()
|
||||
endif
|
||||
if exists('s:snipPos') | return s:JumpTabStop() | endif
|
||||
return exists('s:sid') ? {s:sid}_SuperTab('n') : "\<tab>"
|
||||
endf
|
||||
|
||||
|
||||
Reference in New Issue
Block a user