Created
April 2, 2012 14:07
-
-
Save davidmfoley/2283673 to your computer and use it in GitHub Desktop.
coffeelint/vim quickfix integration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Get coffeelint errors in the vim quickfix menu | |
" requires coffeelint to be installed and in the path | |
" http://www.coffeelint.org/ | |
" lint the current file | |
function! CoffeeLintFile() | |
let current = fnamemodify(expand("%"), ':p') | |
call CoffeeLintAnalyze(current) | |
endfunction | |
" lint the full project | |
function! CoffeeLintAll() | |
call CoffeeLintAnalyze('**/*.coffee') | |
endfunction | |
function! CoffeeLintAnalyze( path ) | |
" run coffeelint, reformat output, redirect to a file | |
exec ":silent :!coffeelint " . a:path . " 2>&1 | awk -F'\\#|( : )' '{printf( \"\\%s:\\%s:\\%s\\n\", $1, $2,$NF)}' > ~/.coffeelint-results" | |
" tell vim to parse it into quickfix window | |
" (colon-separated) | |
exec ':cfile ~/.coffeelint-results' | |
endfunction | |
" this tells vim how to interpret our file format | |
set errorformat+=%f:%l:%m | |
" These are my shortcuts, you will probably want your own | |
map <leader>cx :call CoffeeLintFile()<cr> | |
map <leader>cX :call CoffeeLintAll()<cr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment