Permalink
Browse files

Replace coffee_make_compiler with coffee_compiler

coffee_make_compiler is deprecated already! But the new option is also used by
CoffeeCompile.

Now an error is shown if the compiler executable doesn't exist.
  • Loading branch information...
1 parent 41fb408 commit e7e5d0158199dfc05819c9b60d869d0e6e3916de @kchmck committed Feb 15, 2012
Showing with 34 additions and 14 deletions.
  1. +5 −4 Readme.md
  2. +12 −4 compiler/coffee.vim
  3. +5 −4 doc/coffee-script.txt
  4. +12 −2 ftplugin/coffee.vim
View
@@ -1,5 +1,5 @@
This project adds [CoffeeScript] support to the vim editor. It handles syntax,
-indenting, and compiling. Also included is an [eco] syntax and support for
+indenting, compiling, and more. Also included is an [eco] syntax and support for
CoffeeScript in Haml and HTML.
![Screenshot](http://i.imgur.com/BV29H.png)
@@ -118,10 +118,11 @@ variable along to the compiler. You can use this to set default options:
#### Path to compiler
-To change the compiler used by `CoffeeMake`, set `coffee_make_compiler` to the
-full path of an executable or the filename of one in your `$PATH`:
+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`:
- let coffee_make_compiler = '/usr/bin/coffee'
+ let coffee_compiler = '/usr/bin/coffee'
### CoffeeCompile: Compile Snippets of CoffeeScript
View
@@ -12,8 +12,16 @@ let current_compiler = 'coffee'
let s:pat = '^' . current_compiler
" Path to CoffeeScript compiler
-if !exists('coffee_make_compiler')
- let coffee_make_compiler = 'coffee'
+if !exists('coffee_compiler')
+ let coffee_compiler = 'coffee'
+endif
+
+if exists('coffee_make_compiler')
+ echohl WarningMsg
+ echom '`coffee_make_compiler` is deprecated: use `coffee_compiler` instead'
+ echohl None
+
+ let coffee_compiler = coffee_make_compiler
endif
" Extra options passed to CoffeeMake
@@ -24,8 +32,8 @@ endif
" Get a `makeprg` for the current filename. This is needed to support filenames
" with spaces and quotes, but also not break generic `make`.
function! s:GetMakePrg()
- return g:coffee_make_compiler . ' -c ' . g:coffee_make_options . ' $* '
- \ . fnameescape(expand('%'))
+ 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.
View
@@ -56,7 +56,7 @@ COMMANDS *coffee-script-commands*
|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 added.
+ be considered.
*:CoffeeRun*
:[range]CoffeeRun Compiles the file or [range] and runs the resulting
@@ -68,10 +68,11 @@ You can configure plugin behavior using global variables and syntax commands
in your |vimrc|.
Global Settings~
- *g:coffee_make_compiler*
-Set the path to the compiler used by |CoffeeMake| (by default it's {coffee})
+ *g:coffee_compiler*
+Set the path to the compiler used by |CoffeeMake| and |CoffeeCompile| (by
+default it's {coffee}.)
>
- let coffee_make_compiler = '/usr/bin/coffee'
+ let coffee_compiler = '/usr/bin/coffee'
<
*g:coffee_make_options*
Set default options |CoffeeMake| should pass to the compiler.
View
@@ -19,6 +19,11 @@ if !len(&l:makeprg)
compiler coffee
endif
+" Check here too in case the compiler above isn't loaded.
+if !exists('coffee_compiler')
+ let coffee_compiler = 'coffee'
+endif
+
" Options passed to CoffeeLint
if !exists('coffee_lint_options')
let coffee_lint_options = ''
@@ -54,11 +59,11 @@ function! s:CoffeeCompileUpdate(startline, endline)
endif
" Compile input.
- let output = system('coffee -scb 2>&1', input)
+ let output = system(g:coffee_compiler . ' -scb 2>&1', input)
" Be sure we're in the CoffeeCompile buffer before overwriting.
if exists('b:coffee_compile_buf')
- echoerr 'Something is very wrong'
+ echoerr 'CoffeeCompile buffers are messed up'
return
endif
@@ -89,6 +94,11 @@ endfunction
" to prevent the cursor from being moved (and its position saved) before the
" function is called.
function! s:CoffeeCompile(startline, endline, args)
+ if !executable(g:coffee_compiler)
+ echoerr "Can't find CoffeeScript compiler `" . g:coffee_compiler . "`"
+ return
+ endif
+
" If in the CoffeeCompile buffer, switch back to the source buffer and
" continue.
if !exists('b:coffee_compile_buf')

0 comments on commit e7e5d01

Please sign in to comment.