Permalink
Browse files

coffescript

  • Loading branch information...
1 parent 718589d commit a6f801be02de738f8b4e03f169222c4698dddeea @creaktive committed Jan 18, 2013
Showing with 1,179 additions and 0 deletions.
  1. +9 −0 after/syntax/haml.vim
  2. +11 −0 after/syntax/html.vim
  3. +82 −0 compiler/coffee.vim
  4. +143 −0 doc/coffee-script.txt
  5. +19 −0 doc/tags
  6. +17 −0 ftdetect/coffee.vim
  7. +1 −0 ftdetect/eco.vim
  8. +263 −0 ftplugin/coffee.vim
  9. +351 −0 indent/coffee.vim
  10. +221 −0 syntax/coffee.vim
  11. +62 −0 syntax/eco.vim
@@ -0,0 +1,9 @@
+" Language: CoffeeScript
+" Maintainer: Sven Felix Oberquelle <Svelix.Github@gmail.com>
+" URL: http://github.com/kchmck/vim-coffee-script
+" License: WTFPL
+
+" Inherit coffee from html so coffeeComment isn't redefined and given higher
+" priority than hamlInterpolation.
+syn cluster hamlCoffeescript contains=@htmlCoffeeScript
+syn region hamlCoffeescriptFilter matchgroup=hamlFilter start="^\z(\s*\):coffee\z(script\)*\s*$" end="^\%(\z1 \| *$\)\@!" contains=@hamlCoffeeScript,hamlInterpolation keepend
View
@@ -0,0 +1,11 @@
+" Language: CoffeeScript
+" Maintainer: Mick Koch <kchmck@gmail.com>
+" URL: http://github.com/kchmck/vim-coffee-script
+" License: WTFPL
+
+" Syntax highlighting for text/coffeescript script tags
+syn include @htmlCoffeeScript syntax/coffee.vim
+syn region coffeeScript start=+<script [^>]*type *=[^>]*text/coffeescript[^>]*>+
+\ end=+</script>+me=s-1 keepend
+\ contains=@htmlCoffeeScript,htmlScriptTag,@htmlPreproc
+\ containedin=htmlHead
View
@@ -0,0 +1,82 @@
+" Language: CoffeeScript
+" Maintainer: Mick Koch <kchmck@gmail.com>
+" URL: http://github.com/kchmck/vim-coffee-script
+" License: WTFPL
+
+" All this is needed to support compiling filenames with spaces, quotes, and
+" such. The filename is escaped and embedded into the `makeprg` setting.
+"
+" Because of this, `makeprg` must be updated on every file rename. And because
+" of that, `CompilerSet` can't be used because it doesn't exist when the
+" rename autocmd is ran. So, we have to do some checks to see whether `compiler`
+" was called locally or globally, and respect that in the rest of the script.
+
+if exists('current_compiler')
+ finish
+else
+ let current_compiler = 'coffee'
+endif
+
+" Pattern to check if coffee is the compiler
+let s:pat = '^' . current_compiler
+
+" Path to CoffeeScript compiler
+if !exists('coffee_compiler')
+ let coffee_compiler = 'coffee'
+endif
+
+" Extra options passed to CoffeeMake
+if !exists('coffee_make_options')
+ let coffee_make_options = ''
+endif
+
+" Get a `makeprg` for the current filename.
+function! s:GetMakePrg()
+ return g:coffee_compiler . ' -c ' . g:coffee_make_options . ' $* '
+ \ . fnameescape(expand('%'))
+endfunction
+
+" Set `makeprg` and return 1 if coffee is still the compiler, else return 0.
+function! s:SetMakePrg()
+ if &l:makeprg =~ s:pat
+ let &l:makeprg = s:GetMakePrg()
+ elseif &g:makeprg =~ s:pat
+ let &g:makeprg = s:GetMakePrg()
+ else
+ return 0
+ endif
+
+ return 1
+endfunction
+
+" Set a dummy compiler so we can check whether to set locally or globally.
+CompilerSet makeprg=coffee
+call s:SetMakePrg()
+
+CompilerSet errorformat=Error:\ In\ %f\\,\ %m\ on\ line\ %l,
+ \Error:\ In\ %f\\,\ Parse\ error\ on\ line\ %l:\ %m,
+ \SyntaxError:\ In\ %f\\,\ %m,
+ \%-G%.%#
+
+" Compile the current file.
+command! -bang -bar -nargs=* CoffeeMake make<bang> <args>
+
+" Set `makeprg` on rename since we embed the filename in the setting.
+augroup CoffeeUpdateMakePrg
+ autocmd!
+
+ " Update `makeprg` if coffee is still the compiler, else stop running this
+ " function.
+ function! s:UpdateMakePrg()
+ if !s:SetMakePrg()
+ autocmd! CoffeeUpdateMakePrg
+ endif
+ endfunction
+
+ " Set autocmd locally if compiler was set locally.
+ if &l:makeprg =~ s:pat
+ autocmd BufFilePost,BufWritePost <buffer> call s:UpdateMakePrg()
+ else
+ autocmd BufFilePost,BufWritePost call s:UpdateMakePrg()
+ endif
+augroup END
View
@@ -0,0 +1,143 @@
+*coffee-script.txt* For Vim version 7.3
+
+=============================================================================
+Author: Mick Koch <kchmck@gmail.com> *coffee-script-author*
+License: WTFPL (see |coffee-script-license|)
+=============================================================================
+
+CONTENTS *coffee-script-contents*
+
+|coffee-script-introduction| Introduction and Feature Summary
+|coffee-script-commands| Commands
+|coffee-script-settings| Settings
+|compiler-coffee-script| Compiler
+
+{Vi does not have any of this}
+
+=============================================================================
+
+INTRODUCTION *coffee-script*
+ *coffee-script-introduction*
+
+This plugin adds support for CoffeeScript syntax, indenting, and compiling.
+Also included is an eco syntax and support for CoffeeScript in Haml and HTML.
+
+COMMANDS *coffee-script-commands*
+
+ *:CoffeeMake*
+:CoffeeMake[!] {opts} Wrapper around |:make| that also passes options in
+ |g:coffee_make_options| to the compiler. Use |:silent|
+ to hide compiler output. See |:make| for more
+ information about [!] and other helpful commands.
+
+ *:CoffeeCompile*
+:[range]CoffeeCompile [vertical] [{win-size}]
+ Shows how the current file or [range] is compiled
+ to JavaScript. [vertical] (or vert) splits the
+ compile buffer vertically instead of horizontally, and
+ {win-size} sets the initial size of the buffer. It can
+ be closed quickly with the "q" key.
+
+:CoffeeCompile {watch} [vertical] [{win-size}]
+ The watch mode of :CoffeeCompile emulates the "Try
+ CoffeeScript" live preview on the CoffeeScript web
+ site. After making changes to the source file,
+ exiting insert mode will cause the preview buffer to
+ update automatically. {watch} should be given as
+ "watch" or "unwatch," where the latter will stop the
+ automatic updating. [vertical] is recommended, and
+ 'scrollbind' is useful.
+
+ *:CoffeeLint*
+:[range]CoffeeLint[!] {opts}
+ Run {coffeelint} on the current file and add any
+ errors to the quickfix list. The first error is jumped
+ to if [!] isn't given. Options in
+ |g:coffee_lint_options| and {opts} are passed along to
+ {coffeelint}. Although the whole file is linted, if a
+ [range] is given, only errors within those lines will
+ be considered.
+
+ *:CoffeeRun*
+:[range]CoffeeRun Compiles the file or [range] and runs the resulting
+ JavaScript, displaying the output.
+
+SETTINGS *coffee-script-settings*
+
+You can configure plugin behavior using global variables and syntax commands
+in your |vimrc|.
+
+Global Settings~
+ *g:coffee_compiler*
+Set the path to the compiler used by |CoffeeMake| and |CoffeeCompile| (it's
+{coffee} by default.)
+>
+ let coffee_compiler = '/usr/bin/coffee'
+<
+ *g:coffee_make_options*
+Set default options |CoffeeMake| should pass to the compiler.
+>
+ let coffee_make_options = '--bare'
+<
+ *g:coffee_compile_vert*
+Split the CoffeeCompile buffer vertically by default.
+>
+ let coffee_compile_vert = 1
+<
+ *g:coffee_linter*
+Set the path to the {coffeelint} executable (it's {coffeelint} by default.)
+>
+ let coffee_linter = '/usr/bin/coffeelint'
+<
+ *g:coffee_lint_options*
+Set default options |CoffeeLint| should pass to {coffeelint}.
+>
+ let coffee_lint_options = '-f lint.json'
+<
+
+Syntax Highlighting~
+ *ft-coffee-script-syntax*
+Trailing whitespace is highlighted as an error by default. This can be
+disabled with:
+>
+ hi link coffeeSpaceError NONE
+
+Trailing semicolons are also considered an error (for help transitioning from
+JavaScript.) This can be disabled with:
+>
+ hi link coffeeSemicolonError NONE
+
+Reserved words like {function} and {var} are highlighted where they're not
+allowed in CoffeeScript. This can be disabled with:
+>
+ hi link coffeeReservedError NONE
+
+COMPILER *compiler-coffee-script*
+
+A CoffeeScript compiler is provided as a wrapper around {coffee} and can be
+loaded with;
+>
+ compiler coffee
+
+This is done automatically when a CoffeeScript file is opened if no other
+compiler is loaded.
+
+=============================================================================
+
+LICENSE *coffee-script-license*
+
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ Version 2, December 2004
+
+ Copyright (C) 2010 to 2012 Mick Koch <kchmck@gmail.com>
+
+ Everyone is permitted to copy and distribute verbatim or modified
+ copies of this license document, and changing it is allowed as long
+ as the name is changed.
+
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
+
+ vim:tw=78:ts=8:ft=help:norl:
View
@@ -86,6 +86,10 @@
:AckAdd ack.txt /*:AckAdd*
:AckFile ack.txt /*:AckFile*
:AckFromSearch ack.txt /*:AckFromSearch*
+:CoffeeCompile coffee-script.txt /*:CoffeeCompile*
+:CoffeeLint coffee-script.txt /*:CoffeeLint*
+:CoffeeMake coffee-script.txt /*:CoffeeMake*
+:CoffeeRun coffee-script.txt /*:CoffeeRun*
:CtrlP ctrlp.txt /*:CtrlP*
:CtrlPBookmarkDir ctrlp.txt /*:CtrlPBookmarkDir*
:CtrlPBookmarkDirAdd ctrlp.txt /*:CtrlPBookmarkDirAdd*
@@ -290,6 +294,15 @@ ack-author ack.txt /*ack-author*
ack-mappings ack.txt /*ack-mappings*
ack.txt ack.txt /*ack.txt*
before solarized.txt /*before*
+coffee-script coffee-script.txt /*coffee-script*
+coffee-script-author coffee-script.txt /*coffee-script-author*
+coffee-script-commands coffee-script.txt /*coffee-script-commands*
+coffee-script-contents coffee-script.txt /*coffee-script-contents*
+coffee-script-introduction coffee-script.txt /*coffee-script-introduction*
+coffee-script-license coffee-script.txt /*coffee-script-license*
+coffee-script-settings coffee-script.txt /*coffee-script-settings*
+coffee-script.txt coffee-script.txt /*coffee-script.txt*
+compiler-coffee-script coffee-script.txt /*compiler-coffee-script*
ctrlp-changelog ctrlp.txt /*ctrlp-changelog*
ctrlp-commands ctrlp.txt /*ctrlp-commands*
ctrlp-contents ctrlp.txt /*ctrlp-contents*
@@ -332,6 +345,7 @@ eregex-options eregex.txt /*eregex-options*
eregex-principle eregex.txt /*eregex-principle*
eregex-table eregex.txt /*eregex-table*
eregex.txt eregex.txt /*eregex.txt*
+ft-coffee-script-syntax coffee-script.txt /*ft-coffee-script-syntax*
fugitive fugitive.txt /*fugitive*
fugitive#statusline() fugitive.txt /*fugitive#statusline()*
fugitive-:Gblame fugitive.txt /*fugitive-:Gblame*
@@ -384,6 +398,11 @@ g:SuperTabMappingTabLiteral supertab.txt /*g:SuperTabMappingTabLiteral*
g:SuperTabNoCompleteAfter supertab.txt /*g:SuperTabNoCompleteAfter*
g:SuperTabNoCompleteBefore supertab.txt /*g:SuperTabNoCompleteBefore*
g:SuperTabRetainCompletionDuration supertab.txt /*g:SuperTabRetainCompletionDuration*
+g:coffee_compile_vert coffee-script.txt /*g:coffee_compile_vert*
+g:coffee_compiler coffee-script.txt /*g:coffee_compiler*
+g:coffee_lint_options coffee-script.txt /*g:coffee_lint_options*
+g:coffee_linter coffee-script.txt /*g:coffee_linter*
+g:coffee_make_options coffee-script.txt /*g:coffee_make_options*
g:ctrlp_dont_split ctrlp.txt /*g:ctrlp_dont_split*
g:ctrlp_dotfiles ctrlp.txt /*g:ctrlp_dotfiles*
g:ctrlp_highlight_match ctrlp.txt /*g:ctrlp_highlight_match*
View
@@ -0,0 +1,17 @@
+" Language: CoffeeScript
+" Maintainer: Mick Koch <kchmck@gmail.com>
+" URL: http://github.com/kchmck/vim-coffee-script
+" License: WTFPL
+
+autocmd BufNewFile,BufRead *.coffee set filetype=coffee
+autocmd BufNewFile,BufRead *Cakefile set filetype=coffee
+autocmd BufNewFile,BufRead *.coffeekup,*.ck set filetype=coffee
+autocmd BufNewFile,BufRead *._coffee set filetype=coffee
+
+function! s:DetectCoffee()
+ if getline(1) =~ '^#!.*\<coffee\>'
+ set filetype=coffee
+ endif
+endfunction
+
+autocmd BufNewFile,BufRead * call s:DetectCoffee()
View
@@ -0,0 +1 @@
+autocmd BufNewFile,BufRead *.eco set filetype=eco
Oops, something went wrong.

0 comments on commit a6f801b

Please sign in to comment.