Browse files

Add coffee_linter option

Also check if the coffeelint executable exists
  • Loading branch information...
1 parent e7e5d01 commit 1b5a4e8dcaafe77b1cb5cc8c019c9e4717d18196 @kchmck committed Feb 15, 2012
Showing with 31 additions and 5 deletions.
  1. +12 −1 Readme.md
  2. +7 −2 doc/coffee-script.txt
  3. +12 −2 ftplugin/coffee.vim
View
13 Readme.md
@@ -124,6 +124,8 @@ in your `$PATH`:
let coffee_compiler = '/usr/bin/coffee'
+This option is set to `coffee` by default.
+
### CoffeeCompile: Compile Snippets of CoffeeScript
The `CoffeeCompile` command shows how the current file or a snippet of
@@ -201,10 +203,19 @@ Use it like `CoffeeMake`.
#### Default coffeelint options
-Options in `coffee_lint_options` are passed along to coffeelint.
+Options in `coffee_lint_options` are passed along to `coffeelint`:
let coffee_lint_options = '-f lint.json'
+#### Path to `coffeelint`
+
+Use the `coffee_linter` option to set a different path to the `coffeelint`
+executable:
+
+ let coffee_linter = '/usr/bin/coffeelint'
+
+This option is set to `coffeelint` by default.
+
### CoffeeRun: Run some CoffeeScript
The `CoffeeRun` command compiles the current file or selected snippet and runs
View
9 doc/coffee-script.txt
@@ -69,8 +69,8 @@ in your |vimrc|.
Global Settings~
*g:coffee_compiler*
-Set the path to the compiler used by |CoffeeMake| and |CoffeeCompile| (by
-default it's {coffee}.)
+Set the path to the compiler used by |CoffeeMake| and |CoffeeCompile| (it's
+{coffee} by default.)
>
let coffee_compiler = '/usr/bin/coffee'
<
@@ -84,6 +84,11 @@ 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}.
>
View
14 ftplugin/coffee.vim
@@ -24,6 +24,11 @@ if !exists('coffee_compiler')
let coffee_compiler = 'coffee'
endif
+" Path to coffeelint executable
+if !exists('coffee_linter')
+ let coffee_linter = 'coffeelint'
+endif
+
" Options passed to CoffeeLint
if !exists('coffee_lint_options')
let coffee_lint_options = ''
@@ -199,15 +204,20 @@ endfunction
" Run coffeelint on a file, and add any errors between @startline and @endline
" to the quickfix list.
function! s:CoffeeLint(startline, endline, bang, args)
+ if !executable(g:coffee_linter)
+ echoerr "Can't find CoffeeScript linter `" . g:coffee_linter . "`"
+ return
+ endif
+
let filename = expand('%')
if !len(filename)
echoerr 'CoffeeLint must be ran on a saved file'
return
endif
- let lines = split(system('coffeelint ' . g:coffee_lint_options . ' ' . a:args
- \ . ' ' . filename . ' 2>&1'), '\n')
+ let lines = split(system(g:coffee_linter . ' ' . g:coffee_lint_options . ' ' .
+ \ a:args . ' ' . filename . ' 2>&1'), '\n')
let qflist = []
for line in lines

0 comments on commit 1b5a4e8

Please sign in to comment.