utils 0.0.53 → 0.0.54
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/create_tags +8 -0
- data/lib/utils/config/vim/after/syntax/haml.vim +9 -0
- data/lib/utils/config/vim/after/syntax/html.vim +11 -0
- data/lib/utils/config/vim/compiler/coffee.vim +68 -0
- data/lib/utils/config/vim/doc/coffee-script.txt +116 -0
- data/lib/utils/config/vim/ftdetect/coffee.vim +8 -0
- data/lib/utils/config/vim/ftdetect/eco.vim +1 -0
- data/lib/utils/config/vim/ftplugin/coffee.vim +221 -0
- data/lib/utils/config/vim/indent/coffee.vim +338 -0
- data/lib/utils/config/vim/syntax/coffee.vim +217 -0
- data/lib/utils/config/vim/syntax/eco.vim +62 -0
- data/lib/utils/config/vimrc +1 -1
- data/lib/utils/version.rb +1 -1
- data/utils.gemspec +4 -4
- metadata +15 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.54
|
data/bin/create_tags
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
paths = %w[ . ] + `bundle list --paths`.lines.map(&:chomp)
|
4
|
+
cmd = %w[ ctags --recurse=yes --languages=Ruby,C ] + paths
|
5
|
+
$DEBUG and warn "Executing #{cmd * ' '}."
|
6
|
+
system *cmd
|
7
|
+
megabytes = File.size('tags').to_f / 1024 ** 2 rescue nil
|
8
|
+
megabytes and warn 'Created %.3fM of tags.' % megabytes
|
@@ -0,0 +1,9 @@
|
|
1
|
+
" Language: CoffeeScript
|
2
|
+
" Maintainer: Sven Felix Oberquelle <Svelix.Github@gmail.com>
|
3
|
+
" URL: http://github.com/kchmck/vim-coffee-script
|
4
|
+
" License: WTFPL
|
5
|
+
|
6
|
+
" Inherit coffee from html so coffeeComment isn't redefined and given higher
|
7
|
+
" priority than hamlInterpolation.
|
8
|
+
syn cluster hamlCoffeescript contains=@htmlCoffeeScript
|
9
|
+
syn region hamlCoffeescriptFilter matchgroup=hamlFilter start="^\z(\s*\):coffeescript\s*$" end="^\%(\z1 \| *$\)\@!" contains=@hamlCoffeeScript,hamlInterpolation keepend
|
@@ -0,0 +1,11 @@
|
|
1
|
+
" Language: CoffeeScript
|
2
|
+
" Maintainer: Mick Koch <kchmck@gmail.com>
|
3
|
+
" URL: http://github.com/kchmck/vim-coffee-script
|
4
|
+
" License: WTFPL
|
5
|
+
|
6
|
+
" Syntax highlighting for text/coffeescript script tags
|
7
|
+
syn include @htmlCoffeeScript syntax/coffee.vim
|
8
|
+
syn region coffeeScript start=+<script [^>]*type *=[^>]*text/coffeescript[^>]*>+
|
9
|
+
\ end=+</script>+me=s-1 keepend
|
10
|
+
\ contains=@htmlCoffeeScript,htmlScriptTag,@htmlPreproc
|
11
|
+
\ containedin=htmlHead
|
@@ -0,0 +1,68 @@
|
|
1
|
+
" Language: CoffeeScript
|
2
|
+
" Maintainer: Mick Koch <kchmck@gmail.com>
|
3
|
+
" URL: http://github.com/kchmck/vim-coffee-script
|
4
|
+
" License: WTFPL
|
5
|
+
|
6
|
+
if exists('current_compiler')
|
7
|
+
finish
|
8
|
+
endif
|
9
|
+
|
10
|
+
let current_compiler = 'coffee'
|
11
|
+
" Pattern to check if coffee is the compiler
|
12
|
+
let s:pat = '^' . current_compiler
|
13
|
+
|
14
|
+
" Extra options passed to CoffeeMake
|
15
|
+
if !exists("coffee_make_options")
|
16
|
+
let coffee_make_options = ""
|
17
|
+
endif
|
18
|
+
|
19
|
+
" Get a `makeprg` for the current filename. This is needed to support filenames
|
20
|
+
" with spaces and quotes, but also not break generic `make`.
|
21
|
+
function! s:GetMakePrg()
|
22
|
+
return 'coffee -c ' . g:coffee_make_options . ' $* ' . fnameescape(expand('%'))
|
23
|
+
endfunction
|
24
|
+
|
25
|
+
" Set `makeprg` and return 1 if coffee is still the compiler, else return 0.
|
26
|
+
function! s:SetMakePrg()
|
27
|
+
if &l:makeprg =~ s:pat
|
28
|
+
let &l:makeprg = s:GetMakePrg()
|
29
|
+
elseif &g:makeprg =~ s:pat
|
30
|
+
let &g:makeprg = s:GetMakePrg()
|
31
|
+
else
|
32
|
+
return 0
|
33
|
+
endif
|
34
|
+
|
35
|
+
return 1
|
36
|
+
endfunction
|
37
|
+
|
38
|
+
" Set a dummy compiler so we can check whether to set locally or globally.
|
39
|
+
CompilerSet makeprg=coffee
|
40
|
+
call s:SetMakePrg()
|
41
|
+
|
42
|
+
CompilerSet errorformat=Error:\ In\ %f\\,\ %m\ on\ line\ %l,
|
43
|
+
\Error:\ In\ %f\\,\ Parse\ error\ on\ line\ %l:\ %m,
|
44
|
+
\SyntaxError:\ In\ %f\\,\ %m,
|
45
|
+
\%-G%.%#
|
46
|
+
|
47
|
+
" Compile the current file.
|
48
|
+
command! -bang -bar -nargs=* CoffeeMake make<bang> <args>
|
49
|
+
|
50
|
+
" Set `makeprg` on rename since we embed the filename in the setting.
|
51
|
+
augroup CoffeeUpdateMakePrg
|
52
|
+
autocmd!
|
53
|
+
|
54
|
+
" Update `makeprg` if coffee is still the compiler, else stop running this
|
55
|
+
" function.
|
56
|
+
function! s:UpdateMakePrg()
|
57
|
+
if !s:SetMakePrg()
|
58
|
+
autocmd! CoffeeUpdateMakePrg
|
59
|
+
endif
|
60
|
+
endfunction
|
61
|
+
|
62
|
+
" Set autocmd locally if compiler was set locally.
|
63
|
+
if &l:makeprg =~ s:pat
|
64
|
+
autocmd BufFilePost,BufWritePost <buffer> call s:UpdateMakePrg()
|
65
|
+
else
|
66
|
+
autocmd BufFilePost,BufWritePost call s:UpdateMakePrg()
|
67
|
+
endif
|
68
|
+
augroup END
|
@@ -0,0 +1,116 @@
|
|
1
|
+
*coffee-script.txt* For Vim version 7.3
|
2
|
+
|
3
|
+
=============================================================================
|
4
|
+
Author: Mick Koch <kchmck@gmail.com> *coffee-script-author*
|
5
|
+
License: WTFPL (see |coffee-script-license|)
|
6
|
+
=============================================================================
|
7
|
+
|
8
|
+
CONTENTS *coffee-script-contents*
|
9
|
+
|
10
|
+
|coffee-script-introduction| Introduction and Feature Summary
|
11
|
+
|coffee-script-commands| Commands
|
12
|
+
|coffee-script-settings| Settings
|
13
|
+
|
14
|
+
{Vi does not have any of this}
|
15
|
+
|
16
|
+
=============================================================================
|
17
|
+
|
18
|
+
INTRODUCTION *coffee-script*
|
19
|
+
*coffee-script-introduction*
|
20
|
+
|
21
|
+
This plugin adds support for CoffeeScript syntax, indenting, and compiling.
|
22
|
+
Also included is an eco syntax and support for CoffeeScript in Haml and HTML.
|
23
|
+
|
24
|
+
COMMANDS *coffee-script-commands*
|
25
|
+
|
26
|
+
*:CoffeeMake*
|
27
|
+
:CoffeeMake[!] {opts} Wrapper around |:make| that also passes options in
|
28
|
+
|g:coffee_make_options| to the compiler. Use |:silent|
|
29
|
+
to hide compiler output. See |:make| for more
|
30
|
+
information about the bang and other helpful commands.
|
31
|
+
|
32
|
+
*:CoffeeCompile*
|
33
|
+
:[range]CoffeeCompile [vertical] [{win-size}]
|
34
|
+
Shows how the current file or [range] is compiled
|
35
|
+
to JavaScript. [vertical] (or vert) splits the
|
36
|
+
compile buffer vertically instead of horizontally, and
|
37
|
+
{win-size} sets the initial size of the buffer. It can
|
38
|
+
be closed quickly with the "q" key.
|
39
|
+
|
40
|
+
:CoffeeCompile {watch} [vertical] [{win-size}]
|
41
|
+
The watch mode of :CoffeeCompile emulates the "Try
|
42
|
+
CoffeeScript" live preview on the CoffeeScript web
|
43
|
+
site. After making changes to the source file,
|
44
|
+
exiting insert mode will cause the preview buffer to
|
45
|
+
update automatically. {watch} should be given as
|
46
|
+
"watch" or "unwatch," where the latter will stop the
|
47
|
+
automatic updating. [vertical] is recommended, and
|
48
|
+
'scrollbind' is useful.
|
49
|
+
|
50
|
+
*:CoffeeRun*
|
51
|
+
:[range]CoffeeRun Compiles the file or [range] and runs the resulting
|
52
|
+
JavaScript, displaying the output.
|
53
|
+
|
54
|
+
SETTINGS *coffee-script-settings*
|
55
|
+
|
56
|
+
You can configure plugin behavior using global variables and syntax commands
|
57
|
+
in your |vimrc|.
|
58
|
+
|
59
|
+
Global Settings~
|
60
|
+
|
61
|
+
*g:coffee_make_options*
|
62
|
+
Set default options |CoffeeMake| should pass to the compiler.
|
63
|
+
>
|
64
|
+
let coffee_make_options = '--bare'
|
65
|
+
<
|
66
|
+
*g:coffee_compile_vert*
|
67
|
+
Split the CoffeeCompile buffer vertically by default.
|
68
|
+
>
|
69
|
+
let coffee_compile_vert = 1
|
70
|
+
|
71
|
+
Syntax Highlighting~
|
72
|
+
*ft-coffee-script-syntax*
|
73
|
+
Trailing whitespace is highlighted as an error by default. This can be
|
74
|
+
disabled with:
|
75
|
+
>
|
76
|
+
hi link coffeeSpaceError NONE
|
77
|
+
|
78
|
+
Trailing semicolons are also considered an error (for help transitioning from
|
79
|
+
JavaScript.) This can be disabled with:
|
80
|
+
>
|
81
|
+
hi link coffeeSemicolonError NONE
|
82
|
+
|
83
|
+
Reserved words like {function} and {var} are highlighted where they're not
|
84
|
+
allowed in CoffeeScript. This can be disabled with:
|
85
|
+
>
|
86
|
+
hi link coffeeReservedError NONE
|
87
|
+
|
88
|
+
COMPILER *compiler-coffee-script*
|
89
|
+
|
90
|
+
A CoffeeScript compiler is provided as a wrapper around {coffee} and can be
|
91
|
+
loaded with;
|
92
|
+
>
|
93
|
+
compiler coffee
|
94
|
+
|
95
|
+
This is done automatically when a CoffeeScript file is opened if no other
|
96
|
+
compiler is loaded.
|
97
|
+
|
98
|
+
=============================================================================
|
99
|
+
|
100
|
+
LICENSE *coffee-script-license*
|
101
|
+
|
102
|
+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
103
|
+
Version 2, December 2004
|
104
|
+
|
105
|
+
Copyright (C) 2010 to 2011 Mick Koch <kchmck@gmail.com>
|
106
|
+
|
107
|
+
Everyone is permitted to copy and distribute verbatim or modified
|
108
|
+
copies of this license document, and changing it is allowed as long
|
109
|
+
as the name is changed.
|
110
|
+
|
111
|
+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
112
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
113
|
+
|
114
|
+
0. You just DO WHAT THE FUCK YOU WANT TO.
|
115
|
+
|
116
|
+
vim:tw=78:ts=8:ft=help:norl:
|
@@ -0,0 +1,8 @@
|
|
1
|
+
" Language: CoffeeScript
|
2
|
+
" Maintainer: Mick Koch <kchmck@gmail.com>
|
3
|
+
" URL: http://github.com/kchmck/vim-coffee-script
|
4
|
+
" License: WTFPL
|
5
|
+
|
6
|
+
autocmd BufNewFile,BufRead *.coffee set filetype=coffee
|
7
|
+
autocmd BufNewFile,BufRead *Cakefile set filetype=coffee
|
8
|
+
autocmd BufNewFile,BufRead *.coffeekup set filetype=coffee
|
@@ -0,0 +1 @@
|
|
1
|
+
autocmd BufNewFile,BufRead *.eco set filetype=eco
|
@@ -0,0 +1,221 @@
|
|
1
|
+
" Language: CoffeeScript
|
2
|
+
" Maintainer: Mick Koch <kchmck@gmail.com>
|
3
|
+
" URL: http://github.com/kchmck/vim-coffee-script
|
4
|
+
" License: WTFPL
|
5
|
+
|
6
|
+
if exists("b:did_ftplugin")
|
7
|
+
finish
|
8
|
+
endif
|
9
|
+
|
10
|
+
let b:did_ftplugin = 1
|
11
|
+
|
12
|
+
setlocal formatoptions-=t formatoptions+=croql
|
13
|
+
setlocal comments=:#
|
14
|
+
setlocal commentstring=#\ %s
|
15
|
+
setlocal omnifunc=javascriptcomplete#CompleteJS
|
16
|
+
|
17
|
+
" Enable CoffeeMake if it won't overwrite any settings.
|
18
|
+
if !len(&l:makeprg)
|
19
|
+
compiler coffee
|
20
|
+
endif
|
21
|
+
|
22
|
+
" Reset the global variables used by CoffeeCompile.
|
23
|
+
function! s:CoffeeCompileResetVars()
|
24
|
+
" Position in the source buffer
|
25
|
+
let s:coffee_compile_src_buf = -1
|
26
|
+
let s:coffee_compile_src_pos = []
|
27
|
+
|
28
|
+
" Position in the CoffeeCompile buffer
|
29
|
+
let s:coffee_compile_buf = -1
|
30
|
+
let s:coffee_compile_win = -1
|
31
|
+
let s:coffee_compile_pos = []
|
32
|
+
|
33
|
+
" If CoffeeCompile is watching a buffer
|
34
|
+
let s:coffee_compile_watch = 0
|
35
|
+
endfunction
|
36
|
+
|
37
|
+
" Save the cursor position when moving to and from the CoffeeCompile buffer.
|
38
|
+
function! s:CoffeeCompileSavePos()
|
39
|
+
let buf = bufnr('%')
|
40
|
+
let pos = getpos('.')
|
41
|
+
|
42
|
+
if buf == s:coffee_compile_buf
|
43
|
+
let s:coffee_compile_pos = pos
|
44
|
+
else
|
45
|
+
let s:coffee_compile_src_buf = buf
|
46
|
+
let s:coffee_compile_src_pos = pos
|
47
|
+
endif
|
48
|
+
endfunction
|
49
|
+
|
50
|
+
" Restore the cursor to the source buffer.
|
51
|
+
function! s:CoffeeCompileRestorePos()
|
52
|
+
let win = bufwinnr(s:coffee_compile_src_buf)
|
53
|
+
|
54
|
+
if win != -1
|
55
|
+
exec win 'wincmd w'
|
56
|
+
call setpos('.', s:coffee_compile_src_pos)
|
57
|
+
endif
|
58
|
+
endfunction
|
59
|
+
|
60
|
+
" Close the CoffeeCompile buffer and clean things up.
|
61
|
+
function! s:CoffeeCompileClose()
|
62
|
+
silent! autocmd! CoffeeCompileAuPos
|
63
|
+
silent! autocmd! CoffeeCompileAuWatch
|
64
|
+
|
65
|
+
call s:CoffeeCompileRestorePos()
|
66
|
+
call s:CoffeeCompileResetVars()
|
67
|
+
endfunction
|
68
|
+
|
69
|
+
" Update the CoffeeCompile buffer given some input lines.
|
70
|
+
function! s:CoffeeCompileUpdate(startline, endline)
|
71
|
+
let input = join(getline(a:startline, a:endline), "\n")
|
72
|
+
|
73
|
+
" Coffee doesn't like empty input.
|
74
|
+
if !len(input)
|
75
|
+
return
|
76
|
+
endif
|
77
|
+
|
78
|
+
" Compile input.
|
79
|
+
let output = system('coffee -scb 2>&1', input)
|
80
|
+
|
81
|
+
" Move to the CoffeeCompile buffer.
|
82
|
+
exec s:coffee_compile_win 'wincmd w'
|
83
|
+
|
84
|
+
" Replace buffer contents with new output and delete the last empty line.
|
85
|
+
setlocal modifiable
|
86
|
+
exec '% delete _'
|
87
|
+
put! =output
|
88
|
+
exec '$ delete _'
|
89
|
+
setlocal nomodifiable
|
90
|
+
|
91
|
+
" Highlight as JavaScript if there is no compile error.
|
92
|
+
if v:shell_error
|
93
|
+
setlocal filetype=
|
94
|
+
else
|
95
|
+
setlocal filetype=javascript
|
96
|
+
endif
|
97
|
+
|
98
|
+
" Restore the cursor in the compiled output.
|
99
|
+
call setpos('.', s:coffee_compile_pos)
|
100
|
+
endfunction
|
101
|
+
|
102
|
+
" Update the CoffeeCompile buffer with the whole source buffer and restore the
|
103
|
+
" cursor.
|
104
|
+
function! s:CoffeeCompileWatchUpdate()
|
105
|
+
call s:CoffeeCompileSavePos()
|
106
|
+
call s:CoffeeCompileUpdate(1, '$')
|
107
|
+
call s:CoffeeCompileRestorePos()
|
108
|
+
endfunction
|
109
|
+
|
110
|
+
" Peek at compiled CoffeeScript in a scratch buffer. We handle ranges like this
|
111
|
+
" to prevent the cursor from being moved (and its position saved) before the
|
112
|
+
" function is called.
|
113
|
+
function! s:CoffeeCompile(startline, endline, args)
|
114
|
+
" Don't compile the CoffeeCompile buffer.
|
115
|
+
if bufnr('%') == s:coffee_compile_buf
|
116
|
+
return
|
117
|
+
endif
|
118
|
+
|
119
|
+
" Parse arguments.
|
120
|
+
let watch = a:args =~ '\<watch\>'
|
121
|
+
let unwatch = a:args =~ '\<unwatch\>'
|
122
|
+
let size = str2nr(matchstr(a:args, '\<\d\+\>'))
|
123
|
+
|
124
|
+
" Determine default split direction.
|
125
|
+
if exists("g:coffee_compile_vert")
|
126
|
+
let vert = 1
|
127
|
+
else
|
128
|
+
let vert = a:args =~ '\<vert\%[ical]\>'
|
129
|
+
endif
|
130
|
+
|
131
|
+
" Remove any watch listeners.
|
132
|
+
silent! autocmd! CoffeeCompileAuWatch
|
133
|
+
|
134
|
+
" If just unwatching, don't compile.
|
135
|
+
if unwatch
|
136
|
+
let s:coffee_compile_watch = 0
|
137
|
+
return
|
138
|
+
endif
|
139
|
+
|
140
|
+
if watch
|
141
|
+
let s:coffee_compile_watch = 1
|
142
|
+
endif
|
143
|
+
|
144
|
+
call s:CoffeeCompileSavePos()
|
145
|
+
|
146
|
+
" Build the CoffeeCompile buffer if it doesn't exist.
|
147
|
+
if s:coffee_compile_buf == -1
|
148
|
+
let src_win = bufwinnr(s:coffee_compile_src_buf)
|
149
|
+
|
150
|
+
" Create the new window and resize it.
|
151
|
+
if vert
|
152
|
+
let width = size ? size : winwidth(src_win) / 2
|
153
|
+
|
154
|
+
vertical new
|
155
|
+
exec 'vertical resize' width
|
156
|
+
else
|
157
|
+
" Try to guess the compiled output's height.
|
158
|
+
let height = size ? size : min([winheight(src_win) / 2,
|
159
|
+
\ a:endline - a:startline + 2])
|
160
|
+
|
161
|
+
botright new
|
162
|
+
exec 'resize' height
|
163
|
+
endif
|
164
|
+
|
165
|
+
" Set up scratch buffer.
|
166
|
+
setlocal bufhidden=wipe buftype=nofile
|
167
|
+
setlocal nobuflisted nomodifiable noswapfile nowrap
|
168
|
+
|
169
|
+
autocmd BufWipeout <buffer> call s:CoffeeCompileClose()
|
170
|
+
nnoremap <buffer> <silent> q :hide<CR>
|
171
|
+
|
172
|
+
" Save the cursor position on each buffer switch.
|
173
|
+
augroup CoffeeCompileAuPos
|
174
|
+
autocmd BufEnter,BufLeave * call s:CoffeeCompileSavePos()
|
175
|
+
augroup END
|
176
|
+
|
177
|
+
let s:coffee_compile_buf = bufnr('%')
|
178
|
+
let s:coffee_compile_win = bufwinnr(s:coffee_compile_buf)
|
179
|
+
endif
|
180
|
+
|
181
|
+
" Go back to the source buffer and do the initial compile.
|
182
|
+
call s:CoffeeCompileRestorePos()
|
183
|
+
|
184
|
+
if s:coffee_compile_watch
|
185
|
+
call s:CoffeeCompileWatchUpdate()
|
186
|
+
|
187
|
+
augroup CoffeeCompileAuWatch
|
188
|
+
autocmd InsertLeave <buffer> call s:CoffeeCompileWatchUpdate()
|
189
|
+
augroup END
|
190
|
+
else
|
191
|
+
call s:CoffeeCompileUpdate(a:startline, a:endline)
|
192
|
+
endif
|
193
|
+
endfunction
|
194
|
+
|
195
|
+
" Complete arguments for the CoffeeCompile command.
|
196
|
+
function! s:CoffeeCompileComplete(arg, cmdline, cursor)
|
197
|
+
let args = ['unwatch', 'vertical', 'watch']
|
198
|
+
|
199
|
+
if !len(a:arg)
|
200
|
+
return args
|
201
|
+
endif
|
202
|
+
|
203
|
+
let match = '^' . a:arg
|
204
|
+
|
205
|
+
for arg in args
|
206
|
+
if arg =~ match
|
207
|
+
return [arg]
|
208
|
+
endif
|
209
|
+
endfor
|
210
|
+
endfunction
|
211
|
+
|
212
|
+
" Don't let new windows overwrite the CoffeeCompile variables.
|
213
|
+
if !exists("s:coffee_compile_buf")
|
214
|
+
call s:CoffeeCompileResetVars()
|
215
|
+
endif
|
216
|
+
|
217
|
+
" Peek at compiled CoffeeScript.
|
218
|
+
command! -range=% -bar -nargs=* -complete=customlist,s:CoffeeCompileComplete
|
219
|
+
\ CoffeeCompile call s:CoffeeCompile(<line1>, <line2>, <q-args>)
|
220
|
+
" Run some CoffeeScript.
|
221
|
+
command! -range=% -bar CoffeeRun <line1>,<line2>:w !coffee -s
|
@@ -0,0 +1,338 @@
|
|
1
|
+
" Language: CoffeeScript
|
2
|
+
" Maintainer: Mick Koch <kchmck@gmail.com>
|
3
|
+
" URL: http://github.com/kchmck/vim-coffee-script
|
4
|
+
" License: WTFPL
|
5
|
+
|
6
|
+
if exists("b:did_indent")
|
7
|
+
finish
|
8
|
+
endif
|
9
|
+
|
10
|
+
let b:did_indent = 1
|
11
|
+
|
12
|
+
setlocal autoindent
|
13
|
+
setlocal indentexpr=GetCoffeeIndent(v:lnum)
|
14
|
+
" Make sure GetCoffeeIndent is run when these are typed so they can be
|
15
|
+
" indented or outdented.
|
16
|
+
setlocal indentkeys+=0],0),0.,=else,=when,=catch,=finally
|
17
|
+
|
18
|
+
" Only define the function once.
|
19
|
+
if exists("*GetCoffeeIndent")
|
20
|
+
finish
|
21
|
+
endif
|
22
|
+
|
23
|
+
" Keywords to indent after
|
24
|
+
let s:INDENT_AFTER_KEYWORD = '^\%(if\|unless\|else\|for\|while\|until\|'
|
25
|
+
\ . 'loop\|switch\|when\|try\|catch\|finally\|'
|
26
|
+
\ . 'class\)\>'
|
27
|
+
|
28
|
+
" Operators to indent after
|
29
|
+
let s:INDENT_AFTER_OPERATOR = '\%([([{:=]\|[-=]>\)$'
|
30
|
+
|
31
|
+
" Keywords and operators that continue a line
|
32
|
+
let s:CONTINUATION = '\<\%(is\|isnt\|and\|or\)\>$'
|
33
|
+
\ . '\|'
|
34
|
+
\ . '\%(-\@<!-\|+\@<!+\|<\|[-=]\@<!>\|\*\|/\@<!/\|%\||\|'
|
35
|
+
\ . '&\|,\|\.\@<!\.\)$'
|
36
|
+
|
37
|
+
" Operators that block continuation indenting
|
38
|
+
let s:CONTINUATION_BLOCK = '[([{:=]$'
|
39
|
+
|
40
|
+
" A continuation dot access
|
41
|
+
let s:DOT_ACCESS = '^\.'
|
42
|
+
|
43
|
+
" Keywords to outdent after
|
44
|
+
let s:OUTDENT_AFTER = '^\%(return\|break\|continue\|throw\)\>'
|
45
|
+
|
46
|
+
" A compound assignment like `... = if ...`
|
47
|
+
let s:COMPOUND_ASSIGNMENT = '[:=]\s*\%(if\|unless\|for\|while\|until\|'
|
48
|
+
\ . 'switch\|try\|class\)\>'
|
49
|
+
|
50
|
+
" A postfix condition like `return ... if ...`.
|
51
|
+
let s:POSTFIX_CONDITION = '\S\s\+\zs\<\%(if\|unless\)\>'
|
52
|
+
|
53
|
+
" A single-line else statement like `else ...` but not `else if ...
|
54
|
+
let s:SINGLE_LINE_ELSE = '^else\s\+\%(\<\%(if\|unless\)\>\)\@!'
|
55
|
+
|
56
|
+
" Max lines to look back for a match
|
57
|
+
let s:MAX_LOOKBACK = 50
|
58
|
+
|
59
|
+
" Syntax names for strings
|
60
|
+
let s:SYNTAX_STRING = 'coffee\%(String\|AssignString\|Embed\|Regex\|Heregex\|'
|
61
|
+
\ . 'Heredoc\)'
|
62
|
+
|
63
|
+
" Syntax names for comments
|
64
|
+
let s:SYNTAX_COMMENT = 'coffee\%(Comment\|BlockComment\|HeregexComment\)'
|
65
|
+
|
66
|
+
" Syntax names for strings and comments
|
67
|
+
let s:SYNTAX_STRING_COMMENT = s:SYNTAX_STRING . '\|' . s:SYNTAX_COMMENT
|
68
|
+
|
69
|
+
" Get the linked syntax name of a character.
|
70
|
+
function! s:SyntaxName(linenum, col)
|
71
|
+
return synIDattr(synID(a:linenum, a:col, 1), 'name')
|
72
|
+
endfunction
|
73
|
+
|
74
|
+
" Check if a character is in a comment.
|
75
|
+
function! s:IsComment(linenum, col)
|
76
|
+
return s:SyntaxName(a:linenum, a:col) =~ s:SYNTAX_COMMENT
|
77
|
+
endfunction
|
78
|
+
|
79
|
+
" Check if a character is in a string.
|
80
|
+
function! s:IsString(linenum, col)
|
81
|
+
return s:SyntaxName(a:linenum, a:col) =~ s:SYNTAX_STRING
|
82
|
+
endfunction
|
83
|
+
|
84
|
+
" Check if a character is in a comment or string.
|
85
|
+
function! s:IsCommentOrString(linenum, col)
|
86
|
+
return s:SyntaxName(a:linenum, a:col) =~ s:SYNTAX_STRING_COMMENT
|
87
|
+
endfunction
|
88
|
+
|
89
|
+
" Check if a whole line is a comment.
|
90
|
+
function! s:IsCommentLine(linenum)
|
91
|
+
" Check the first non-whitespace character.
|
92
|
+
return s:IsComment(a:linenum, indent(a:linenum) + 1)
|
93
|
+
endfunction
|
94
|
+
|
95
|
+
" Repeatedly search a line for a regex until one is found outside a string or
|
96
|
+
" comment.
|
97
|
+
function! s:SmartSearch(linenum, regex)
|
98
|
+
" Start at the first column.
|
99
|
+
let col = 0
|
100
|
+
|
101
|
+
" Search until there are no more matches, unless a good match is found.
|
102
|
+
while 1
|
103
|
+
call cursor(a:linenum, col + 1)
|
104
|
+
let [_, col] = searchpos(a:regex, 'cn', a:linenum)
|
105
|
+
|
106
|
+
" No more matches.
|
107
|
+
if !col
|
108
|
+
break
|
109
|
+
endif
|
110
|
+
|
111
|
+
if !s:IsCommentOrString(a:linenum, col)
|
112
|
+
return 1
|
113
|
+
endif
|
114
|
+
endwhile
|
115
|
+
|
116
|
+
" No good match found.
|
117
|
+
return 0
|
118
|
+
endfunction
|
119
|
+
|
120
|
+
" Skip a match if it's in a comment or string, is a single-line statement that
|
121
|
+
" isn't adjacent, or is a postfix condition.
|
122
|
+
function! s:ShouldSkip(startlinenum, linenum, col)
|
123
|
+
if s:IsCommentOrString(a:linenum, a:col)
|
124
|
+
return 1
|
125
|
+
endif
|
126
|
+
|
127
|
+
" Check for a single-line statement that isn't adjacent.
|
128
|
+
if s:SmartSearch(a:linenum, '\<then\>') && a:startlinenum - a:linenum > 1
|
129
|
+
return 1
|
130
|
+
endif
|
131
|
+
|
132
|
+
if s:SmartSearch(a:linenum, s:POSTFIX_CONDITION) &&
|
133
|
+
\ !s:SmartSearch(a:linenum, s:COMPOUND_ASSIGNMENT)
|
134
|
+
return 1
|
135
|
+
endif
|
136
|
+
|
137
|
+
return 0
|
138
|
+
endfunction
|
139
|
+
|
140
|
+
" Find the farthest line to look back to, capped to line 1 (zero and negative
|
141
|
+
" numbers cause bad things).
|
142
|
+
function! s:MaxLookback(startlinenum)
|
143
|
+
return max([1, a:startlinenum - s:MAX_LOOKBACK])
|
144
|
+
endfunction
|
145
|
+
|
146
|
+
" Get the skip expression for searchpair().
|
147
|
+
function! s:SkipExpr(startlinenum)
|
148
|
+
return "s:ShouldSkip(" . a:startlinenum . ", line('.'), col('.'))"
|
149
|
+
endfunction
|
150
|
+
|
151
|
+
" Search for pairs of text.
|
152
|
+
function! s:SearchPair(start, end)
|
153
|
+
" The cursor must be in the first column for regexes to match.
|
154
|
+
call cursor(0, 1)
|
155
|
+
|
156
|
+
let startlinenum = line('.')
|
157
|
+
|
158
|
+
" Don't need the W flag since MaxLookback caps the search to line 1.
|
159
|
+
return searchpair(a:start, '', a:end, 'bcn',
|
160
|
+
\ s:SkipExpr(startlinenum),
|
161
|
+
\ s:MaxLookback(startlinenum))
|
162
|
+
endfunction
|
163
|
+
|
164
|
+
" Try to find a previous matching line.
|
165
|
+
function! s:GetMatch(curline)
|
166
|
+
let firstchar = a:curline[0]
|
167
|
+
|
168
|
+
if firstchar == '}'
|
169
|
+
return s:SearchPair('{', '}')
|
170
|
+
elseif firstchar == ')'
|
171
|
+
return s:SearchPair('(', ')')
|
172
|
+
elseif firstchar == ']'
|
173
|
+
return s:SearchPair('\[', '\]')
|
174
|
+
elseif a:curline =~ '^else\>'
|
175
|
+
return s:SearchPair('\<\%(if\|unless\|when\)\>', '\<else\>')
|
176
|
+
elseif a:curline =~ '^catch\>'
|
177
|
+
return s:SearchPair('\<try\>', '\<catch\>')
|
178
|
+
elseif a:curline =~ '^finally\>'
|
179
|
+
return s:SearchPair('\<try\>', '\<finally\>')
|
180
|
+
endif
|
181
|
+
|
182
|
+
return 0
|
183
|
+
endfunction
|
184
|
+
|
185
|
+
" Get the nearest previous line that isn't a comment.
|
186
|
+
function! s:GetPrevNormalLine(startlinenum)
|
187
|
+
let curlinenum = a:startlinenum
|
188
|
+
|
189
|
+
while curlinenum > 0
|
190
|
+
let curlinenum = prevnonblank(curlinenum - 1)
|
191
|
+
|
192
|
+
if !s:IsCommentLine(curlinenum)
|
193
|
+
return curlinenum
|
194
|
+
endif
|
195
|
+
endwhile
|
196
|
+
|
197
|
+
return 0
|
198
|
+
endfunction
|
199
|
+
|
200
|
+
" Try to find a comment in a line.
|
201
|
+
function! s:FindComment(linenum)
|
202
|
+
let col = 0
|
203
|
+
|
204
|
+
while 1
|
205
|
+
call cursor(a:linenum, col + 1)
|
206
|
+
let [_, col] = searchpos('#', 'cn', a:linenum)
|
207
|
+
|
208
|
+
if !col
|
209
|
+
break
|
210
|
+
endif
|
211
|
+
|
212
|
+
if s:IsComment(a:linenum, col)
|
213
|
+
return col
|
214
|
+
endif
|
215
|
+
endwhile
|
216
|
+
|
217
|
+
return 0
|
218
|
+
endfunction
|
219
|
+
|
220
|
+
" Get a line without comments or surrounding whitespace.
|
221
|
+
function! s:GetTrimmedLine(linenum)
|
222
|
+
let comment = s:FindComment(a:linenum)
|
223
|
+
let line = getline(a:linenum)
|
224
|
+
|
225
|
+
if comment
|
226
|
+
" Subtract 1 to get to the column before the comment and another 1 for
|
227
|
+
" zero-based indexing.
|
228
|
+
let line = line[:comment - 2]
|
229
|
+
endif
|
230
|
+
|
231
|
+
return substitute(substitute(line, '^\s\+', '', ''),
|
232
|
+
\ '\s\+$', '', '')
|
233
|
+
endfunction
|
234
|
+
|
235
|
+
function! s:GetCoffeeIndent(curlinenum)
|
236
|
+
let prevlinenum = s:GetPrevNormalLine(a:curlinenum)
|
237
|
+
|
238
|
+
" Don't do anything if there's no previous line.
|
239
|
+
if !prevlinenum
|
240
|
+
return -1
|
241
|
+
endif
|
242
|
+
|
243
|
+
let curline = s:GetTrimmedLine(a:curlinenum)
|
244
|
+
|
245
|
+
" Try to find a previous matching statement. This handles outdenting.
|
246
|
+
let matchlinenum = s:GetMatch(curline)
|
247
|
+
|
248
|
+
if matchlinenum
|
249
|
+
return indent(matchlinenum)
|
250
|
+
endif
|
251
|
+
|
252
|
+
" Try to find a matching `when`.
|
253
|
+
if curline =~ '^when\>' && !s:SmartSearch(prevlinenum, '\<switch\>')
|
254
|
+
let linenum = a:curlinenum
|
255
|
+
|
256
|
+
while linenum > 0
|
257
|
+
let linenum = s:GetPrevNormalLine(linenum)
|
258
|
+
|
259
|
+
if getline(linenum) =~ '^\s*when\>'
|
260
|
+
return indent(linenum)
|
261
|
+
endif
|
262
|
+
endwhile
|
263
|
+
|
264
|
+
return -1
|
265
|
+
endif
|
266
|
+
|
267
|
+
let prevline = s:GetTrimmedLine(prevlinenum)
|
268
|
+
let previndent = indent(prevlinenum)
|
269
|
+
|
270
|
+
" Always indent after these operators.
|
271
|
+
if prevline =~ s:INDENT_AFTER_OPERATOR
|
272
|
+
return previndent + &shiftwidth
|
273
|
+
endif
|
274
|
+
|
275
|
+
" Indent after a continuation if it's the first.
|
276
|
+
if prevline =~ s:CONTINUATION
|
277
|
+
" If the line ends in a slash, make sure it isn't a regex.
|
278
|
+
if prevline =~ '/$'
|
279
|
+
" Move to the line so we can get the last column.
|
280
|
+
call cursor(prevlinenum)
|
281
|
+
|
282
|
+
if s:IsString(prevlinenum, col('$') - 1)
|
283
|
+
return -1
|
284
|
+
endif
|
285
|
+
endif
|
286
|
+
|
287
|
+
let prevprevlinenum = s:GetPrevNormalLine(prevlinenum)
|
288
|
+
|
289
|
+
" If the continuation is the first in the file, don't run the other checks.
|
290
|
+
if !prevprevlinenum
|
291
|
+
return previndent + &shiftwidth
|
292
|
+
endif
|
293
|
+
|
294
|
+
let prevprevline = s:GetTrimmedLine(prevprevlinenum)
|
295
|
+
|
296
|
+
if prevprevline !~ s:CONTINUATION && prevprevline !~ s:CONTINUATION_BLOCK
|
297
|
+
return previndent + &shiftwidth
|
298
|
+
endif
|
299
|
+
|
300
|
+
return -1
|
301
|
+
endif
|
302
|
+
|
303
|
+
" Indent after these keywords and compound assignments if they aren't a
|
304
|
+
" single-line statement.
|
305
|
+
if prevline =~ s:INDENT_AFTER_KEYWORD || prevline =~ s:COMPOUND_ASSIGNMENT
|
306
|
+
if !s:SmartSearch(prevlinenum, '\<then\>') && prevline !~ s:SINGLE_LINE_ELSE
|
307
|
+
return previndent + &shiftwidth
|
308
|
+
endif
|
309
|
+
|
310
|
+
return -1
|
311
|
+
endif
|
312
|
+
|
313
|
+
" Indent a dot access if it's the first.
|
314
|
+
if curline =~ s:DOT_ACCESS && prevline !~ s:DOT_ACCESS
|
315
|
+
return previndent + &shiftwidth
|
316
|
+
endif
|
317
|
+
|
318
|
+
" Outdent after these keywords if they don't have a postfix condition or are
|
319
|
+
" a single-line statement.
|
320
|
+
if prevline =~ s:OUTDENT_AFTER
|
321
|
+
if !s:SmartSearch(prevlinenum, s:POSTFIX_CONDITION) ||
|
322
|
+
\ s:SmartSearch(prevlinenum, '\<then\>')
|
323
|
+
return previndent - &shiftwidth
|
324
|
+
endif
|
325
|
+
endif
|
326
|
+
|
327
|
+
" No indenting or outdenting is needed.
|
328
|
+
return -1
|
329
|
+
endfunction
|
330
|
+
|
331
|
+
" Wrap s:GetCoffeeIndent to keep the cursor position.
|
332
|
+
function! GetCoffeeIndent(curlinenum)
|
333
|
+
let oldcursor = getpos('.')
|
334
|
+
let indent = s:GetCoffeeIndent(a:curlinenum)
|
335
|
+
call setpos('.', oldcursor)
|
336
|
+
|
337
|
+
return indent
|
338
|
+
endfunction
|
@@ -0,0 +1,217 @@
|
|
1
|
+
" Language: CoffeeScript
|
2
|
+
" Maintainer: Mick Koch <kchmck@gmail.com>
|
3
|
+
" URL: http://github.com/kchmck/vim-coffee-script
|
4
|
+
" License: WTFPL
|
5
|
+
|
6
|
+
" Bail if our syntax is already loaded.
|
7
|
+
if exists('b:current_syntax') && b:current_syntax == 'coffee'
|
8
|
+
finish
|
9
|
+
endif
|
10
|
+
|
11
|
+
" Include JavaScript for coffeeEmbed.
|
12
|
+
syn include @coffeeJS syntax/javascript.vim
|
13
|
+
|
14
|
+
" Highlight long strings.
|
15
|
+
syn sync minlines=100
|
16
|
+
|
17
|
+
" CoffeeScript identifiers can have dollar signs.
|
18
|
+
setlocal isident+=$
|
19
|
+
|
20
|
+
" These are `matches` instead of `keywords` because vim's highlighting
|
21
|
+
" priority for keywords is higher than matches. This causes keywords to be
|
22
|
+
" highlighted inside matches, even if a match says it shouldn't contain them --
|
23
|
+
" like with coffeeAssign and coffeeDot.
|
24
|
+
syn match coffeeStatement /\<\%(return\|break\|continue\|throw\)\>/ display
|
25
|
+
hi def link coffeeStatement Statement
|
26
|
+
|
27
|
+
syn match coffeeRepeat /\<\%(for\|while\|until\|loop\)\>/ display
|
28
|
+
hi def link coffeeRepeat Repeat
|
29
|
+
|
30
|
+
syn match coffeeConditional /\<\%(if\|else\|unless\|switch\|when\|then\)\>/
|
31
|
+
\ display
|
32
|
+
hi def link coffeeConditional Conditional
|
33
|
+
|
34
|
+
syn match coffeeException /\<\%(try\|catch\|finally\)\>/ display
|
35
|
+
hi def link coffeeException Exception
|
36
|
+
|
37
|
+
syn match coffeeKeyword /\<\%(new\|in\|of\|by\|and\|or\|not\|is\|isnt\|class\|extends\|super\|do\)\>/
|
38
|
+
\ display
|
39
|
+
" The `own` keyword is only a keyword after `for`.
|
40
|
+
syn match coffeeKeyword /\<for\s\+own\>/ contained containedin=coffeeRepeat
|
41
|
+
\ display
|
42
|
+
hi def link coffeeKeyword Keyword
|
43
|
+
|
44
|
+
syn match coffeeOperator /\<\%(instanceof\|typeof\|delete\)\>/ display
|
45
|
+
hi def link coffeeOperator Operator
|
46
|
+
|
47
|
+
" The first case matches symbol operators only if they have an operand before.
|
48
|
+
syn match coffeeExtendedOp /\%(\S\s*\)\@<=[+\-*/%&|\^=!<>?.]\+\|[-=]>\|--\|++\|:/
|
49
|
+
\ display
|
50
|
+
syn match coffeeExtendedOp /\<\%(and\|or\)=/ display
|
51
|
+
hi def link coffeeExtendedOp coffeeOperator
|
52
|
+
|
53
|
+
" This is separate from `coffeeExtendedOp` to help differentiate commas from
|
54
|
+
" dots.
|
55
|
+
syn match coffeeSpecialOp /[,;]/ display
|
56
|
+
hi def link coffeeSpecialOp SpecialChar
|
57
|
+
|
58
|
+
syn match coffeeBoolean /\<\%(true\|on\|yes\|false\|off\|no\)\>/ display
|
59
|
+
hi def link coffeeBoolean Boolean
|
60
|
+
|
61
|
+
syn match coffeeGlobal /\<\%(null\|undefined\)\>/ display
|
62
|
+
hi def link coffeeGlobal Type
|
63
|
+
|
64
|
+
" A special variable
|
65
|
+
syn match coffeeSpecialVar /\<\%(this\|prototype\|arguments\)\>/ display
|
66
|
+
" An @-variable
|
67
|
+
syn match coffeeSpecialVar /@\%(\I\i*\)\?/ display
|
68
|
+
hi def link coffeeSpecialVar Special
|
69
|
+
|
70
|
+
" A class-like name that starts with a capital letter
|
71
|
+
syn match coffeeObject /\<\u\w*\>/ display
|
72
|
+
hi def link coffeeObject Structure
|
73
|
+
|
74
|
+
" A constant-like name in SCREAMING_CAPS
|
75
|
+
syn match coffeeConstant /\<\u[A-Z0-9_]\+\>/ display
|
76
|
+
hi def link coffeeConstant Constant
|
77
|
+
|
78
|
+
" A variable name
|
79
|
+
syn cluster coffeeIdentifier contains=coffeeSpecialVar,coffeeObject,
|
80
|
+
\ coffeeConstant
|
81
|
+
|
82
|
+
" A non-interpolated string
|
83
|
+
syn cluster coffeeBasicString contains=@Spell,coffeeEscape
|
84
|
+
" An interpolated string
|
85
|
+
syn cluster coffeeInterpString contains=@coffeeBasicString,coffeeInterp
|
86
|
+
|
87
|
+
" Regular strings
|
88
|
+
syn region coffeeString start=/"/ skip=/\\\\\|\\"/ end=/"/
|
89
|
+
\ contains=@coffeeInterpString
|
90
|
+
syn region coffeeString start=/'/ skip=/\\\\\|\\'/ end=/'/
|
91
|
+
\ contains=@coffeeBasicString
|
92
|
+
hi def link coffeeString String
|
93
|
+
|
94
|
+
" A integer, including a leading plus or minus
|
95
|
+
syn match coffeeNumber /\i\@<![-+]\?\d\+\%([eE][+-]\?\d\+\)\?/ display
|
96
|
+
" A hex number
|
97
|
+
syn match coffeeNumber /\<0[xX]\x\+\>/ display
|
98
|
+
syn match coffeeNumber /\<0b[01]\+\>/ display
|
99
|
+
hi def link coffeeNumber Number
|
100
|
+
|
101
|
+
" A floating-point number, including a leading plus or minus
|
102
|
+
syn match coffeeFloat /\i\@<![-+]\?\d*\.\@<!\.\d\+\%([eE][+-]\?\d\+\)\?/
|
103
|
+
\ display
|
104
|
+
hi def link coffeeFloat Float
|
105
|
+
|
106
|
+
" An error for reserved keywords
|
107
|
+
if !exists("coffee_no_reserved_words_error")
|
108
|
+
syn match coffeeReservedError /\<\%(case\|default\|function\|var\|void\|with\|const\|let\|enum\|export\|import\|native\|__hasProp\|__extends\|__slice\|__bind\|__indexOf\)\>/
|
109
|
+
\ display
|
110
|
+
hi def link coffeeReservedError Error
|
111
|
+
endif
|
112
|
+
|
113
|
+
" A normal object assignment
|
114
|
+
syn match coffeeObjAssign /@\?\I\i*\s*\ze::\@!/ contains=@coffeeIdentifier display
|
115
|
+
hi def link coffeeObjAssign Identifier
|
116
|
+
|
117
|
+
syn keyword coffeeTodo TODO FIXME XXX contained
|
118
|
+
hi def link coffeeTodo Todo
|
119
|
+
|
120
|
+
syn match coffeeComment /#.*/ contains=@Spell,coffeeTodo
|
121
|
+
hi def link coffeeComment Comment
|
122
|
+
|
123
|
+
syn region coffeeBlockComment start=/####\@!/ end=/###/
|
124
|
+
\ contains=@Spell,coffeeTodo
|
125
|
+
hi def link coffeeBlockComment coffeeComment
|
126
|
+
|
127
|
+
" A comment in a heregex
|
128
|
+
syn region coffeeHeregexComment start=/#/ end=/\ze\/\/\/\|$/ contained
|
129
|
+
\ contains=@Spell,coffeeTodo
|
130
|
+
hi def link coffeeHeregexComment coffeeComment
|
131
|
+
|
132
|
+
" Embedded JavaScript
|
133
|
+
syn region coffeeEmbed matchgroup=coffeeEmbedDelim
|
134
|
+
\ start=/`/ skip=/\\\\\|\\`/ end=/`/
|
135
|
+
\ contains=@coffeeJS
|
136
|
+
hi def link coffeeEmbedDelim Delimiter
|
137
|
+
|
138
|
+
syn region coffeeInterp matchgroup=coffeeInterpDelim start=/#{/ end=/}/ contained
|
139
|
+
\ contains=@coffeeAll
|
140
|
+
hi def link coffeeInterpDelim PreProc
|
141
|
+
|
142
|
+
" A string escape sequence
|
143
|
+
syn match coffeeEscape /\\\d\d\d\|\\x\x\{2\}\|\\u\x\{4\}\|\\./ contained display
|
144
|
+
hi def link coffeeEscape SpecialChar
|
145
|
+
|
146
|
+
" A regex -- must not follow a parenthesis, number, or identifier, and must not
|
147
|
+
" be followed by a number
|
148
|
+
syn region coffeeRegex start=/\%(\%()\|\i\@<!\d\)\s*\|\i\)\@<!\/=\@!\s\@!/
|
149
|
+
\ skip=/\[[^\]]\{-}\/[^\]]\{-}\]/
|
150
|
+
\ end=/\/[gimy]\{,4}\d\@!/
|
151
|
+
\ oneline contains=@coffeeBasicString
|
152
|
+
hi def link coffeeRegex String
|
153
|
+
|
154
|
+
" A heregex
|
155
|
+
syn region coffeeHeregex start=/\/\/\// end=/\/\/\/[gimy]\{,4}/
|
156
|
+
\ contains=@coffeeInterpString,coffeeHeregexComment
|
157
|
+
\ fold
|
158
|
+
hi def link coffeeHeregex coffeeRegex
|
159
|
+
|
160
|
+
" Heredoc strings
|
161
|
+
syn region coffeeHeredoc start=/"""/ end=/"""/ contains=@coffeeInterpString
|
162
|
+
\ fold
|
163
|
+
syn region coffeeHeredoc start=/'''/ end=/'''/ contains=@coffeeBasicString
|
164
|
+
\ fold
|
165
|
+
hi def link coffeeHeredoc String
|
166
|
+
|
167
|
+
" An error for trailing whitespace, as long as the line isn't just whitespace
|
168
|
+
if !exists("coffee_no_trailing_space_error")
|
169
|
+
syn match coffeeSpaceError /\S\@<=\s\+$/ display
|
170
|
+
hi def link coffeeSpaceError Error
|
171
|
+
endif
|
172
|
+
|
173
|
+
" An error for trailing semicolons, for help transitioning from JavaScript
|
174
|
+
if !exists("coffee_no_trailing_semicolon_error")
|
175
|
+
syn match coffeeSemicolonError /;$/ display
|
176
|
+
hi def link coffeeSemicolonError Error
|
177
|
+
endif
|
178
|
+
|
179
|
+
" Ignore reserved words in dot accesses.
|
180
|
+
syn match coffeeDotAccess /\.\@<!\.\s*\I\i*/he=s+1 contains=@coffeeIdentifier
|
181
|
+
hi def link coffeeDotAccess coffeeExtendedOp
|
182
|
+
|
183
|
+
" Ignore reserved words in prototype accesses.
|
184
|
+
syn match coffeeProtoAccess /::\s*\I\i*/he=s+2 contains=@coffeeIdentifier
|
185
|
+
hi def link coffeeProtoAccess coffeeExtendedOp
|
186
|
+
|
187
|
+
" This is required for interpolations to work.
|
188
|
+
syn region coffeeCurlies matchgroup=coffeeCurly start=/{/ end=/}/
|
189
|
+
\ contains=@coffeeAll
|
190
|
+
syn region coffeeBrackets matchgroup=coffeeBracket start=/\[/ end=/\]/
|
191
|
+
\ contains=@coffeeAll
|
192
|
+
syn region coffeeParens matchgroup=coffeeParen start=/(/ end=/)/
|
193
|
+
\ contains=@coffeeAll
|
194
|
+
|
195
|
+
" These are highlighted the same as commas since they tend to go together.
|
196
|
+
hi def link coffeeBlock coffeeSpecialOp
|
197
|
+
hi def link coffeeBracket coffeeBlock
|
198
|
+
hi def link coffeeCurly coffeeBlock
|
199
|
+
hi def link coffeeParen coffeeBlock
|
200
|
+
|
201
|
+
" This is used instead of TOP to keep things coffee-specific for good
|
202
|
+
" embedding. `contained` groups aren't included.
|
203
|
+
syn cluster coffeeAll contains=coffeeStatement,coffeeRepeat,coffeeConditional,
|
204
|
+
\ coffeeException,coffeeKeyword,coffeeOperator,
|
205
|
+
\ coffeeExtendedOp,coffeeSpecialOp,coffeeBoolean,
|
206
|
+
\ coffeeGlobal,coffeeSpecialVar,coffeeObject,
|
207
|
+
\ coffeeConstant,coffeeString,coffeeNumber,
|
208
|
+
\ coffeeFloat,coffeeReservedError,coffeeObjAssign,
|
209
|
+
\ coffeeComment,coffeeBlockComment,coffeeEmbed,
|
210
|
+
\ coffeeRegex,coffeeHeregex,coffeeHeredoc,
|
211
|
+
\ coffeeSpaceError,coffeeSemicolonError,
|
212
|
+
\ coffeeDotAccess,coffeeProtoAccess,
|
213
|
+
\ coffeeCurlies,coffeeBrackets,coffeeParens
|
214
|
+
|
215
|
+
if !exists('b:current_syntax')
|
216
|
+
let b:current_syntax = 'coffee'
|
217
|
+
endif
|
@@ -0,0 +1,62 @@
|
|
1
|
+
" Vim syntax file
|
2
|
+
" Language: eco
|
3
|
+
" Maintainer: Jay Adkisson
|
4
|
+
" Mostly stolen from eruby.vim
|
5
|
+
|
6
|
+
if !exists("g:eco_default_subtype")
|
7
|
+
let g:eco_default_subtype = "html"
|
8
|
+
endif
|
9
|
+
|
10
|
+
if !exists("b:eco_subtype")
|
11
|
+
let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$")
|
12
|
+
let b:eco_subtype = matchstr(s:lines,'eco_subtype=\zs\w\+')
|
13
|
+
if b:eco_subtype == ''
|
14
|
+
let b:eco_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.eco\)\+$','',''),'\.\zs\w\+$')
|
15
|
+
endif
|
16
|
+
if b:eco_subtype == 'rhtml'
|
17
|
+
let b:eco_subtype = 'html'
|
18
|
+
elseif b:eco_subtype == 'jst'
|
19
|
+
let b:eco_subtype = 'html'
|
20
|
+
elseif b:eco_subtype == 'rb'
|
21
|
+
let b:eco_subtype = 'ruby'
|
22
|
+
elseif b:eco_subtype == 'yml'
|
23
|
+
let b:eco_subtype = 'yaml'
|
24
|
+
elseif b:eco_subtype == 'js' || b:eco_subtype == 'json'
|
25
|
+
let b:eco_subtype = 'javascript'
|
26
|
+
elseif b:eco_subtype == 'txt'
|
27
|
+
" Conventional; not a real file type
|
28
|
+
let b:eco_subtype = 'text'
|
29
|
+
elseif b:eco_subtype == ''
|
30
|
+
if exists('b:current_syntax') && b:current_syntax != ''
|
31
|
+
let b:eco_subtype = b:current_syntax
|
32
|
+
else
|
33
|
+
let b:eco_subtype = g:eco_default_subtype
|
34
|
+
endif
|
35
|
+
endif
|
36
|
+
endif
|
37
|
+
|
38
|
+
if exists("b:eco_subtype") && b:eco_subtype != '' && b:eco_subtype != 'eco'
|
39
|
+
exec "runtime! syntax/".b:eco_subtype.".vim"
|
40
|
+
syn include @coffeeTop syntax/coffee.vim
|
41
|
+
endif
|
42
|
+
|
43
|
+
syn cluster ecoRegions contains=ecoBlock,ecoExpression,ecoComment
|
44
|
+
|
45
|
+
syn region ecoBlock matchgroup=ecoDelimiter start=/<%/ end=/%>/ contains=@coffeeTop containedin=ALLBUT,@ecoRegions keepend
|
46
|
+
syn region ecoExpression matchgroup=ecoDelimiter start=/<%[=\-]/ end=/%>/ contains=@coffeeTop containedin=ALLBUT,@ecoRegions keepend
|
47
|
+
syn region ecoComment matchgroup=ecoComment start=/<%#/ end=/%>/ contains=@coffeeTodo,@Spell containedin=ALLBUT,@ecoRegions keepend
|
48
|
+
|
49
|
+
" eco features not in coffeescript proper
|
50
|
+
syn keyword ecoEnd end containedin=@ecoRegions
|
51
|
+
syn match ecoIndentColon /\s+\w+:/ containedin=@ecoRegions
|
52
|
+
|
53
|
+
" Define the default highlighting.
|
54
|
+
|
55
|
+
hi def link ecoDelimiter Delimiter
|
56
|
+
hi def link ecoComment Comment
|
57
|
+
hi def link ecoEnd coffeeConditional
|
58
|
+
hi def link ecoIndentColon None
|
59
|
+
|
60
|
+
let b:current_syntax = 'eco'
|
61
|
+
|
62
|
+
" vim: nowrap sw=2 sts=2 ts=8:
|
data/lib/utils/config/vimrc
CHANGED
data/lib/utils/version.rb
CHANGED
data/utils.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "utils"
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.54"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Florian Frank"]
|
9
|
-
s.date = "2012-
|
9
|
+
s.date = "2012-09-05"
|
10
10
|
s.description = "This ruby gem provides some useful command line utilities"
|
11
11
|
s.email = "flori@ping.de"
|
12
|
-
s.executables = ["chroot-exec", "chroot-libs", "classify", "discover", "edit", "edit_wait", "enum", "errf", "git-empty", "myex", "number_files", "path", "probe", "same_files", "search", "sedit", "sshscreen", "strip_spaces", "unquarantine_apps", "untest", "utils-install-config", "utils-utilsrc", "vacuum_firefox_sqlite", "xmp"]
|
12
|
+
s.executables = ["chroot-exec", "chroot-libs", "classify", "create_tags", "discover", "edit", "edit_wait", "enum", "errf", "git-empty", "myex", "number_files", "path", "probe", "same_files", "search", "sedit", "sshscreen", "strip_spaces", "unquarantine_apps", "untest", "utils-install-config", "utils-utilsrc", "vacuum_firefox_sqlite", "xmp"]
|
13
13
|
s.extra_rdoc_files = ["README.rdoc", "lib/utils/config/config_file.rb", "lib/utils/config.rb", "lib/utils/editor.rb", "lib/utils/file_xt.rb", "lib/utils/finder.rb", "lib/utils/grepper.rb", "lib/utils/irb.rb", "lib/utils/md5.rb", "lib/utils/patterns.rb", "lib/utils/version.rb", "lib/utils.rb"]
|
14
|
-
s.files = [".gitignore", "COPYING", "Gemfile", "README.rdoc", "Rakefile", "TODO", "VERSION", "bin/chroot-exec", "bin/chroot-libs", "bin/classify", "bin/discover", "bin/edit", "bin/edit_wait", "bin/enum", "bin/errf", "bin/git-empty", "bin/myex", "bin/number_files", "bin/path", "bin/probe", "bin/same_files", "bin/search", "bin/sedit", "bin/sshscreen", "bin/strip_spaces", "bin/unquarantine_apps", "bin/untest", "bin/utils-install-config", "bin/utils-utilsrc", "bin/vacuum_firefox_sqlite", "bin/xmp", "lib/utils.rb", "lib/utils/config.rb", "lib/utils/config/config_file.rb", "lib/utils/config/gdb/asm", "lib/utils/config/gdb/ruby", "lib/utils/config/gdbinit", "lib/utils/config/irbrc", "lib/utils/config/rdebugrc", "lib/utils/config/rvmrc", "lib/utils/config/screenrc", "lib/utils/config/utilsrc", "lib/utils/config/vim/autoload/Align.vim", "lib/utils/config/vim/autoload/AlignMaps.vim", "lib/utils/config/vim/autoload/rails.vim", "lib/utils/config/vim/autoload/rubycomplete.vim", "lib/utils/config/vim/autoload/sqlcomplete.vim", "lib/utils/config/vim/autoload/vimball.vim", "lib/utils/config/vim/colors/flori.vim", "lib/utils/config/vim/compiler/eruby.vim", "lib/utils/config/vim/compiler/ruby.vim", "lib/utils/config/vim/compiler/rubyunit.vim", "lib/utils/config/vim/ftdetect/ragel.vim", "lib/utils/config/vim/ftdetect/ruby.vim", "lib/utils/config/vim/ftdetect/slim.vim", "lib/utils/config/vim/ftplugin/eruby.vim", "lib/utils/config/vim/ftplugin/ruby.vim", "lib/utils/config/vim/ftplugin/xml.vim", "lib/utils/config/vim/indent/IndentAnything_html.vim", "lib/utils/config/vim/indent/eruby.vim", "lib/utils/config/vim/indent/javascript.vim", "lib/utils/config/vim/indent/ruby.vim", "lib/utils/config/vim/indent/slim.vim", "lib/utils/config/vim/plugin/AlignMapsPlugin.vim", "lib/utils/config/vim/plugin/AlignPlugin.vim", "lib/utils/config/vim/plugin/Decho.vim", "lib/utils/config/vim/plugin/IndentAnything.vim", "lib/utils/config/vim/plugin/bufexplorer.vim", "lib/utils/config/vim/plugin/cecutil.vim", "lib/utils/config/vim/plugin/fugitive.vim", "lib/utils/config/vim/plugin/lusty-explorer.vim", "lib/utils/config/vim/plugin/rails.vim", "lib/utils/config/vim/plugin/rubyextra.vim", "lib/utils/config/vim/plugin/surround.vim", "lib/utils/config/vim/plugin/taglist.vim", "lib/utils/config/vim/plugin/test/IndentAnything/test.js", "lib/utils/config/vim/plugin/vimballPlugin.vim", "lib/utils/config/vim/syntax/Decho.vim", "lib/utils/config/vim/syntax/eruby.vim", "lib/utils/config/vim/syntax/javascript.vim", "lib/utils/config/vim/syntax/ragel.vim", "lib/utils/config/vim/syntax/ruby.vim", "lib/utils/config/vim/syntax/slim.vim", "lib/utils/config/vimrc", "lib/utils/editor.rb", "lib/utils/file_xt.rb", "lib/utils/finder.rb", "lib/utils/grepper.rb", "lib/utils/irb.rb", "lib/utils/md5.rb", "lib/utils/patterns.rb", "lib/utils/version.rb", "utils.gemspec"]
|
14
|
+
s.files = [".gitignore", "COPYING", "Gemfile", "README.rdoc", "Rakefile", "TODO", "VERSION", "bin/chroot-exec", "bin/chroot-libs", "bin/classify", "bin/create_tags", "bin/discover", "bin/edit", "bin/edit_wait", "bin/enum", "bin/errf", "bin/git-empty", "bin/myex", "bin/number_files", "bin/path", "bin/probe", "bin/same_files", "bin/search", "bin/sedit", "bin/sshscreen", "bin/strip_spaces", "bin/unquarantine_apps", "bin/untest", "bin/utils-install-config", "bin/utils-utilsrc", "bin/vacuum_firefox_sqlite", "bin/xmp", "lib/utils.rb", "lib/utils/config.rb", "lib/utils/config/config_file.rb", "lib/utils/config/gdb/asm", "lib/utils/config/gdb/ruby", "lib/utils/config/gdbinit", "lib/utils/config/irbrc", "lib/utils/config/rdebugrc", "lib/utils/config/rvmrc", "lib/utils/config/screenrc", "lib/utils/config/utilsrc", "lib/utils/config/vim/after/syntax/haml.vim", "lib/utils/config/vim/after/syntax/html.vim", "lib/utils/config/vim/autoload/Align.vim", "lib/utils/config/vim/autoload/AlignMaps.vim", "lib/utils/config/vim/autoload/rails.vim", "lib/utils/config/vim/autoload/rubycomplete.vim", "lib/utils/config/vim/autoload/sqlcomplete.vim", "lib/utils/config/vim/autoload/vimball.vim", "lib/utils/config/vim/colors/flori.vim", "lib/utils/config/vim/compiler/coffee.vim", "lib/utils/config/vim/compiler/eruby.vim", "lib/utils/config/vim/compiler/ruby.vim", "lib/utils/config/vim/compiler/rubyunit.vim", "lib/utils/config/vim/doc/coffee-script.txt", "lib/utils/config/vim/ftdetect/coffee.vim", "lib/utils/config/vim/ftdetect/eco.vim", "lib/utils/config/vim/ftdetect/ragel.vim", "lib/utils/config/vim/ftdetect/ruby.vim", "lib/utils/config/vim/ftdetect/slim.vim", "lib/utils/config/vim/ftplugin/coffee.vim", "lib/utils/config/vim/ftplugin/eruby.vim", "lib/utils/config/vim/ftplugin/ruby.vim", "lib/utils/config/vim/ftplugin/xml.vim", "lib/utils/config/vim/indent/IndentAnything_html.vim", "lib/utils/config/vim/indent/coffee.vim", "lib/utils/config/vim/indent/eruby.vim", "lib/utils/config/vim/indent/javascript.vim", "lib/utils/config/vim/indent/ruby.vim", "lib/utils/config/vim/indent/slim.vim", "lib/utils/config/vim/plugin/AlignMapsPlugin.vim", "lib/utils/config/vim/plugin/AlignPlugin.vim", "lib/utils/config/vim/plugin/Decho.vim", "lib/utils/config/vim/plugin/IndentAnything.vim", "lib/utils/config/vim/plugin/bufexplorer.vim", "lib/utils/config/vim/plugin/cecutil.vim", "lib/utils/config/vim/plugin/fugitive.vim", "lib/utils/config/vim/plugin/lusty-explorer.vim", "lib/utils/config/vim/plugin/rails.vim", "lib/utils/config/vim/plugin/rubyextra.vim", "lib/utils/config/vim/plugin/surround.vim", "lib/utils/config/vim/plugin/taglist.vim", "lib/utils/config/vim/plugin/test/IndentAnything/test.js", "lib/utils/config/vim/plugin/vimballPlugin.vim", "lib/utils/config/vim/syntax/Decho.vim", "lib/utils/config/vim/syntax/coffee.vim", "lib/utils/config/vim/syntax/eco.vim", "lib/utils/config/vim/syntax/eruby.vim", "lib/utils/config/vim/syntax/javascript.vim", "lib/utils/config/vim/syntax/ragel.vim", "lib/utils/config/vim/syntax/ruby.vim", "lib/utils/config/vim/syntax/slim.vim", "lib/utils/config/vimrc", "lib/utils/editor.rb", "lib/utils/file_xt.rb", "lib/utils/finder.rb", "lib/utils/grepper.rb", "lib/utils/irb.rb", "lib/utils/md5.rb", "lib/utils/patterns.rb", "lib/utils/version.rb", "utils.gemspec"]
|
15
15
|
s.homepage = "http://github.com/flori/utils"
|
16
16
|
s.rdoc_options = ["--title", "Utils - Some useful command line utilities", "--main", "README.rdoc"]
|
17
17
|
s.require_paths = ["lib"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.54
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gem_hadar
|
@@ -97,6 +97,7 @@ executables:
|
|
97
97
|
- chroot-exec
|
98
98
|
- chroot-libs
|
99
99
|
- classify
|
100
|
+
- create_tags
|
100
101
|
- discover
|
101
102
|
- edit
|
102
103
|
- edit_wait
|
@@ -143,6 +144,7 @@ files:
|
|
143
144
|
- bin/chroot-exec
|
144
145
|
- bin/chroot-libs
|
145
146
|
- bin/classify
|
147
|
+
- bin/create_tags
|
146
148
|
- bin/discover
|
147
149
|
- bin/edit
|
148
150
|
- bin/edit_wait
|
@@ -175,6 +177,8 @@ files:
|
|
175
177
|
- lib/utils/config/rvmrc
|
176
178
|
- lib/utils/config/screenrc
|
177
179
|
- lib/utils/config/utilsrc
|
180
|
+
- lib/utils/config/vim/after/syntax/haml.vim
|
181
|
+
- lib/utils/config/vim/after/syntax/html.vim
|
178
182
|
- lib/utils/config/vim/autoload/Align.vim
|
179
183
|
- lib/utils/config/vim/autoload/AlignMaps.vim
|
180
184
|
- lib/utils/config/vim/autoload/rails.vim
|
@@ -182,16 +186,22 @@ files:
|
|
182
186
|
- lib/utils/config/vim/autoload/sqlcomplete.vim
|
183
187
|
- lib/utils/config/vim/autoload/vimball.vim
|
184
188
|
- lib/utils/config/vim/colors/flori.vim
|
189
|
+
- lib/utils/config/vim/compiler/coffee.vim
|
185
190
|
- lib/utils/config/vim/compiler/eruby.vim
|
186
191
|
- lib/utils/config/vim/compiler/ruby.vim
|
187
192
|
- lib/utils/config/vim/compiler/rubyunit.vim
|
193
|
+
- lib/utils/config/vim/doc/coffee-script.txt
|
194
|
+
- lib/utils/config/vim/ftdetect/coffee.vim
|
195
|
+
- lib/utils/config/vim/ftdetect/eco.vim
|
188
196
|
- lib/utils/config/vim/ftdetect/ragel.vim
|
189
197
|
- lib/utils/config/vim/ftdetect/ruby.vim
|
190
198
|
- lib/utils/config/vim/ftdetect/slim.vim
|
199
|
+
- lib/utils/config/vim/ftplugin/coffee.vim
|
191
200
|
- lib/utils/config/vim/ftplugin/eruby.vim
|
192
201
|
- lib/utils/config/vim/ftplugin/ruby.vim
|
193
202
|
- lib/utils/config/vim/ftplugin/xml.vim
|
194
203
|
- lib/utils/config/vim/indent/IndentAnything_html.vim
|
204
|
+
- lib/utils/config/vim/indent/coffee.vim
|
195
205
|
- lib/utils/config/vim/indent/eruby.vim
|
196
206
|
- lib/utils/config/vim/indent/javascript.vim
|
197
207
|
- lib/utils/config/vim/indent/ruby.vim
|
@@ -211,6 +221,8 @@ files:
|
|
211
221
|
- lib/utils/config/vim/plugin/test/IndentAnything/test.js
|
212
222
|
- lib/utils/config/vim/plugin/vimballPlugin.vim
|
213
223
|
- lib/utils/config/vim/syntax/Decho.vim
|
224
|
+
- lib/utils/config/vim/syntax/coffee.vim
|
225
|
+
- lib/utils/config/vim/syntax/eco.vim
|
214
226
|
- lib/utils/config/vim/syntax/eruby.vim
|
215
227
|
- lib/utils/config/vim/syntax/javascript.vim
|
216
228
|
- lib/utils/config/vim/syntax/ragel.vim
|
@@ -244,7 +256,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
244
256
|
version: '0'
|
245
257
|
segments:
|
246
258
|
- 0
|
247
|
-
hash:
|
259
|
+
hash: 2048215407046048042
|
248
260
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
249
261
|
none: false
|
250
262
|
requirements:
|