Skip to content
Newer
Older
100644 266 lines (150 sloc) 7.41 KB
feab54e @kchmck Readme
authored May 23, 2011
1 This project adds [CoffeeScript] support to the vim editor. It handles syntax,
421f3fc @kchmck Readme
authored Aug 10, 2011
2 indenting, and compiling. Also included is an [eco] syntax and support for
4824ea3 @kchmck Update dox
authored Oct 16, 2011
3 CoffeeScript in Haml and HTML.
1234183 @kchmck Initial commit
authored Jan 20, 2010
4
421f3fc @kchmck Readme
authored Aug 11, 2011
5 ![Screenshot](http://i.imgur.com/BV29H.png)
31a19f4 @kchmck Add screenshots section to readme
authored Jan 20, 2010
6
421f3fc @kchmck Readme
authored Aug 11, 2011
7 [CoffeeScript]: http://jashkenas.github.com/coffee-script/
8 [eco]: https://github.com/sstephenson/eco
e423493 @kchmck Add indenting section
authored Mar 28, 2010
9
0d191d7 @kchmck Docs
authored Oct 20, 2011
10 ### Install from a Zipball
3ecf1f0 @kchmck Add installation instructions to readme
authored Jan 20, 2010
11
421f3fc @kchmck Readme
authored Aug 11, 2011
12 This is the quickest way to get things running.
2929a2f @kchmck Readme
authored Jul 21, 2011
13
384792e @kchmck Readme
authored Aug 21, 2011
14 1. Download the latest zipball from [vim.org][zipball-vim] or
35b2f3e @kchmck Clarify github downloads a little (#48)
authored Oct 18, 2011
15 [github][zipball-github]. The latest version on github is under Download
16 Packages (don't use the Download buttons.)
2929a2f @kchmck Readme
authored Jul 21, 2011
17
18 2. Extract the archive into `~/.vim/`:
19
20 unzip -od ~/.vim vim-coffee-script-HASH.zip
21
22 These steps are also used to update the plugin.
23
384792e @kchmck Readme
authored Aug 21, 2011
24 [zipball-vim]: http://www.vim.org/scripts/script.php?script_id=3590
4824ea3 @kchmck Update dox
authored Oct 17, 2011
25 [zipball-github]: https://github.com/kchmck/vim-coffee-script/downloads
2929a2f @kchmck Readme
authored Jul 21, 2011
26
0d191d7 @kchmck Docs
authored Oct 20, 2011
27 ### Install with Pathogen
2929a2f @kchmck Readme
authored Jul 21, 2011
28
6277c81 @kchmck Readme
authored Aug 17, 2011
29 Since this plugin has rolling versions based on git commits, using pathogen and
d821074 @kchmck Readme
authored Aug 12, 2011
30 git is the preferred way to install. The plugin ends up contained in its own
4824ea3 @kchmck Update dox
authored Oct 17, 2011
31 directory and updates are just a `git pull` away.
2929a2f @kchmck Readme
authored Jul 21, 2011
32
33 1. Install tpope's [pathogen] into `~/.vim/autoload/` and add this line to your
34 `vimrc`:
07cfcd9 @kchmck Update the installing section
authored May 26, 2010
35
04f5367 @kchmck Readme
authored Aug 12, 2011
36 call pathogen#infect()
07cfcd9 @kchmck Update the installing section
authored May 26, 2010
37
04f5367 @kchmck Readme
authored Aug 12, 2011
38 To get the all the features of this plugin, make sure you also have a
4824ea3 @kchmck Update dox
authored Oct 17, 2011
39 `filetype plugin indent on` line in there.
07cfcd9 @kchmck Update the installing section
authored May 26, 2010
40
c2898f2 @kchmck Add www to pathogen link (issue #6)
authored Nov 10, 2010
41 [pathogen]: http://www.vim.org/scripts/script.php?script_id=2332
07cfcd9 @kchmck Update the installing section
authored May 26, 2010
42
384792e @kchmck Readme
authored Aug 21, 2011
43 2. Create and change into `~/.vim/bundle/`:
07cfcd9 @kchmck Update the installing section
authored May 26, 2010
44
421f3fc @kchmck Readme
authored Aug 11, 2011
45 $ mkdir ~/.vim/bundle
07cfcd9 @kchmck Update the installing section
authored May 26, 2010
46 $ cd ~/.vim/bundle
47
48 3. Make a clone of the `vim-coffee-script` repository:
49
2929a2f @kchmck Readme
authored Jul 21, 2011
50 $ git clone https://github.com/kchmck/vim-coffee-script.git
07cfcd9 @kchmck Update the installing section
authored May 26, 2010
51
2929a2f @kchmck Readme
authored Jul 21, 2011
52 #### Updating
07cfcd9 @kchmck Update the installing section
authored May 26, 2010
53
384792e @kchmck Readme
authored Aug 21, 2011
54 1. Change into `~/.vim/bundle/vim-coffee-script/`:
07cfcd9 @kchmck Update the installing section
authored May 26, 2010
55
56 $ cd ~/.vim/bundle/vim-coffee-script
57
58 2. Pull in the latest changes:
59
60 $ git pull
61
d821074 @kchmck Readme
authored Aug 12, 2011
62 ### CoffeeMake: Compile the Current File
c92f18e @kchmck Add the CoffeeMake command
authored May 3, 2011
63
421f3fc @kchmck Readme
authored Aug 11, 2011
64 The `CoffeeMake` command compiles the current file and parses any errors:
c92f18e @kchmck Add the CoffeeMake command
authored May 3, 2011
65
5de030e @kchmck Update screenshots
authored Aug 5, 2011
66 ![CoffeeMake](http://i.imgur.com/OKRKE.png)
c92f18e @kchmck Add the CoffeeMake command
authored May 3, 2011
67
5de030e @kchmck Update screenshots
authored Aug 5, 2011
68 ![CoffeeMake](http://i.imgur.com/PQ6ed.png)
c92f18e @kchmck Add the CoffeeMake command
authored May 3, 2011
69
5de030e @kchmck Update screenshots
authored Aug 5, 2011
70 ![CoffeeMake](http://i.imgur.com/Jp6NI.png)
c92f18e @kchmck Add the CoffeeMake command
authored May 3, 2011
71
421f3fc @kchmck Readme
authored Aug 11, 2011
72 The full signature of the command is:
73
d821074 @kchmck Readme
authored Aug 12, 2011
74 :[silent] CoffeeMake[!] [COFFEE-OPTIONS]...
421f3fc @kchmck Readme
authored Aug 11, 2011
75
c92f18e @kchmck Add the CoffeeMake command
authored May 3, 2011
76 By default, `CoffeeMake` shows all compiler output and jumps to the first line
77 reported as an error by `coffee`:
78
79 :CoffeeMake
80
81 Compiler output can be hidden with `silent`:
82
83 :silent CoffeeMake
84
85 Line-jumping can be turned off by adding a bang:
86
87 :CoffeeMake!
88
89 Options given to `CoffeeMake` are passed along to `coffee`:
90
91 :CoffeeMake --bare
92
4824ea3 @kchmck Update dox
authored Oct 17, 2011
93 `CoffeeMake` can be manually loaded for a file with:
94
95 :compiler coffee
96
d821074 @kchmck Readme
authored Aug 12, 2011
97 #### Recompile on write
c92f18e @kchmck Add the CoffeeMake command
authored May 3, 2011
98
682c2fa @kchmck Yeh, contraction
authored Oct 18, 2011
99 To recompile a file when it's written, add an `autocmd` like this to your
421f3fc @kchmck Readme
authored Aug 11, 2011
100 `vimrc`:
c92f18e @kchmck Add the CoffeeMake command
authored May 3, 2011
101
421f3fc @kchmck Readme
authored Aug 11, 2011
102 au BufWritePost *.coffee silent CoffeeMake!
c92f18e @kchmck Add the CoffeeMake command
authored May 3, 2011
103
104 All of the customizations above can be used, too. This one compiles silently
1b6f1f0 @kchmck Fix awkward wording (#44)
authored Aug 5, 2011
105 and with the `-b` option, but shows any errors:
c92f18e @kchmck Add the CoffeeMake command
authored May 3, 2011
106
421f3fc @kchmck Readme
authored Aug 11, 2011
107 au BufWritePost *.coffee silent CoffeeMake! -b | cwindow | redraw!
dcffbb9 @kchmck Mention redraw quirk workaround
authored Jul 16, 2011
108
109 The `redraw!` command is needed to fix a redrawing quirk in terminal vim, but
110 can removed for gVim.
c92f18e @kchmck Add the CoffeeMake command
authored May 3, 2011
111
187e392 @kchmck More readme
authored Jul 7, 2011
112 #### Default compiler options
c92f18e @kchmck Add the CoffeeMake command
authored May 3, 2011
113
114 The `CoffeeMake` command passes any options in the `coffee_make_options`
384792e @kchmck Readme
authored Aug 21, 2011
115 variable along to the compiler. You can use this to set default options:
c92f18e @kchmck Add the CoffeeMake command
authored May 3, 2011
116
c218d63 @kchmck Use single quotes
authored Feb 14, 2012
117 let coffee_make_options = '--bare'
c92f18e @kchmck Add the CoffeeMake command
authored May 3, 2011
118
014fb6e @kchmck Add coffee_make_compiler to set a compiler path (#78)
authored Feb 14, 2012
119 #### Path to compiler
120
121 To change the compiler used by `CoffeeMake`, set `coffee_make_compiler` to the
122 full path of an executable or the filename of one in your `$PATH`:
123
c218d63 @kchmck Use single quotes
authored Feb 14, 2012
124 let coffee_make_compiler = '/usr/bin/coffee'
014fb6e @kchmck Add coffee_make_compiler to set a compiler path (#78)
authored Feb 14, 2012
125
d821074 @kchmck Readme
authored Aug 12, 2011
126 ### CoffeeCompile: Compile Snippets of CoffeeScript
0e8e63f @kchmck Add CoffeeCompile command
authored Mar 23, 2011
127
c92f18e @kchmck Add the CoffeeMake command
authored May 3, 2011
128 The `CoffeeCompile` command shows how the current file or a snippet of
899e8a8 @kchmck Add watch and vertical modes to CoffeeCompile (#39)
authored Aug 12, 2011
129 CoffeeScript is compiled to JavaScript. The full signature of the command is:
130
131 :[RANGE] CoffeeCompile [watch|unwatch] [vert[ical]] [WINDOW-SIZE]
132
133 Calling `CoffeeCompile` without a range compiles the whole file:
0e8e63f @kchmck Add CoffeeCompile command
authored Mar 23, 2011
134
5de030e @kchmck Update screenshots
authored Aug 5, 2011
135 ![CoffeeCompile](http://i.imgur.com/pTesp.png)
0e8e63f @kchmck Add CoffeeCompile command
authored Mar 23, 2011
136
5de030e @kchmck Update screenshots
authored Aug 5, 2011
137 ![Compiled](http://i.imgur.com/81QMf.png)
0e8e63f @kchmck Add CoffeeCompile command
authored Mar 23, 2011
138
139 Calling `CoffeeCompile` with a range, like in visual mode, compiles the selected
140 snippet of CoffeeScript:
141
5de030e @kchmck Update screenshots
authored Aug 5, 2011
142 ![CoffeeCompile Snippet](http://i.imgur.com/Rm7iu.png)
0e8e63f @kchmck Add CoffeeCompile command
authored Mar 23, 2011
143
5de030e @kchmck Update screenshots
authored Aug 5, 2011
144 ![Compiled Snippet](http://i.imgur.com/KmrG8.png)
0e8e63f @kchmck Add CoffeeCompile command
authored Mar 23, 2011
145
ae54812 @kchmck Retry syntax-highlighted CoffeeCompile
authored Jun 18, 2011
146 This scratch buffer can be quickly closed by hitting the `q` key.
0e8e63f @kchmck Add CoffeeCompile command
authored Mar 23, 2011
147
899e8a8 @kchmck Add watch and vertical modes to CoffeeCompile (#39)
authored Aug 12, 2011
148 Using `vert` splits the CoffeeCompile buffer vertically instead of horizontally:
149
150 :CoffeeCompile vert
151
8c9c204 @kchmck Update docks
authored Oct 18, 2011
152 Set the `coffee_compile_vert` variable to split the buffer vertically by
153 default:
154
155 let coffee_compile_vert = 1
156
899e8a8 @kchmck Add watch and vertical modes to CoffeeCompile (#39)
authored Aug 12, 2011
157 The initial size of the CoffeeCompile buffer can be given as a number:
158
159 :CoffeeCompile 4
160
6277c81 @kchmck Readme
authored Aug 17, 2011
161 #### Watch (live preview) mode
899e8a8 @kchmck Add watch and vertical modes to CoffeeCompile (#39)
authored Aug 12, 2011
162
903191e @kchmck Dox
authored Oct 18, 2011
163 Watch mode is like the Try CoffeeScript preview box on the CoffeeScript
c513e6e @kchmck Dox
authored Oct 16, 2011
164 homepage:
899e8a8 @kchmck Add watch and vertical modes to CoffeeCompile (#39)
authored Aug 12, 2011
165
166 ![Watch Mode](http://i.imgur.com/wIN6h.png)
167 ![Watch Mode](http://i.imgur.com/GgdCo.png)
168 ![Watch Mode](http://i.imgur.com/QdpAP.png)
169
c513e6e @kchmck Dox
authored Oct 17, 2011
170 Writing some code and then exiting insert mode automatically updates the
171 compiled JavaScript buffer.
4824ea3 @kchmck Update dox
authored Oct 17, 2011
172
899e8a8 @kchmck Add watch and vertical modes to CoffeeCompile (#39)
authored Aug 12, 2011
173 Use `watch` to start watching a buffer (`vert` is also recommended):
174
175 :CoffeeCompile watch vert
176
177 After making some changes in insert mode, hit escape and the CoffeeScript will
178 be recompiled. Changes made outside of insert mode don't trigger this recompile,
179 but calling `CoffeeCompile` will compile these changes without any bad effects.
180
181 To get synchronized scrolling of a CoffeeScript and CoffeeCompile buffer, set
182 `scrollbind` on each:
183
184 :setl scrollbind
185
186 Use `unwatch` to stop watching a buffer:
187
188 :CoffeeCompile unwatch
189
1cf15a3 @kchmck Add CoffeeLint command
authored Feb 14, 2012
190 ### CoffeeLint: Lint your CoffeeScript
191
192 The `CoffeeLint` command runs [coffeelint](http://www.coffeelint.org/) on the
193 current file and parses any errors:
194
195 :[RANGE] CoffeeLint[!] [COFFEELINT-OPTIONS]
196
197 Use it like `CoffeeMake`.
198
199 :CoffeeLint! | cwindow
200
201 #### Default coffeelint options
202
203 Options in `coffee_lint_options` are passed along to coffeelint.
204
205 let coffee_lint_options = '-f lint.json'
206
d821074 @kchmck Readme
authored Aug 12, 2011
207 ### CoffeeRun: Run some CoffeeScript
ead4012 @kchmck Document CoffeeRun in readme
authored Jun 13, 2011
208
209 The `CoffeeRun` command compiles the current file or selected snippet and runs
c4df62e @kchmck Readme
authored Jun 20, 2011
210 the resulting JavaScript. Output is shown at the bottom of the screen:
211
5de030e @kchmck Update screenshots
authored Aug 5, 2011
212 ![CoffeeRun](http://i.imgur.com/d4yXC.png)
c4df62e @kchmck Readme
authored Jun 20, 2011
213
5de030e @kchmck Update screenshots
authored Aug 5, 2011
214 ![CoffeeRun Output](http://i.imgur.com/m6UID.png)
ead4012 @kchmck Document CoffeeRun in readme
authored Jun 13, 2011
215
8c9c204 @kchmck Update docks
authored Oct 18, 2011
216 ### Configure Syntax Highlighting
1a2148e @kchmck Add syntax error customization (thanks patrkris)
authored Jul 2, 2010
217
8c9c204 @kchmck Update docks
authored Oct 18, 2011
218 Add these lines to your `vimrc` to disable the relevant syntax group.
1a2148e @kchmck Add syntax error customization (thanks patrkris)
authored Jul 2, 2010
219
3f6df51 @kchmck Clean up readme.md
authored Apr 19, 2011
220 #### Disable trailing whitespace error
1a2148e @kchmck Add syntax error customization (thanks patrkris)
authored Jul 2, 2010
221
3f6df51 @kchmck Clean up readme.md
authored Apr 19, 2011
222 Trailing whitespace is highlighted as an error by default. This can be disabled
223 with:
1a2148e @kchmck Add syntax error customization (thanks patrkris)
authored Jul 2, 2010
224
c455bf2 @kchmck Use vim commands instead of let statements
authored Aug 13, 2011
225 hi link coffeeSpaceError NONE
1a2148e @kchmck Add syntax error customization (thanks patrkris)
authored Jul 2, 2010
226
3f6df51 @kchmck Clean up readme.md
authored Apr 19, 2011
227 #### Disable trailing semicolon error
1a2148e @kchmck Add syntax error customization (thanks patrkris)
authored Jul 2, 2010
228
421f3fc @kchmck Readme
authored Aug 11, 2011
229 Trailing semicolons are also considered an error (for help transitioning from
230 JavaScript.) This can be disabled with:
1a2148e @kchmck Add syntax error customization (thanks patrkris)
authored Jul 2, 2010
231
c455bf2 @kchmck Use vim commands instead of let statements
authored Aug 13, 2011
232 hi link coffeeSemicolonError NONE
12f044a @kchmck Make the reserved words error configurable
authored Jul 12, 2010
233
3f6df51 @kchmck Clean up readme.md
authored Apr 19, 2011
234 #### Disable reserved words error
12f044a @kchmck Make the reserved words error configurable
authored Jul 13, 2010
235
384792e @kchmck Readme
authored Aug 21, 2011
236 Reserved words like `function` and `var` are highlighted as an error where
237 they're not allowed in CoffeeScript. This can be disabled with:
12f044a @kchmck Make the reserved words error configurable
authored Jul 13, 2010
238
c455bf2 @kchmck Use vim commands instead of let statements
authored Aug 13, 2011
239 hi link coffeeReservedError NONE
dff2a57 @kchmck Deprecate coffee_folding
authored Aug 5, 2011
240
8c9c204 @kchmck Update docks
authored Oct 18, 2011
241 ### Tune Vim for CoffeeScript
dff2a57 @kchmck Deprecate coffee_folding
authored Aug 5, 2011
242
421f3fc @kchmck Readme
authored Aug 11, 2011
243 Changing these core settings can make vim more CoffeeScript friendly.
dff2a57 @kchmck Deprecate coffee_folding
authored Aug 5, 2011
244
245 #### Fold by indentation
246
d821074 @kchmck Readme
authored Aug 12, 2011
247 Folding by indentation works well for CoffeeScript functions and classes:
dff2a57 @kchmck Deprecate coffee_folding
authored Aug 5, 2011
248
5de030e @kchmck Update screenshots
authored Aug 5, 2011
249 ![Folding](http://i.imgur.com/lpDWo.png)
dff2a57 @kchmck Deprecate coffee_folding
authored Aug 5, 2011
250
251 To fold by indentation in CoffeeScript files, add this line to your `vimrc`:
252
253 au BufNewFile,BufReadPost *.coffee setl foldmethod=indent nofoldenable
254
255 With this, folding is disabled by default but can be quickly toggled per-file
d821074 @kchmck Readme
authored Aug 12, 2011
256 by hitting `zi`. To enable folding by default, remove `nofoldenable`:
dff2a57 @kchmck Deprecate coffee_folding
authored Aug 5, 2011
257
258 au BufNewFile,BufReadPost *.coffee setl foldmethod=indent
3c6b338 @kchmck Mention two-space indents (#41)
authored Aug 5, 2011
259
260 #### Two-space indentation
261
262 To get standard two-space indentation in CoffeeScript files, add this line to
263 your `vimrc`:
264
265 au BufNewFile,BufReadPost *.coffee setl shiftwidth=2 expandtab
Something went wrong with that request. Please try again.