Sha256: 10d4d8acf9ced10e81cf1d4d3331e0c19487d7f7eb39eb9b880bca2ceffd0073

Contents?: true

Size: 1.91 KB

Versions: 14

Compression:

Stored size: 1.91 KB

Contents

" Language:    CoffeeScript
" Maintainer:  Mick Koch <kchmck@gmail.com>
" URL:         http://github.com/kchmck/vim-coffee-script
" License:     WTFPL

if exists('current_compiler')
  finish
endif

let current_compiler = 'coffee'
" Pattern to check if coffee is the compiler
let s:pat = '^' . current_compiler

" Extra options passed to CoffeeMake
if !exists("coffee_make_options")
  let coffee_make_options = ""
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 'coffee -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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
utils-0.0.67 lib/utils/config/vim/compiler/coffee.vim
utils-0.0.66 lib/utils/config/vim/compiler/coffee.vim
utils-0.0.65 lib/utils/config/vim/compiler/coffee.vim
utils-0.0.64 lib/utils/config/vim/compiler/coffee.vim
utils-0.0.63 lib/utils/config/vim/compiler/coffee.vim
utils-0.0.62 lib/utils/config/vim/compiler/coffee.vim
utils-0.0.61 lib/utils/config/vim/compiler/coffee.vim
utils-0.0.60 lib/utils/config/vim/compiler/coffee.vim
utils-0.0.59 lib/utils/config/vim/compiler/coffee.vim
utils-0.0.58 lib/utils/config/vim/compiler/coffee.vim
utils-0.0.57 lib/utils/config/vim/compiler/coffee.vim
utils-0.0.56 lib/utils/config/vim/compiler/coffee.vim
utils-0.0.55 lib/utils/config/vim/compiler/coffee.vim
utils-0.0.54 lib/utils/config/vim/compiler/coffee.vim