{"id":13773617,"url":"https://github.com/kchmck/vim-coffee-script","last_synced_at":"2025-05-16T07:04:46.734Z","repository":{"id":55583016,"uuid":"481220","full_name":"kchmck/vim-coffee-script","owner":"kchmck","description":"CoffeeScript support for vim","archived":false,"fork":false,"pushed_at":"2020-12-20T17:00:14.000Z","size":432,"stargazers_count":1765,"open_issues_count":36,"forks_count":201,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-05-14T14:28:37.969Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Vim script","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kchmck.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"Copying.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-01-20T21:36:21.000Z","updated_at":"2025-01-30T18:08:03.000Z","dependencies_parsed_at":"2022-08-15T03:40:17.894Z","dependency_job_id":null,"html_url":"https://github.com/kchmck/vim-coffee-script","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kchmck%2Fvim-coffee-script","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kchmck%2Fvim-coffee-script/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kchmck%2Fvim-coffee-script/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kchmck%2Fvim-coffee-script/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kchmck","download_url":"https://codeload.github.com/kchmck/vim-coffee-script/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254485055,"owners_count":22078767,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T17:01:18.044Z","updated_at":"2025-05-16T07:04:41.726Z","avatar_url":"https://github.com/kchmck.png","language":"Vim script","readme":"This project adds [CoffeeScript] support to vim. It covers syntax, indenting,\ncompiling, and more.\n\n![Screenshot](http://i.imgur.com/j1BhpZQ.png)\n\n[CoffeeScript]: http://coffeescript.org/\n\n## Table of Contents\n\n- Installation\n  - [Requirements](#requirements)\n  - [Install using Pathogen](#install-using-pathogen)\n  - [Install using Vundle](#install-using-vundle)\n  - [Install from a Zip File](#install-from-a-zip-file)\n- Coffee Commands\n  - [Compile to JavaScript](#compile-to-javascript)\n  - [Compile CoffeeScript Snippets](#coffeecompile-compile-coffeescript-snippets)\n  - [Live Preview Compiling](#coffeewatch-live-preview-compiling)\n  - [Run CoffeeScript Snippets](#coffeerun-run-coffeescript-snippets)\n  - [Lint your CoffeeScript](#coffeelint-lint-your-coffeescript)\n- Extras\n  - [Literate CoffeeScript](#literate-coffeescript)\n  - [CoffeeScript in HTML](#coffeescript-in-html)\n  - [CoffeeScript in Haml](#coffeescript-in-haml)\n- Configuration\n  - [Custom Autocmds](#custom-autocmds)\n  - [Configuration Variables](#configuration-variables)\n  - [Configure Syntax Highlighting](#configure-syntax-highlighting)\n  - [Tune Vim for CoffeeScript](#tune-vim-for-coffeescript)\n\n## Requirements\n\n - vim 7.4 or later\n - coffee 1.2.0 or later\n\n## Install using Pathogen\n\nThis project uses rolling releases based on git commits, so pathogen is a\nnatural fit for it. If you're already using pathogen, you can skip to step 4.\n\n1. Install [pathogen.vim] into `~/.vim/autoload/` (see [pathogen's\n   readme][install-pathogen] for more information.)\n\n[pathogen.vim]: http://www.vim.org/scripts/script.php?script_id=2332\n[install-pathogen]: https://github.com/tpope/vim-pathogen#installation\n\n2. Enable pathogen in your vimrc. Here's a bare-minimum vimrc that enables\n   all the features of `vim-coffee-script`:\n\n   ```vim\n   call pathogen#infect()\n   syntax enable\n   filetype plugin indent on\n   ```\n\n   If you already have a vimrc built up, just make sure it contains these calls,\n   in this order.\n\n3. Create the directory `~/.vim/bundle/`:\n\n        mkdir ~/.vim/bundle\n\n4. Clone the `vim-coffee-script` repo into `~/.vim/bundle/`:\n\n        git clone https://github.com/kchmck/vim-coffee-script.git ~/.vim/bundle/vim-coffee-script/\n\nUpdating takes two steps:\n\n1. Change into `~/.vim/bundle/vim-coffee-script/`:\n\n        cd ~/.vim/bundle/vim-coffee-script\n\n2. Pull in the latest changes:\n\n        git pull\n\n## Install using Vundle\n\n1. [Install Vundle] into `~/.vim/bundle/`.\n\n[Install Vundle]: https://github.com/gmarik/vundle#quick-start\n\n2. Configure your vimrc for Vundle. Here's a bare-minimum vimrc that enables all\n   the features of `vim-coffee-script`:\n\n\n   ```vim\n   set nocompatible\n   filetype off\n\n   set rtp+=~/.vim/bundle/vundle/\n   call vundle#rc()\n\n   Plugin 'kchmck/vim-coffee-script'\n\n   syntax enable\n   filetype plugin indent on\n   ```\n\n   If you're adding Vundle to a built-up vimrc, just make sure all these calls\n   are in there and that they occur in this order.\n\n3. Open vim and run `:PluginInstall`.\n\nTo update, open vim and run `:PluginInstall!` (notice the bang!)\n\n## Install from a Zip File\n\n1. Download the latest zip file from [vim.org][zip].\n\n2. Extract the archive into `~/.vim/`:\n\n        unzip -od ~/.vim/ ARCHIVE.zip\n\n   This should create the files `~/.vim/autoload/coffee.vim`,\n   `~/.vim/compiler/coffee.vim`, etc.\n\nYou can update the plugin using the same steps.\n\n[zip]: http://www.vim.org/scripts/script.php?script_id=3590\n\n## Compile to JavaScript\n\nA `coffee` wrapper for use with `:make` is enabled automatically for coffee\nfiles if no other compiler is loaded. To enable it manually, run\n\n    :compiler coffee\n\nThe `:make` command is then configured to use the `coffee` compiler and\nrecognize its errors. I've included a quick reference here but be sure to check\nout [`:help :make`][make] for a full reference of the command.\n\n  ![make](http://i.imgur.com/scUXmxR.png)\n\n  ![make Result](http://i.imgur.com/eGIjEdn.png)\n\n[make]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:make_makeprg\n\nConsider the full signature of a `:make` call as\n\n    :[silent] make[!] [COFFEE-OPTIONS]...\n\nBy default `:make` shows all compiler output and jumps to the first line\nreported as an error. Compiler output can be hidden with a leading `:silent`:\n\n    :silent make\n\nLine-jumping can be turned off by adding a bang:\n\n    :make!\n\n`COFFEE-OPTIONS` given to `:make` are passed along to `coffee` (see also\n[`coffee_make_options`](#coffee_make_options)):\n\n    :make --bare --output /some/dir\n\nSee the [full table of options](http://coffeescript.org/#usage) for a\nlist of all the options that `coffee` recognizes.\n\n*Configuration*: [`coffee_compiler`](#coffee_compiler),\n[`coffee_make_options`](#coffee_make_options)\n\n#### The quickfix window\n\nCompiler errors are added to the [quickfix] list by `:make`, but the quickfix\nwindow isn't automatically shown. The [`:cwindow`][cwindow] command will pop up\nthe quickfix window if there are any errors:\n\n    :make\n    :cwindow\n\nThis is usually the desired behavior, so you may want to add an autocmd to your\nvimrc to do this automatically:\n\n    autocmd QuickFixCmdPost * nested cwindow | redraw!\n\nThe `redraw!` command is needed to fix a redrawing quirk in terminal vim, but\ncan removed for gVim.\n\n[quickfix]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix\n[cwindow]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:cwindow\n\n#### Recompile on write\n\nTo recompile a file when it's written, add a `BufWritePost` autocmd to your\nvimrc:\n\n    autocmd BufWritePost *.coffee silent make!\n\n#### Cake and Cakefiles\n\nA `cake` compiler is also available with the call\n\n    :compiler cake\n\nYou can then use `:make` as above to run your Cakefile and capture any `coffee`\nerrors:\n\n    :silent make build\n\nIt runs within the current directory, so make sure you're in the directory of\nyour Cakefile before calling it.\n\n*Configuration*: [`coffee_cake`](#coffee_cake),\n[`coffee_cake_options`](#coffee_cake_options)\n\n## CoffeeCompile: Compile CoffeeScript Snippets\n\nCoffeeCompile shows how the current file or a snippet of CoffeeScript is\ncompiled to JavaScript.\n\n    :[RANGE] CoffeeCompile [vert[ical]] [WINDOW-SIZE]\n\nCalling `:CoffeeCompile` without a range compiles the whole file:\n\n  ![CoffeeCompile](http://i.imgur.com/0zFG0l0.png)\n\n  ![CoffeeCompile Result](http://i.imgur.com/bpiAxaa.png)\n\nCalling it with a range, like in visual mode, compiles only the selected snippet\nof CoffeeScript:\n\n  ![CoffeeCompile Snippet](http://i.imgur.com/x3OT3Ay.png)\n\n  ![Compiled Snippet](http://i.imgur.com/J02j4T8.png)\n\nEach file gets its own CoffeeCompile buffer, and the same buffer is used for all\nfuture calls of `:CoffeeCompile` on that file. It can be quickly closed by\nhitting `q` in normal mode.\n\nUsing `vert` opens the CoffeeCompile buffer vertically instead of horizontally\n(see also [`coffee_compile_vert`](#coffee_compile_vert)):\n\n    :CoffeeCompile vert\n\nBy default the CoffeeCompile buffer splits the source buffer in half, but this\ncan be overridden by passing in a `WINDOW-SIZE`:\n\n    :CoffeeCompile 4\n\n*Configuration*: [`coffee_compiler`](#coffee_compiler`),\n[`coffee_compile_vert`](#coffee_compile_vert)\n\n#### Quick syntax checking\n\nIf compiling a snippet results in a compiler error, CoffeeCompile adds that\nerror to the [quickfix] list.\n\n[quickfix]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix\n\n  ![Syntax Checking](http://i.imgur.com/RC8accF.png)\n\n  ![Syntax Checking Result](http://i.imgur.com/gi1ON75.png)\n\nYou can use this to quickly check the syntax of a snippet.\n\n## CoffeeWatch: Live Preview Compiling\n\nCoffeeWatch emulates using the Try CoffeeScript preview box on the [CoffeeScript\nhomepage][CoffeeScript].\n\n  ![CoffeeWatch](http://i.imgur.com/TRHdIMG.png)\n\n  ![CoffeeWatch Result](http://i.imgur.com/rJbOeeS.png)\n\nCoffeeWatch takes the same options as CoffeeCompile:\n\n    :CoffeeWatch [vert[ical]] [WINDOW-SIZE]\n\nAfter a source buffer is watched, leaving insert mode or saving the file fires\noff a recompile of the CoffeeScript:\n\n  ![Insert Mode](http://i.imgur.com/SBVcf4k.png)\n\n  ![Recompile](http://i.imgur.com/pbPMog7.png)\n\nYou can force recompilation by calling `:CoffeeWatch`.\n\nTo get synchronized scrolling of the source buffer and CoffeeWatch buffer, set\n[`'scrollbind'`](http://vimdoc.sourceforge.net/htmldoc/options.html#'scrollbind')\non each:\n\n    :setl scrollbind\n\n*Configuration*: [`coffee_compiler`](#coffee_compiler),\n[`coffee_watch_vert`](#coffee_watch_vert)\n\n## CoffeeRun: Run CoffeeScript Snippets\n\nCoffeeRun compiles the current file or selected snippet and runs the resulting\nJavaScript.\n\n  ![CoffeeRun](http://i.imgur.com/YSkHUuQ.png)\n\n  ![CoffeeRun Output](http://i.imgur.com/wZQbggN.png)\n\nThe command has two forms:\n\n    :CoffeeRun [PROGRAM-OPTIONS]...\n\nThis form applies when no `RANGE` is given or when the given range is `1,$`\n(first line to last line). It allows passing `PROGRAM-OPTIONS` to your compiled\nprogram. The filename is passed directly to `coffee` so you must save the file\nfor your changes to take effect.\n\n    :RANGE CoffeeRun [COFFEE-OPTIONS]...\n\nThis form applies with all other ranges. It compiles and runs the lines within\nthe given `RANGE` and any extra `COFFEE-OPTIONS` are passed to `coffee`.\n\n*Configuration*: [`coffee_compiler`](#coffee_compiler),\n[`coffee_run_vert`](#coffee_run_vert)\n\n## CoffeeLint: Lint your CoffeeScript\n\nCoffeeLint runs [coffeelint](http://www.coffeelint.org/) (version 1.4.0 or later\nrequired) on the current file and adds any issues to the [quickfix] list.\n\n  ![CoffeeLint](http://i.imgur.com/UN8Nr5N.png)\n\n  ![CoffeeLint Result](http://i.imgur.com/9hSIj3W.png)\n\n    :[RANGE] CoffeeLint[!] [COFFEELINT-OPTIONS]... [ | cwindow]\n\nIf a `RANGE` is given, only those lines are piped to `coffeelint`. Options given\nin `COFFEELINT-OPTIONS` are passed to `coffeelint` (see also\n[`coffee_lint_options`](#coffee_lint_options)):\n\n    :CoffeeLint -f lint.json\n\nIt behaves very similar to `:make`, described [above](#compile-to-javascript).\n\n    :CoffeeLint! | cwindow\n\n*Configuration*: [`coffee_linter`](#coffee_linter),\n[`coffee_lint_options`](#coffee_lint_options)\n\n## Literate CoffeeScript\n\nLiterate CoffeeScript syntax and indent support is now built in! The `Coffee`\ncommands detect when they're running on a litcoffee file and pass the\n`--literate` flag to their respective tools.\n\nLiterate CoffeeScript syntax and indent support was written by @mintplant\n(Michael Smith). A standalone repo\n[exists](https://github.com/jwhitley/vim-literate-coffeescript), but you'll\nneed to copy the `ftplugin/litcoffee.vim` file or set up an autocmd to get the\n`Coffee` commands to be automatically loaded for litcoffee files.\n\n## CoffeeScript in HTML\n\nCoffeeScript is highlighted and indented within\n\n```html\n\u003cscript type=\"text/coffeescript\"\u003e\n\u003c/script\u003e\n```\n\nblocks in html files.\n\n## CoffeeScript in Haml\n\nCoffeeScript is highlighted within the `:coffeescript` filter in haml files:\n\n```haml\n:coffeescript\n  console.log \"hullo\"\n```\n\nAt this time, coffee indenting doesn't work in these blocks.\n\n## Custom Autocmds\n\nYou can [define commands][autocmd-explain] to be ran automatically on these\ncustom events.\n\nIn all cases, the name of the command running the event (`CoffeeCompile`,\n`CoffeeWatch`, or `CoffeeRun`) is matched by the [`{pat}`][autocmd] argument.\nYou can match all commands with a `*` or only specific commands by separating\nthem with a comma: `CoffeeCompile,CoffeeWatch`.\n\n[autocmd-explain]: http://vimdoc.sourceforge.net/htmldoc/usr_40.html#40.3\n[autocmd]: http://vimdoc.sourceforge.net/htmldoc/autocmd.html#:autocmd\n\n#### CoffeeBufNew\n\nCoffeeBufNew is ran when a new scratch buffer is created. It's called from the\nnew buffer, so it can be used to do additional set up.\n\n```vim\naugroup CoffeeBufNew\n  autocmd User * set wrap\naugroup END\n```\n\n*Used By*: CoffeeCompile, CoffeeWatch, CoffeeRun\n\n#### CoffeeBufUpdate\n\nCoffeeBufUpdate is ran when a scratch buffer is updated with output from\n`coffee`. It's called from the scratch buffer, so it can be used to alter the\ncompiled output.\n\n```vim\n\" Switch back to the source buffer after updating.\naugroup CoffeeBufUpdate\n  autocmd User CoffeeCompile,CoffeeRun exec bufwinnr(b:coffee_src_buf) 'wincmd w'\naugroup END\n```\n\nFor example, to strip off the \"Generated by\" comment on the first line, put this\nin your vimrc:\n\n```vim\nfunction! s:RemoveGeneratedBy()\n  \" If there was an error compiling, there's no comment to remove.\n  if v:shell_error\n    return\n  endif\n\n  \" Save cursor position.\n  let pos = getpos('.')\n\n  \" Remove first line.\n  set modifiable\n  1 delete _\n  set nomodifiable\n\n  \" Restore cursor position.\n  call setpos('.', pos)\nendfunction\n\naugroup CoffeeBufUpdate\n  autocmd User CoffeeCompile,CoffeeWatch call s:RemoveGeneratedBy()\naugroup END\n```\n\n*Used By*: CoffeeCompile, CoffeeWatch, CoffeeRun\n\n## Configuration Variables\n\nThis is the full list of configuration variables available, with example\nsettings and default values. Use these in your vimrc to control the default\nbehavior.\n\n#### coffee\\_indent\\_keep\\_current\n\nBy default, the indent function matches the indent of the previous line if it\ndoesn't find a reason to indent or outdent. To change this behavior so it\ninstead keeps the [current indent of the cursor][98], use\n\n    let coffee_indent_keep_current = 1\n\n[98]: https://github.com/kchmck/vim-coffee-script/pull/98\n\n*Default*: `unlet coffee_indent_keep_current`\n\nNote that if you change this after a coffee file has been loaded, you'll have to\nreload the indent script for the change to take effect:\n\n    unlet b:did_indent | runtime indent/coffee.vim\n\n#### coffee\\_compiler\n\nPath to the `coffee` executable used by the `Coffee` commands:\n\n    let coffee_compiler = '/usr/bin/coffee'\n\n*Default*: `'coffee'` (search `$PATH` for executable)\n\n#### coffee\\_make\\_options\n\nOptions to pass to `coffee` with `:make`:\n\n    let coffee_make_options = '--bare'\n\n*Default*: `''` (nothing)\n\nNote that `coffee_make_options` is embedded into `'makeprg'`, so `:compiler\ncoffee` must be ran after changing `coffee_make_options` for the changes to take\neffect.\n\n#### coffee\\_cake\n\nPath to the `cake` executable:\n\n    let coffee_cake = '/opt/bin/cake'\n\n*Default*: `'cake'` (search `$PATH` for executable)\n\n#### coffee\\_cake\\_options\n\nOptions to pass to `cake` with `:make`:\n\n    let coffee_cake_options = 'build'\n\n*Default*: `''` (nothing)\n\n#### coffee\\_linter\n\nPath to the `coffeelint` executable:\n\n    let coffee_linter = '/opt/bin/coffeelint'\n\n*Default*: `'coffeelint'` (search `$PATH` for executable)\n\n#### coffee\\_lint\\_options\n\nOptions to pass to `coffeelint`:\n\n    let coffee_lint_options = '-f lint.json'\n\n*Default*: `''` (nothing)\n\n#### coffee\\_compile\\_vert\n\nOpen the CoffeeCompile buffer with a vertical split instead of a horizontal\none:\n\n    let coffee_compile_vert = 1\n\n*Default*: `unlet coffee_compile_vert`\n\n#### coffee\\_watch\\_vert\n\nOpen the CoffeeWatch buffer with a vertical split instead of a horizontal\none:\n\n    let coffee_watch_vert = 1\n\n*Default*: `unlet coffee_watch_vert`\n\n#### coffee\\_run\\_vert\n\nOpen the CoffeeRun buffer with a vertical split instead of a horizontal\none:\n\n    let coffee_run_vert = 1\n\n*Default*: `unlet coffee_run_vert`\n\n## Configure Syntax Highlighting\n\nAdd these lines to your vimrc to disable the relevant syntax group.\n\n#### Disable trailing whitespace error\n\nTrailing whitespace is highlighted as an error by default. This can be disabled\nwith:\n\n    hi link coffeeSpaceError NONE\n\n#### Disable trailing semicolon error\n\nTrailing semicolons are considered an error (for help transitioning from\nJavaScript.) This can be disabled with:\n\n    hi link coffeeSemicolonError NONE\n\n#### Disable reserved words error\n\nReserved words like `function` and `var` are highlighted as an error where\nthey're not allowed in CoffeeScript. This can be disabled with:\n\n    hi link coffeeReservedError NONE\n\n## Tune Vim for CoffeeScript\n\nChanging these core settings can make vim more CoffeeScript friendly.\n\n#### Fold by indentation\n\nFolding by indentation works well for CoffeeScript functions and classes:\n\n  ![Folding](http://i.imgur.com/gDgUBdO.png)\n\nTo fold by indentation in CoffeeScript files, add this line to your vimrc:\n\n    autocmd BufNewFile,BufReadPost *.coffee setl foldmethod=indent nofoldenable\n\nWith this, folding is disabled by default but can be quickly toggled per-file\nby hitting `zi`. To enable folding by default, remove `nofoldenable`:\n\n    autocmd BufNewFile,BufReadPost *.coffee setl foldmethod=indent\n\n#### Two-space indentation\n\nTo get standard two-space indentation in CoffeeScript files, add this line to\nyour vimrc:\n\n    autocmd BufNewFile,BufReadPost *.coffee setl shiftwidth=2 expandtab\n","funding_links":[],"categories":["Rails development","Included modes"],"sub_categories":["Code completion","Install for multiple users"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkchmck%2Fvim-coffee-script","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkchmck%2Fvim-coffee-script","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkchmck%2Fvim-coffee-script/lists"}