Skip to content

HTTPS clone URL

Subversion checkout URL

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