forked from kchmck/vim-coffee-script
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
253 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
" Language: Coco | ||
" Maintainer: satyr | ||
" URL: http://github.com/satyr/vim-coco | ||
" License: WTFPL | ||
|
||
if exists('current_compiler') | ||
finish | ||
endif | ||
|
||
let current_compiler = 'co' | ||
" Pattern to check if coco is the compiler | ||
let s:pat = '^' . current_compiler | ||
|
||
" 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 escape('coco -c' . g:coco_make_options | ||
\ . ' $* ' | ||
\ . fnameescape(expand('%')), | ||
\ ' ') | ||
endfunction | ||
|
||
exec 'CompilerSet makeprg=' . s:GetMakePrg() | ||
|
||
CompilerSet errorformat=%EFailed\ at:\ %f, | ||
\%CSyntaxError:\ %m\ on\ line\ %l, | ||
\%CError:\ Parse\ error\ on\ line\ %l:\ %m, | ||
\%C,%C\ %.%# | ||
|
||
" Compile the current file. | ||
command! -bang -bar -nargs=* CocoMake make<bang> <args> | ||
|
||
" Set `makeprg` on rename since we embed the filename in the setting. | ||
augroup CocoUpdateMakePrg | ||
autocmd! | ||
|
||
" Update `makeprg` if coco is still the compiler, else stop running this | ||
" function. | ||
function! s:UpdateMakePrg() | ||
if &l:makeprg =~ s:pat | ||
let &l:makeprg = s:GetMakePrg() | ||
elseif &g:makeprg =~ s:pat | ||
let &g:makeprg = s:GetMakePrg() | ||
else | ||
autocmd! CocoUpdateMakePrg | ||
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 |
This file contains 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