Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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