Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 116 lines (100 sloc) 2.783 kB
522e5ca @scrooloose add old nerdtree snippets
authored
1 "ruby {{{1
892738e @jmcantrell Fixed default argument when no argument is passed.
jmcantrell authored
2 function! Snippet_RubyClassNameFromFilename(...)
522e5ca @scrooloose add old nerdtree snippets
authored
3 let name = expand("%:t:r")
291dd3c @jmcantrell Added ability to provide a default argument to the "get class" functi…
jmcantrell authored
4 if len(name) == 0
892738e @jmcantrell Fixed default argument when no argument is passed.
jmcantrell authored
5 if a:0 == 0
291dd3c @jmcantrell Added ability to provide a default argument to the "get class" functi…
jmcantrell authored
6 let name = 'MyClass'
7 else
892738e @jmcantrell Fixed default argument when no argument is passed.
jmcantrell authored
8 let name = a:1
291dd3c @jmcantrell Added ability to provide a default argument to the "get class" functi…
jmcantrell authored
9 endif
10 endif
f8e281c @mikem Simplify RSpec require
mikem authored
11 return Snippet_Camelcase(substitute(name, '_spec$', '', ''))
522e5ca @scrooloose add old nerdtree snippets
authored
12 endfunction
13
892738e @jmcantrell Fixed default argument when no argument is passed.
jmcantrell authored
14 function! Snippet_MigrationNameFromFilename(...)
522e5ca @scrooloose add old nerdtree snippets
authored
15 let name = substitute(expand("%:t:r"), '^.\{-}_', '', '')
291dd3c @jmcantrell Added ability to provide a default argument to the "get class" functi…
jmcantrell authored
16 if len(name) == 0
892738e @jmcantrell Fixed default argument when no argument is passed.
jmcantrell authored
17 if a:0 == 0
291dd3c @jmcantrell Added ability to provide a default argument to the "get class" functi…
jmcantrell authored
18 let name = 'MyClass'
19 else
892738e @jmcantrell Fixed default argument when no argument is passed.
jmcantrell authored
20 let name = a:1
291dd3c @jmcantrell Added ability to provide a default argument to the "get class" functi…
jmcantrell authored
21 endif
22 endif
ba6fa12 @scrooloose start converting to the snipmate format, still lots to do
authored
23 return Snippet_Camelcase(name)
522e5ca @scrooloose add old nerdtree snippets
authored
24 endfunction
25
26
27 "python {{{1
892738e @jmcantrell Fixed default argument when no argument is passed.
jmcantrell authored
28 function! Snippet_PythonClassNameFromFilename(...)
522e5ca @scrooloose add old nerdtree snippets
authored
29 let name = expand("%:t:r")
291dd3c @jmcantrell Added ability to provide a default argument to the "get class" functi…
jmcantrell authored
30 if len(name) == 0
892738e @jmcantrell Fixed default argument when no argument is passed.
jmcantrell authored
31 if a:0 == 0
291dd3c @jmcantrell Added ability to provide a default argument to the "get class" functi…
jmcantrell authored
32 let name = 'MyClass'
33 else
892738e @jmcantrell Fixed default argument when no argument is passed.
jmcantrell authored
34 let name = a:1
291dd3c @jmcantrell Added ability to provide a default argument to the "get class" functi…
jmcantrell authored
35 endif
36 endif
ba6fa12 @scrooloose start converting to the snipmate format, still lots to do
authored
37 return Snippet_Camelcase(name)
522e5ca @scrooloose add old nerdtree snippets
authored
38 endfunction
39
40 "php {{{1
892738e @jmcantrell Fixed default argument when no argument is passed.
jmcantrell authored
41 function! Snippet_PHPClassNameFromFilename(...)
291dd3c @jmcantrell Added ability to provide a default argument to the "get class" functi…
jmcantrell authored
42 let name = expand("%:t:r:r")
43 if len(name) == 0
892738e @jmcantrell Fixed default argument when no argument is passed.
jmcantrell authored
44 if a:0 == 0
291dd3c @jmcantrell Added ability to provide a default argument to the "get class" functi…
jmcantrell authored
45 let name = 'MyClass'
46 else
892738e @jmcantrell Fixed default argument when no argument is passed.
jmcantrell authored
47 let name = a:1
291dd3c @jmcantrell Added ability to provide a default argument to the "get class" functi…
jmcantrell authored
48 endif
49 endif
50 return name
522e5ca @scrooloose add old nerdtree snippets
authored
51 endfunction
52
53 "java {{{1
892738e @jmcantrell Fixed default argument when no argument is passed.
jmcantrell authored
54 function! Snippet_JavaClassNameFromFilename(...)
291dd3c @jmcantrell Added ability to provide a default argument to the "get class" functi…
jmcantrell authored
55 let name = expand("%:t:r")
56 if len(name) == 0
892738e @jmcantrell Fixed default argument when no argument is passed.
jmcantrell authored
57 if a:0 == 0
291dd3c @jmcantrell Added ability to provide a default argument to the "get class" functi…
jmcantrell authored
58 let name = 'MyClass'
59 else
892738e @jmcantrell Fixed default argument when no argument is passed.
jmcantrell authored
60 let name = a:1
291dd3c @jmcantrell Added ability to provide a default argument to the "get class" functi…
jmcantrell authored
61 endif
62 endif
63 return name
522e5ca @scrooloose add old nerdtree snippets
authored
64 endfunction
65
66 function! Snippet_JavaInstanceVarType(name)
67 let oldview = winsaveview()
68 if searchdecl(a:name) == 0
69 normal! B
70 let old_reg = @"
71 normal! yaW
72 let type = @"
73 let @" = old_reg
74 call winrestview(oldview)
75 let type = substitute(type, '\s\+$', '', '')
76
77 "searchdecl treats 'return foo;' as a declaration of foo
78 if type != 'return'
79 return type
80 endif
81 endif
82 return "<+type+>"
83 endfunction
84
85
86 "global {{{1
87 function! s:start_comment()
88 return substitute(&commentstring, '^\([^ ]*\)\s*%s\(.*\)$', '\1', '')
89 endfunction
90
91 function! s:end_comment()
92 return substitute(&commentstring, '^.*%s\(.*\)$', '\1', '')
93 endfunction
94
95 function! Snippet_Modeline()
3e73632 @fishman fixed modeline snippet
fishman authored
96 return s:start_comment() . " vim: set ${1:settings}:" . s:end_comment()
522e5ca @scrooloose add old nerdtree snippets
authored
97 endfunction
98
ba6fa12 @scrooloose start converting to the snipmate format, still lots to do
authored
99 function! Snippet_Camelcase(s)
100 "upcase the first letter
101 let toReturn = substitute(a:s, '^\(.\)', '\=toupper(submatch(1))', '')
102 "turn all '_x' into 'X'
103 return substitute(toReturn, '_\(.\)', '\=toupper(submatch(1))', 'g')
104 endfunction
105
106 function! Snippet_Underscore(s)
107 "down the first letter
108 let toReturn = substitute(a:s, '^\(.\)', '\=tolower(submatch(1))', '')
109 "turn all 'X' into '_x'
110 return substitute(toReturn, '\([A-Z]\)', '\=tolower("_".submatch(1))', 'g')
111 endfunction
522e5ca @scrooloose add old nerdtree snippets
authored
112
113
114 " modeline {{{1
115 " vim: set fdm=marker:
Something went wrong with that request. Please try again.