Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 200 lines (114 sloc) 5.871 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
dcad7e5 @kchmck Mention eco and text/coffeescript
authored
3 `text/coffeescript` in 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
421f3fc @kchmck Readme
authored
14 1. Download the latest zipball over at [vim.org page][zipball].
2929a2f @kchmck 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
26 Since this plugin uses "rolling releases" based on git commits, using pathogen
421f3fc @kchmck Readme
authored
27 and git is the preferred way to install. It ends up cleaner and easier to keep
28 up-to-date.
2929a2f @kchmck Readme
authored
29
30 1. Install tpope's [pathogen] into `~/.vim/autoload/` and add this line to your
31 `vimrc`:
07cfcd9 @kchmck Update the installing section
authored
32
33 call pathogen#runtime_append_all_bundles()
34
187e392 @kchmck More readme
authored
35 Be aware that it must be added before any `filetype plugin indent on`
36 lines according to the install page:
37
38 > Note that you need to invoke the pathogen functions before invoking
39 > "filetype plugin indent on" if you want it to load ftdetect files. On
40 > Debian (and probably other distros), the system vimrc does this early on,
41 > so you actually need to "filetype off" before "filetype plugin indent on"
42 > to force reloading.
43
44 To get the all the features of this plugin, be sure you do have a `filetype
45 plugin indent on` line.
07cfcd9 @kchmck Update the installing section
authored
46
c2898f2 @kchmck Add www to pathogen link (issue #6)
authored
47 [pathogen]: http://www.vim.org/scripts/script.php?script_id=2332
07cfcd9 @kchmck Update the installing section
authored
48
49 2. Create, and change into, the `~/.vim/bundle/` directory:
50
421f3fc @kchmck Readme
authored
51 $ mkdir ~/.vim/bundle
07cfcd9 @kchmck Update the installing section
authored
52 $ cd ~/.vim/bundle
53
54 3. Make a clone of the `vim-coffee-script` repository:
55
2929a2f @kchmck Readme
authored
56 $ git clone https://github.com/kchmck/vim-coffee-script.git
07cfcd9 @kchmck Update the installing section
authored
57
2929a2f @kchmck Readme
authored
58 #### Updating
07cfcd9 @kchmck Update the installing section
authored
59
60 1. Change into the `~/.vim/bundle/vim-coffee-script/` directory:
61
62 $ cd ~/.vim/bundle/vim-coffee-script
63
64 2. Pull in the latest changes:
65
66 $ git pull
67
421f3fc @kchmck Readme
authored
68 ### CoffeeMake: Compiling the Current File and Autocompiling
c92f18e @kchmck Add the CoffeeMake command
authored
69
421f3fc @kchmck Readme
authored
70 The `CoffeeMake` command compiles the current file and parses any errors:
c92f18e @kchmck Add the CoffeeMake command
authored
71
5de030e @kchmck Update screenshots
authored
72 ![CoffeeMake](http://i.imgur.com/OKRKE.png)
c92f18e @kchmck Add the CoffeeMake command
authored
73
5de030e @kchmck Update screenshots
authored
74 ![CoffeeMake](http://i.imgur.com/PQ6ed.png)
c92f18e @kchmck Add the CoffeeMake command
authored
75
5de030e @kchmck Update screenshots
authored
76 ![CoffeeMake](http://i.imgur.com/Jp6NI.png)
c92f18e @kchmck Add the CoffeeMake command
authored
77
421f3fc @kchmck Readme
authored
78 The full signature of the command is:
79
80 :[silent] CoffeeMake[!] [COFFEE-OPTS]...
81
c92f18e @kchmck Add the CoffeeMake command
authored
82 By default, `CoffeeMake` shows all compiler output and jumps to the first line
83 reported as an error by `coffee`:
84
85 :CoffeeMake
86
87 Compiler output can be hidden with `silent`:
88
89 :silent CoffeeMake
90
91 Line-jumping can be turned off by adding a bang:
92
93 :CoffeeMake!
94
95 Options given to `CoffeeMake` are passed along to `coffee`:
96
97 :CoffeeMake --bare
98
99 #### Autocompiling
100
421f3fc @kchmck Readme
authored
101 To get autocompiling when a file is written, add an `autocmd` like this to your
102 `vimrc`:
c92f18e @kchmck Add the CoffeeMake command
authored
103
421f3fc @kchmck Readme
authored
104 au BufWritePost *.coffee silent CoffeeMake!
c92f18e @kchmck Add the CoffeeMake command
authored
105
106 All of the customizations above can be used, too. This one compiles silently
1b6f1f0 @kchmck Fix awkward wording (#44)
authored
107 and with the `-b` option, but shows any errors:
c92f18e @kchmck Add the CoffeeMake command
authored
108
421f3fc @kchmck Readme
authored
109 au BufWritePost *.coffee silent CoffeeMake! -b | cwindow | redraw!
dcffbb9 @kchmck Mention redraw quirk workaround
authored
110
111 The `redraw!` command is needed to fix a redrawing quirk in terminal vim, but
112 can removed for gVim.
c92f18e @kchmck Add the CoffeeMake command
authored
113
187e392 @kchmck More readme
authored
114 #### Default compiler options
c92f18e @kchmck Add the CoffeeMake command
authored
115
116 The `CoffeeMake` command passes any options in the `coffee_make_options`
187e392 @kchmck More readme
authored
117 variable along to the compiler. This can be used to set default options:
c92f18e @kchmck Add the CoffeeMake command
authored
118
77647f6 @kchmck Misc readme
authored
119 let coffee_make_options = "--bare"
c92f18e @kchmck Add the CoffeeMake command
authored
120
421f3fc @kchmck Readme
authored
121 ### CoffeeCompile: Compiling a CoffeeScript Snippet
0e8e63f @kchmck Add CoffeeCompile command
authored
122
c92f18e @kchmck Add the CoffeeMake command
authored
123 The `CoffeeCompile` command shows how the current file or a snippet of
421f3fc @kchmck Readme
authored
124 CoffeeScript is compiled to JavaScript. Calling `CoffeeCompile` without a range
125 compiles the whole file:
0e8e63f @kchmck Add CoffeeCompile command
authored
126
5de030e @kchmck Update screenshots
authored
127 ![CoffeeCompile](http://i.imgur.com/pTesp.png)
0e8e63f @kchmck Add CoffeeCompile command
authored
128
5de030e @kchmck Update screenshots
authored
129 ![Compiled](http://i.imgur.com/81QMf.png)
0e8e63f @kchmck Add CoffeeCompile command
authored
130
131 Calling `CoffeeCompile` with a range, like in visual mode, compiles the selected
132 snippet of CoffeeScript:
133
5de030e @kchmck Update screenshots
authored
134 ![CoffeeCompile Snippet](http://i.imgur.com/Rm7iu.png)
0e8e63f @kchmck Add CoffeeCompile command
authored
135
5de030e @kchmck Update screenshots
authored
136 ![Compiled Snippet](http://i.imgur.com/KmrG8.png)
0e8e63f @kchmck Add CoffeeCompile command
authored
137
ae54812 @kchmck Retry syntax-highlighted CoffeeCompile
authored
138 This scratch buffer can be quickly closed by hitting the `q` key.
0e8e63f @kchmck Add CoffeeCompile command
authored
139
421f3fc @kchmck Readme
authored
140 ### CoffeeRun: Running some CoffeeScript
ead4012 @kchmck Document CoffeeRun in readme
authored
141
142 The `CoffeeRun` command compiles the current file or selected snippet and runs
c4df62e @kchmck Readme
authored
143 the resulting JavaScript. Output is shown at the bottom of the screen:
144
5de030e @kchmck Update screenshots
authored
145 ![CoffeeRun](http://i.imgur.com/d4yXC.png)
c4df62e @kchmck Readme
authored
146
5de030e @kchmck Update screenshots
authored
147 ![CoffeeRun Output](http://i.imgur.com/m6UID.png)
ead4012 @kchmck Document CoffeeRun in readme
authored
148
77647f6 @kchmck Misc readme
authored
149 ### Configuration
1a2148e @kchmck Add syntax error customization (thanks patrkris)
authored
150
421f3fc @kchmck Readme
authored
151 You can configure plugin behavior by adding the relevant `let` statements to
152 your `vimrc`.
1a2148e @kchmck Add syntax error customization (thanks patrkris)
authored
153
3f6df51 @kchmck Clean up readme.md
authored
154 #### Disable trailing whitespace error
1a2148e @kchmck Add syntax error customization (thanks patrkris)
authored
155
3f6df51 @kchmck Clean up readme.md
authored
156 Trailing whitespace is highlighted as an error by default. This can be disabled
157 with:
1a2148e @kchmck Add syntax error customization (thanks patrkris)
authored
158
159 let coffee_no_trailing_space_error = 1
160
3f6df51 @kchmck Clean up readme.md
authored
161 #### Disable trailing semicolon error
1a2148e @kchmck Add syntax error customization (thanks patrkris)
authored
162
421f3fc @kchmck Readme
authored
163 Trailing semicolons are also considered an error (for help transitioning from
164 JavaScript.) This can be disabled with:
1a2148e @kchmck Add syntax error customization (thanks patrkris)
authored
165
166 let coffee_no_trailing_semicolon_error = 1
12f044a @kchmck Make the reserved words error configurable
authored
167
3f6df51 @kchmck Clean up readme.md
authored
168 #### Disable reserved words error
12f044a @kchmck Make the reserved words error configurable
authored
169
c4df62e @kchmck Readme
authored
170 Reserved words like `function` and `var` are highlighted as an error in contexts
3f6df51 @kchmck Clean up readme.md
authored
171 disallowed by CoffeeScript. This can be disabled with:
12f044a @kchmck Make the reserved words error configurable
authored
172
173 let coffee_no_reserved_words_error = 1
dff2a57 @kchmck Deprecate coffee_folding
authored
174
175 ### Tuning Vim for CoffeeScript
176
421f3fc @kchmck Readme
authored
177 Changing these core settings can make vim more CoffeeScript friendly.
dff2a57 @kchmck Deprecate coffee_folding
authored
178
179 #### Fold by indentation
180
421f3fc @kchmck Readme
authored
181 Folding by indentation is a good fit for CoffeeScript functions and classes:
dff2a57 @kchmck Deprecate coffee_folding
authored
182
5de030e @kchmck Update screenshots
authored
183 ![Folding](http://i.imgur.com/lpDWo.png)
dff2a57 @kchmck Deprecate coffee_folding
authored
184
185 To fold by indentation in CoffeeScript files, add this line to your `vimrc`:
186
187 au BufNewFile,BufReadPost *.coffee setl foldmethod=indent nofoldenable
188
189 With this, folding is disabled by default but can be quickly toggled per-file
190 by hitting `zi`. To enable it by default, remove `nofoldenable`:
191
192 au BufNewFile,BufReadPost *.coffee setl foldmethod=indent
3c6b338 @kchmck Mention two-space indents (#41)
authored
193
194 #### Two-space indentation
195
196 To get standard two-space indentation in CoffeeScript files, add this line to
197 your `vimrc`:
198
199 au BufNewFile,BufReadPost *.coffee setl shiftwidth=2 expandtab
Something went wrong with that request. Please try again.