mirror of
https://github.com/amix/vimrc
synced 2025-06-16 01:25:00 +08:00
Updated all the plugins. Removed powerline. Added vim-airline (replacement for powerline). Added vim-fugitive.
This commit is contained in:
@ -1,226 +1,555 @@
|
||||
This project adds [CoffeeScript] support to the vim editor. It handles syntax,
|
||||
indenting, compiling, and more. Also included is support for CoffeeScript in
|
||||
Haml and HTML.
|
||||
This project adds [CoffeeScript] support to vim. It covers syntax, indenting,
|
||||
compiling, and more.
|
||||
|
||||

|
||||

|
||||
|
||||
[CoffeeScript]: http://jashkenas.github.com/coffee-script/
|
||||
[CoffeeScript]: http://coffeescript.org/
|
||||
|
||||
### Install from a Zipball
|
||||
## Table of Contents
|
||||
|
||||
This is the quickest way to get things running.
|
||||
- Installation
|
||||
- [Requirements](#requirements)
|
||||
- [Install using Pathogen](#install-using-pathogen)
|
||||
- [Install using Vundle](#install-using-vundle)
|
||||
- [Install from a Zip File](#install-from-a-zip-file)
|
||||
- Coffee Commands
|
||||
- [Compile to JavaScript](#compile-to-javascript)
|
||||
- [Compile CoffeeScript Snippets](#coffeecompile-compile-coffeescript-snippets)
|
||||
- [Live Preview Compiling](#coffeewatch-live-preview-compiling)
|
||||
- [Run CoffeeScript Snippets](#coffeerun-run-coffeescript-snippets)
|
||||
- [Lint your CoffeeScript](#coffeelint-lint-your-coffeescript)
|
||||
- Extras
|
||||
- [Literate CoffeeScript](#literate-coffeescript)
|
||||
- [CoffeeScript in HTML](#coffeescript-in-html)
|
||||
- [CoffeeScript in Haml](#coffeescript-in-haml)
|
||||
- Configuration
|
||||
- [Custom Autocmds](#custom-autocmds)
|
||||
- [Configuration Variables](#configuration-variables)
|
||||
- [Configure Syntax Highlighting](#configure-syntax-highlighting)
|
||||
- [Tune Vim for CoffeeScript](#tune-vim-for-coffeescript)
|
||||
|
||||
1. Download the latest zipball from [vim.org][zipball-vim] or
|
||||
[github][zipball-github]. The latest version on github is under Download
|
||||
Packages (don't use the Download buttons.)
|
||||
## Requirements
|
||||
|
||||
2. Extract the archive into `~/.vim/`:
|
||||
- vim 7.4 or later
|
||||
- coffee 1.2.0 or later
|
||||
|
||||
unzip -od ~/.vim vim-coffee-script-HASH.zip
|
||||
## Install using Pathogen
|
||||
|
||||
These steps are also used to update the plugin.
|
||||
This project uses rolling releases based on git commits, so pathogen is a
|
||||
natural fit for it. If you're already using pathogen, you can skip to step 4.
|
||||
|
||||
[zipball-vim]: http://www.vim.org/scripts/script.php?script_id=3590
|
||||
[zipball-github]: https://github.com/kchmck/vim-coffee-script/downloads
|
||||
1. Install [pathogen.vim] into `~/.vim/autoload/` (see [pathogen's
|
||||
readme][install-pathogen] for more information.)
|
||||
|
||||
### Install with Pathogen
|
||||
[pathogen.vim]: http://www.vim.org/scripts/script.php?script_id=2332
|
||||
[install-pathogen]: https://github.com/tpope/vim-pathogen#installation
|
||||
|
||||
Since this plugin has rolling versions based on git commits, using pathogen and
|
||||
git is the preferred way to install. The plugin ends up contained in its own
|
||||
directory and updates are just a `git pull` away.
|
||||
2. Enable pathogen in your vimrc. Here's a bare-minimum vimrc that enables
|
||||
all the features of `vim-coffee-script`:
|
||||
|
||||
1. Install tpope's [pathogen] into `~/.vim/autoload/` and add this line to your
|
||||
`vimrc`:
|
||||
```vim
|
||||
call pathogen#infect()
|
||||
syntax enable
|
||||
filetype plugin indent on
|
||||
```
|
||||
|
||||
call pathogen#infect()
|
||||
If you already have a vimrc built up, just make sure it contains these calls,
|
||||
in this order.
|
||||
|
||||
To get the all the features of this plugin, make sure you also have a
|
||||
`filetype plugin indent on` line in there.
|
||||
3. Create the directory `~/.vim/bundle/`:
|
||||
|
||||
[pathogen]: http://www.vim.org/scripts/script.php?script_id=2332
|
||||
mkdir ~/.vim/bundle
|
||||
|
||||
2. Create and change into `~/.vim/bundle/`:
|
||||
4. Clone the `vim-coffee-script` repo into `~/.vim/bundle/`:
|
||||
|
||||
$ mkdir ~/.vim/bundle
|
||||
$ cd ~/.vim/bundle
|
||||
git clone https://github.com/kchmck/vim-coffee-script.git ~/.vim/bundle/vim-coffee-script/
|
||||
|
||||
3. Make a clone of the `vim-coffee-script` repository:
|
||||
|
||||
$ git clone https://github.com/kchmck/vim-coffee-script.git
|
||||
|
||||
#### Updating
|
||||
Updating takes two steps:
|
||||
|
||||
1. Change into `~/.vim/bundle/vim-coffee-script/`:
|
||||
|
||||
$ cd ~/.vim/bundle/vim-coffee-script
|
||||
cd ~/.vim/bundle/vim-coffee-script
|
||||
|
||||
2. Pull in the latest changes:
|
||||
|
||||
$ git pull
|
||||
git pull
|
||||
|
||||
### CoffeeMake: Compile the Current File
|
||||
## Install using Vundle
|
||||
|
||||
The `CoffeeMake` command compiles the current file and parses any errors:
|
||||
1. [Install Vundle] into `~/.vim/bundle/`.
|
||||
|
||||

|
||||
[Install Vundle]: https://github.com/gmarik/vundle#quick-start
|
||||
|
||||
The full signature of the command is:
|
||||
2. Configure your vimrc for Vundle. Here's a bare-minimum vimrc that enables all
|
||||
the features of `vim-coffee-script`:
|
||||
|
||||
:[silent] CoffeeMake[!] [COFFEE-OPTIONS]...
|
||||
|
||||
By default, `CoffeeMake` shows all compiler output and jumps to the first line
|
||||
reported as an error by `coffee`:
|
||||
```vim
|
||||
set nocompatible
|
||||
filetype off
|
||||
|
||||
:CoffeeMake
|
||||
set rtp+=~/.vim/bundle/vundle/
|
||||
call vundle#rc()
|
||||
|
||||
Compiler output can be hidden with `silent`:
|
||||
Bundle 'kchmck/vim-coffee-script'
|
||||
|
||||
:silent CoffeeMake
|
||||
syntax enable
|
||||
filetype plugin indent on
|
||||
```
|
||||
|
||||
Line-jumping can be turned off by adding a bang:
|
||||
If you're adding Vundle to a built-up vimrc, just make sure all these calls
|
||||
are in there and that they occur in this order.
|
||||
|
||||
:CoffeeMake!
|
||||
3. Open vim and run `:BundleInstall`.
|
||||
|
||||
Options given to `CoffeeMake` are passed along to `coffee`:
|
||||
To update, open vim and run `:BundleInstall!` (notice the bang!)
|
||||
|
||||
:CoffeeMake --bare
|
||||
## Install from a Zip File
|
||||
|
||||
`CoffeeMake` can be manually loaded for a file with:
|
||||
1. Download the latest zip file from [vim.org][zip].
|
||||
|
||||
2. Extract the archive into `~/.vim/`:
|
||||
|
||||
unzip -od ~/.vim/ ARCHIVE.zip
|
||||
|
||||
This should create the files `~/.vim/autoload/coffee.vim`,
|
||||
`~/.vim/compiler/coffee.vim`, etc.
|
||||
|
||||
You can update the plugin using the same steps.
|
||||
|
||||
[zip]: http://www.vim.org/scripts/script.php?script_id=3590
|
||||
|
||||
## Compile to JavaScript
|
||||
|
||||
A `coffee` wrapper for use with `:make` is enabled automatically for coffee
|
||||
files if no other compiler is loaded. To enable it manually, run
|
||||
|
||||
:compiler coffee
|
||||
|
||||
#### Recompile on write
|
||||
The `:make` command is then configured to use the `coffee` compiler and
|
||||
recognize its errors. I've included a quick reference here but be sure to check
|
||||
out [`:help :make`][make] for a full reference of the command.
|
||||
|
||||
To recompile a file when it's written, add an `autocmd` like this to your
|
||||
`vimrc`:
|
||||

|
||||
|
||||
au BufWritePost *.coffee silent CoffeeMake!
|
||||

|
||||
|
||||
All of the customizations above can be used, too. This one compiles silently
|
||||
and with the `-b` option, but shows any errors:
|
||||
[make]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:make_makeprg
|
||||
|
||||
au BufWritePost *.coffee silent CoffeeMake! -b | cwindow | redraw!
|
||||
Consider the full signature of a `:make` call as
|
||||
|
||||
:[silent] make[!] [COFFEE-OPTIONS]...
|
||||
|
||||
By default `:make` shows all compiler output and jumps to the first line
|
||||
reported as an error. Compiler output can be hidden with a leading `:silent`:
|
||||
|
||||
:silent make
|
||||
|
||||
Line-jumping can be turned off by adding a bang:
|
||||
|
||||
:make!
|
||||
|
||||
`COFFEE-OPTIONS` given to `:make` are passed along to `coffee` (see also
|
||||
[`coffee_make_options`](#coffee_make_options)):
|
||||
|
||||
:make --bare --output /some/dir
|
||||
|
||||
See the [full table of options](http://coffeescript.org/#usage) for a
|
||||
list of all the options that `coffee` recognizes.
|
||||
|
||||
*Configuration*: [`coffee_compiler`](#coffee_compiler),
|
||||
[`coffee_make_options`](#coffee_make_options)
|
||||
|
||||
#### The quickfix window
|
||||
|
||||
Compiler errors are added to the [quickfix] list by `:make`, but the quickfix
|
||||
window isn't automatically shown. The [`:cwindow`][cwindow] command will pop up
|
||||
the quickfix window if there are any errors:
|
||||
|
||||
:make
|
||||
:cwindow
|
||||
|
||||
This is usually the desired behavior, so you may want to add an autocmd to your
|
||||
vimrc to do this automatically:
|
||||
|
||||
autocmd QuickFixCmdPost * nested cwindow | redraw!
|
||||
|
||||
The `redraw!` command is needed to fix a redrawing quirk in terminal vim, but
|
||||
can removed for gVim.
|
||||
|
||||
#### Default compiler options
|
||||
[quickfix]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix
|
||||
[cwindow]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:cwindow
|
||||
|
||||
The `CoffeeMake` command passes any options in the `coffee_make_options`
|
||||
variable along to the compiler. You can use this to set default options:
|
||||
#### Recompile on write
|
||||
|
||||
let coffee_make_options = '--bare'
|
||||
To recompile a file when it's written, add a `BufWritePost` autocmd to your
|
||||
vimrc:
|
||||
|
||||
#### Path to compiler
|
||||
autocmd BufWritePost *.coffee silent make!
|
||||
|
||||
To change the compiler used by `CoffeeMake` and `CoffeeCompile`, set
|
||||
`coffee_compiler` to the full path of an executable or the filename of one
|
||||
in your `$PATH`:
|
||||
#### Cake and Cakefiles
|
||||
|
||||
let coffee_compiler = '/usr/bin/coffee'
|
||||
A `cake` compiler is also available with the call
|
||||
|
||||
This option is set to `coffee` by default.
|
||||
:compiler cake
|
||||
|
||||
### CoffeeCompile: Compile Snippets of CoffeeScript
|
||||
You can then use `:make` as above to run your Cakefile and capture any `coffee`
|
||||
errors:
|
||||
|
||||
The `CoffeeCompile` command shows how the current file or a snippet of
|
||||
CoffeeScript is compiled to JavaScript. The full signature of the command is:
|
||||
:silent make build
|
||||
|
||||
:[RANGE] CoffeeCompile [watch|unwatch] [vert[ical]] [WINDOW-SIZE]
|
||||
It runs within the current directory, so make sure you're in the directory of
|
||||
your Cakefile before calling it.
|
||||
|
||||
Calling `CoffeeCompile` without a range compiles the whole file:
|
||||
*Configuration*: [`coffee_cake`](#coffee_cake),
|
||||
[`coffee_cake_options`](#coffee_cake_options)
|
||||
|
||||

|
||||
## CoffeeCompile: Compile CoffeeScript Snippets
|
||||
|
||||
Calling `CoffeeCompile` with a range, like in visual mode, compiles the selected
|
||||
snippet of CoffeeScript:
|
||||
CoffeeCompile shows how the current file or a snippet of CoffeeScript is
|
||||
compiled to JavaScript.
|
||||
|
||||

|
||||
:[RANGE] CoffeeCompile [vert[ical]] [WINDOW-SIZE]
|
||||
|
||||

|
||||
Calling `:CoffeeCompile` without a range compiles the whole file:
|
||||
|
||||
This scratch buffer can be quickly closed by hitting the `q` key.
|
||||

|
||||
|
||||
Using `vert` splits the CoffeeCompile buffer vertically instead of horizontally:
|
||||

|
||||
|
||||
Calling it with a range, like in visual mode, compiles only the selected snippet
|
||||
of CoffeeScript:
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
Each file gets its own CoffeeCompile buffer, and the same buffer is used for all
|
||||
future calls of `:CoffeeCompile` on that file. It can be quickly closed by
|
||||
hitting `q` in normal mode.
|
||||
|
||||
Using `vert` opens the CoffeeCompile buffer vertically instead of horizontally
|
||||
(see also [`coffee_compile_vert`](#coffee_compile_vert)):
|
||||
|
||||
:CoffeeCompile vert
|
||||
|
||||
Set the `coffee_compile_vert` variable to split the buffer vertically by
|
||||
default:
|
||||
|
||||
let coffee_compile_vert = 1
|
||||
|
||||
The initial size of the CoffeeCompile buffer can be given as a number:
|
||||
By default the CoffeeCompile buffer splits the source buffer in half, but this
|
||||
can be overridden by passing in a `WINDOW-SIZE`:
|
||||
|
||||
:CoffeeCompile 4
|
||||
|
||||
#### Watch (live preview) mode
|
||||
*Configuration*: [`coffee_compiler`](#coffee_compiler`),
|
||||
[`coffee_compile_vert`](#coffee_compile_vert)
|
||||
|
||||
Watch mode is like the Try CoffeeScript preview box on the CoffeeScript
|
||||
homepage:
|
||||
#### Quick syntax checking
|
||||
|
||||

|
||||
If compiling a snippet results in a compiler error, CoffeeCompile adds that
|
||||
error to the [quickfix] list.
|
||||
|
||||

|
||||
[quickfix]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix
|
||||
|
||||
Writing some code and then exiting insert mode automatically updates the
|
||||
compiled JavaScript buffer.
|
||||

|
||||
|
||||
Use `watch` to start watching a buffer (`vert` is also recommended):
|
||||

|
||||
|
||||
:CoffeeCompile watch vert
|
||||
You can use this to quickly check the syntax of a snippet.
|
||||
|
||||
After making some changes in insert mode, hit escape and the CoffeeScript will
|
||||
be recompiled. Changes made outside of insert mode don't trigger this recompile,
|
||||
but calling `CoffeeCompile` will compile these changes without any bad effects.
|
||||
## CoffeeWatch: Live Preview Compiling
|
||||
|
||||
To get synchronized scrolling of a CoffeeScript and CoffeeCompile buffer, set
|
||||
`scrollbind` on each:
|
||||
CoffeeWatch emulates using the Try CoffeeScript preview box on the [CoffeeScript
|
||||
homepage][CoffeeScript].
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
CoffeeWatch takes the same options as CoffeeCompile:
|
||||
|
||||
:CoffeeWatch [vert[ical]] [WINDOW-SIZE]
|
||||
|
||||
After a source buffer is watched, leaving insert mode or saving the file fires
|
||||
off a recompile of the CoffeeScript:
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
You can force recompilation by calling `:CoffeeWatch`.
|
||||
|
||||
To get synchronized scrolling of the source buffer and CoffeeWatch buffer, set
|
||||
[`'scrollbind'`](http://vimdoc.sourceforge.net/htmldoc/options.html#'scrollbind')
|
||||
on each:
|
||||
|
||||
:setl scrollbind
|
||||
|
||||
Use `unwatch` to stop watching a buffer:
|
||||
*Configuration*: [`coffee_compiler`](#coffee_compiler),
|
||||
[`coffee_watch_vert`](#coffee_watch_vert)
|
||||
|
||||
:CoffeeCompile unwatch
|
||||
## CoffeeRun: Run CoffeeScript Snippets
|
||||
|
||||
### CoffeeLint: Lint your CoffeeScript
|
||||
CoffeeRun compiles the current file or selected snippet and runs the resulting
|
||||
JavaScript.
|
||||
|
||||
The `CoffeeLint` command runs [coffeelint](http://www.coffeelint.org/) (version
|
||||
0.4.0 or later required) on the current file and parses any errors:
|
||||

|
||||
|
||||
:[RANGE] CoffeeLint[!] [COFFEELINT-OPTIONS]
|
||||

|
||||
|
||||
Use it like `CoffeeMake`.
|
||||
The command has two forms:
|
||||
|
||||

|
||||
:CoffeeRun [PROGRAM-OPTIONS]...
|
||||
|
||||
#### Default coffeelint options
|
||||
This form applies when no `RANGE` is given or when the given range is `1,$`
|
||||
(first line to last line). It allows passing `PROGRAM-OPTIONS` to your compiled
|
||||
program. The filename is passed directly to `coffee` so you must save the file
|
||||
for your changes to take effect.
|
||||
|
||||
Options in `coffee_lint_options` are passed along to `coffeelint`:
|
||||
:RANGE CoffeeRun [COFFEE-OPTIONS]...
|
||||
|
||||
This form applies with all other ranges. It compiles and runs the lines within
|
||||
the given `RANGE` and any extra `COFFEE-OPTIONS` are passed to `coffee`.
|
||||
|
||||
*Configuration*: [`coffee_compiler`](#coffee_compiler),
|
||||
[`coffee_run_vert`](#coffee_run_vert)
|
||||
|
||||
## CoffeeLint: Lint your CoffeeScript
|
||||
|
||||
CoffeeLint runs [coffeelint](http://www.coffeelint.org/) (version 0.5.7 or later
|
||||
required) on the current file and adds any issues to the [quickfix] list.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
:[RANGE] CoffeeLint[!] [COFFEELINT-OPTIONS]... [ | cwindow]
|
||||
|
||||
If a `RANGE` is given, only those lines are piped to `coffeelint`. Options given
|
||||
in `COFFEELINT-OPTIONS` are passed to `coffeelint` (see also
|
||||
[`coffee_lint_options`](#coffee_lint_options)):
|
||||
|
||||
:CoffeeLint -f lint.json
|
||||
|
||||
It behaves very similar to `:make`, described [above](#compile-to-javascript).
|
||||
|
||||
:CoffeeLint! | cwindow
|
||||
|
||||
*Configuration*: [`coffee_linter`](#coffee_linter),
|
||||
[`coffee_lint_options`](#coffee_lint_options)
|
||||
|
||||
## Literate CoffeeScript
|
||||
|
||||
Literate CoffeeScript syntax and indent support is provided by
|
||||
[vim-literate-coffeescript]. The `Coffee` commands detect when they're running
|
||||
on a litcoffee file and pass the `--literate` flag to their respective tools,
|
||||
but at this time the commands are not automatically loaded when a litcoffee file
|
||||
is opened.
|
||||
|
||||
[vim-literate-coffeescript]: https://github.com/mintplant/vim-literate-coffeescript
|
||||
|
||||
To load them, run
|
||||
|
||||
runtime ftplugin/coffee.vim
|
||||
|
||||
while inside a litcoffee buffer. To do this automatically, add
|
||||
|
||||
autocmd FileType litcoffee runtime ftplugin/coffee.vim
|
||||
|
||||
to your vimrc.
|
||||
|
||||
## CoffeeScript in HTML
|
||||
|
||||
CoffeeScript is highlighted and indented within
|
||||
|
||||
```html
|
||||
<script type="text/coffeescript">
|
||||
</script>
|
||||
```
|
||||
|
||||
blocks in html files.
|
||||
|
||||
## CoffeeScript in Haml
|
||||
|
||||
CoffeeScript is highlighted within the `:coffeescript` filter in haml files:
|
||||
|
||||
```haml
|
||||
:coffeescript
|
||||
console.log "hullo"
|
||||
```
|
||||
|
||||
At this time, coffee indenting doesn't work in these blocks.
|
||||
|
||||
## Custom Autocmds
|
||||
|
||||
You can [define commands][autocmd-explain] to be ran automatically on these
|
||||
custom events.
|
||||
|
||||
In all cases, the name of the command running the event (`CoffeeCompile`,
|
||||
`CoffeeWatch`, or `CoffeeRun`) is matched by the [`{pat}`][autocmd] argument.
|
||||
You can match all commands with a `*` or only specific commands by separating
|
||||
them with a comma: `CoffeeCompile,CoffeeWatch`.
|
||||
|
||||
[autocmd-explain]: http://vimdoc.sourceforge.net/htmldoc/usr_40.html#40.3
|
||||
[autocmd]: http://vimdoc.sourceforge.net/htmldoc/autocmd.html#:autocmd
|
||||
|
||||
#### CoffeeBufNew
|
||||
|
||||
CoffeeBufNew is ran when a new scratch buffer is created. It's called from the
|
||||
new buffer, so it can be used to do additional set up.
|
||||
|
||||
```vim
|
||||
augroup CoffeeBufNew
|
||||
autocmd User * set wrap
|
||||
augroup END
|
||||
```
|
||||
|
||||
*Used By*: CoffeeCompile, CoffeeWatch, CoffeeRun
|
||||
|
||||
#### CoffeeBufUpdate
|
||||
|
||||
CoffeeBufUpdate is ran when a scratch buffer is updated with output from
|
||||
`coffee`. It's called from the scratch buffer, so it can be used to alter the
|
||||
compiled output.
|
||||
|
||||
```vim
|
||||
" Switch back to the source buffer after updating.
|
||||
augroup CoffeeBufUpdate
|
||||
autocmd User CoffeeCompile,CoffeeRun exec bufwinnr(b:coffee_src_buf) 'wincmd w'
|
||||
augroup END
|
||||
```
|
||||
|
||||
For example, to strip off the "Generated by" comment on the first line, put this
|
||||
in your vimrc:
|
||||
|
||||
```vim
|
||||
function! s:RemoveGeneratedBy()
|
||||
" If there was an error compiling, there's no comment to remove.
|
||||
if v:shell_error
|
||||
return
|
||||
endif
|
||||
|
||||
" Save cursor position.
|
||||
let pos = getpos('.')
|
||||
|
||||
" Remove first line.
|
||||
set modifiable
|
||||
1 delete _
|
||||
set nomodifiable
|
||||
|
||||
" Restore cursor position.
|
||||
call setpos('.', pos)
|
||||
endfunction
|
||||
|
||||
augroup CoffeeBufUpdate
|
||||
autocmd User CoffeeCompile,CoffeeWatch call s:RemoveGeneratedBy()
|
||||
augroup END
|
||||
```
|
||||
|
||||
*Used By*: CoffeeCompile, CoffeeWatch, CoffeeRun
|
||||
|
||||
## Configuration Variables
|
||||
|
||||
This is the full list of configuration variables available, with example
|
||||
settings and default values. Use these in your vimrc to control the default
|
||||
behavior.
|
||||
|
||||
#### coffee\_indent\_keep\_current
|
||||
|
||||
By default, the indent function matches the indent of the previous line if it
|
||||
doesn't find a reason to indent or outdent. To change this behavior so it
|
||||
instead keeps the [current indent of the cursor][98], use
|
||||
|
||||
let coffee_indent_keep_current = 1
|
||||
|
||||
[98]: https://github.com/kchmck/vim-coffee-script/pull/98
|
||||
|
||||
*Default*: `unlet coffee_indent_keep_current`
|
||||
|
||||
Note that if you change this after a coffee file has been loaded, you'll have to
|
||||
reload the indent script for the change to take effect:
|
||||
|
||||
unlet b:did_indent | runtime indent/coffee.vim
|
||||
|
||||
#### coffee\_compiler
|
||||
|
||||
Path to the `coffee` executable used by the `Coffee` commands:
|
||||
|
||||
let coffee_compiler = '/usr/bin/coffee'
|
||||
|
||||
*Default*: `'coffee'` (search `$PATH` for executable)
|
||||
|
||||
#### coffee\_make\_options
|
||||
|
||||
Options to pass to `coffee` with `:make`:
|
||||
|
||||
let coffee_make_options = '--bare'
|
||||
|
||||
*Default*: `''` (nothing)
|
||||
|
||||
Note that `coffee_make_options` is embedded into `'makeprg'`, so `:compiler
|
||||
coffee` must be ran after changing `coffee_make_options` for the changes to take
|
||||
effect.
|
||||
|
||||
#### coffee\_cake
|
||||
|
||||
Path to the `cake` executable:
|
||||
|
||||
let coffee_cake = '/opt/bin/cake'
|
||||
|
||||
*Default*: `'cake'` (search `$PATH` for executable)
|
||||
|
||||
#### coffee\_cake\_options
|
||||
|
||||
Options to pass to `cake` with `:make`:
|
||||
|
||||
let coffee_cake_options = 'build'
|
||||
|
||||
*Default*: `''` (nothing)
|
||||
|
||||
#### coffee\_linter
|
||||
|
||||
Path to the `coffeelint` executable:
|
||||
|
||||
let coffee_linter = '/opt/bin/coffeelint'
|
||||
|
||||
*Default*: `'coffeelint'` (search `$PATH` for executable)
|
||||
|
||||
#### coffee\_lint\_options
|
||||
|
||||
Options to pass to `coffeelint`:
|
||||
|
||||
let coffee_lint_options = '-f lint.json'
|
||||
|
||||
#### Path to `coffeelint`
|
||||
*Default*: `''` (nothing)
|
||||
|
||||
Use the `coffee_linter` option to set a different path to the `coffeelint`
|
||||
executable:
|
||||
#### coffee\_compile\_vert
|
||||
|
||||
let coffee_linter = '/usr/bin/coffeelint'
|
||||
Open the CoffeeCompile buffer with a vertical split instead of a horizontal
|
||||
one:
|
||||
|
||||
This option is set to `coffeelint` by default.
|
||||
let coffee_compile_vert = 1
|
||||
|
||||
### CoffeeRun: Run some CoffeeScript
|
||||
*Default*: `unlet coffee_compile_vert`
|
||||
|
||||
The `CoffeeRun` command compiles the current file or selected snippet and runs
|
||||
the resulting JavaScript. Output is shown at the bottom of the screen:
|
||||
#### coffee\_watch\_vert
|
||||
|
||||

|
||||
Open the CoffeeWatch buffer with a vertical split instead of a horizontal
|
||||
one:
|
||||
|
||||

|
||||
let coffee_watch_vert = 1
|
||||
|
||||
### Configure Syntax Highlighting
|
||||
*Default*: `unlet coffee_watch_vert`
|
||||
|
||||
Add these lines to your `vimrc` to disable the relevant syntax group.
|
||||
#### coffee\_run\_vert
|
||||
|
||||
Open the CoffeeRun buffer with a vertical split instead of a horizontal
|
||||
one:
|
||||
|
||||
let coffee_run_vert = 1
|
||||
|
||||
*Default*: `unlet coffee_run_vert`
|
||||
|
||||
## Configure Syntax Highlighting
|
||||
|
||||
Add these lines to your vimrc to disable the relevant syntax group.
|
||||
|
||||
#### Disable trailing whitespace error
|
||||
|
||||
@ -231,7 +560,7 @@ with:
|
||||
|
||||
#### Disable trailing semicolon error
|
||||
|
||||
Trailing semicolons are also considered an error (for help transitioning from
|
||||
Trailing semicolons are considered an error (for help transitioning from
|
||||
JavaScript.) This can be disabled with:
|
||||
|
||||
hi link coffeeSemicolonError NONE
|
||||
@ -243,7 +572,7 @@ they're not allowed in CoffeeScript. This can be disabled with:
|
||||
|
||||
hi link coffeeReservedError NONE
|
||||
|
||||
### Tune Vim for CoffeeScript
|
||||
## Tune Vim for CoffeeScript
|
||||
|
||||
Changing these core settings can make vim more CoffeeScript friendly.
|
||||
|
||||
@ -251,20 +580,20 @@ Changing these core settings can make vim more CoffeeScript friendly.
|
||||
|
||||
Folding by indentation works well for CoffeeScript functions and classes:
|
||||
|
||||

|
||||

|
||||
|
||||
To fold by indentation in CoffeeScript files, add this line to your `vimrc`:
|
||||
To fold by indentation in CoffeeScript files, add this line to your vimrc:
|
||||
|
||||
au BufNewFile,BufReadPost *.coffee setl foldmethod=indent nofoldenable
|
||||
autocmd BufNewFile,BufReadPost *.coffee setl foldmethod=indent nofoldenable
|
||||
|
||||
With this, folding is disabled by default but can be quickly toggled per-file
|
||||
by hitting `zi`. To enable folding by default, remove `nofoldenable`:
|
||||
|
||||
au BufNewFile,BufReadPost *.coffee setl foldmethod=indent
|
||||
autocmd BufNewFile,BufReadPost *.coffee setl foldmethod=indent
|
||||
|
||||
#### Two-space indentation
|
||||
|
||||
To get standard two-space indentation in CoffeeScript files, add this line to
|
||||
your `vimrc`:
|
||||
your vimrc:
|
||||
|
||||
au BufNewFile,BufReadPost *.coffee setl shiftwidth=2 expandtab
|
||||
autocmd BufNewFile,BufReadPost *.coffee setl shiftwidth=2 expandtab
|
||||
|
Reference in New Issue
Block a user