2013-09-16 20:02:37 -04:00
|
|
|
" Erlang compiler file
|
|
|
|
" Language: Erlang
|
|
|
|
" Maintainer: Pawel 'kTT' Salata <rockplayer.pl@gmail.com>
|
|
|
|
" URL: http://ktototaki.info
|
2013-09-12 11:32:53 -04:00
|
|
|
|
2013-09-16 20:02:37 -04:00
|
|
|
if exists("current_compiler")
|
|
|
|
finish
|
2013-09-12 11:32:53 -04:00
|
|
|
endif
|
2013-09-16 20:02:37 -04:00
|
|
|
let current_compiler = "erlang"
|
2013-09-12 11:32:53 -04:00
|
|
|
|
|
|
|
if exists(":CompilerSet") != 2
|
2013-09-16 20:02:37 -04:00
|
|
|
command -nargs=* CompilerSet setlocal <args>
|
2013-09-12 11:32:53 -04:00
|
|
|
endif
|
|
|
|
|
2013-09-16 20:02:37 -04:00
|
|
|
if !exists('g:erlangCheckFile')
|
|
|
|
let g:erlangCheckFile = "~/.vim/compiler/erlang_check_file.erl"
|
2013-09-12 11:32:53 -04:00
|
|
|
endif
|
|
|
|
|
2013-09-16 20:02:37 -04:00
|
|
|
if !exists('g:erlangHighlightErrors')
|
|
|
|
let g:erlangHighlightErrors = 0
|
2013-09-12 11:32:53 -04:00
|
|
|
endif
|
|
|
|
|
2013-09-16 20:02:37 -04:00
|
|
|
let b:error_list = {}
|
|
|
|
let b:is_showing_msg = 0
|
2013-09-12 11:32:53 -04:00
|
|
|
|
2013-09-16 20:02:37 -04:00
|
|
|
function! HighlightErlangErrors()
|
|
|
|
if match(getline(1), "#!.*escript") != -1
|
|
|
|
setlocal makeprg=escript\ -s\ %
|
|
|
|
else
|
|
|
|
execute "setlocal makeprg=" . g:erlangCheckFile . "\\ \%"
|
|
|
|
endif
|
|
|
|
silent make!
|
|
|
|
call s:clear_matches()
|
|
|
|
for error in getqflist()
|
|
|
|
let item = {}
|
|
|
|
let item['lnum'] = error.lnum
|
|
|
|
let item['msg'] = error.text
|
|
|
|
let b:error_list[error.lnum] = item
|
|
|
|
call matchadd('SpellBad', "\\%" . error.lnum . "l")
|
|
|
|
endfor
|
|
|
|
if len(getqflist())
|
|
|
|
redraw!
|
|
|
|
endif
|
|
|
|
call s:show_msg()
|
|
|
|
setlocal makeprg=erlc\ %
|
2013-09-12 11:32:53 -04:00
|
|
|
endfunction
|
|
|
|
|
2013-09-16 20:02:37 -04:00
|
|
|
function! s:show_msg()
|
|
|
|
let pos = getpos(".")
|
|
|
|
if has_key(b:error_list, pos[1])
|
|
|
|
let item = get(b:error_list, pos[1])
|
|
|
|
echo item.msg
|
|
|
|
let b:is_showing_msg = 1
|
|
|
|
else
|
|
|
|
if exists("b:is_showing_msg") && b:is_showing_msg == 1
|
|
|
|
echo
|
|
|
|
let b:is_showing_msg = 0
|
|
|
|
endif
|
|
|
|
endif
|
2013-09-12 11:32:53 -04:00
|
|
|
endf
|
|
|
|
|
2013-09-16 20:02:37 -04:00
|
|
|
function! s:clear_matches()
|
|
|
|
call clearmatches()
|
|
|
|
let b:error_list = {}
|
|
|
|
if exists("b:is_showing_msg") && b:is_showing_msg == 1
|
|
|
|
echo
|
|
|
|
let b:is_showing_msg = 0
|
|
|
|
endif
|
2013-09-12 11:32:53 -04:00
|
|
|
endfunction
|
|
|
|
|
2013-09-16 20:02:37 -04:00
|
|
|
CompilerSet makeprg=erlc\ %
|
|
|
|
CompilerSet errorformat=%f:%l:\ %tarning:\ %m,%E%f:%l:\ %m
|
2013-09-12 11:32:53 -04:00
|
|
|
|
2013-09-16 20:02:37 -04:00
|
|
|
if g:erlangHighlightErrors
|
|
|
|
autocmd BufLeave *.erl call s:clear_matches()
|
|
|
|
autocmd BufEnter *.erl call s:clear_matches()
|
|
|
|
autocmd BufWritePost *.erl call HighlightErlangErrors()
|
|
|
|
autocmd CursorHold *.erl call s:show_msg()
|
|
|
|
autocmd CursorMoved *.erl call s:show_msg()
|
2013-09-12 11:32:53 -04:00
|
|
|
endif
|