" Vim Compiler File " Compiler: Hugs98 " Maintainer: Claus Reinke " Last Change: 15 March 2002 " quickfix settings first " if exists("current_compiler") finish endif let current_compiler = "hugs" " need to end hugs after attempted load if has("win32") setlocal makeprg=echo\ :q\ \\\|\ C:\\Programme\\Hugs98\\hugs\ -98\ % else setlocal makeprg=echo\ :q\ \\\|\ hugs\ -98\ % endif setlocal errorformat=%E%.%#ERROR\ \"%f\":%l\ -\ %m, \%E%.%#ERROR\ \"%f\"\ (line\ %l):\ %m, \%E%.%#ERROR%m, \%C\ ***\ %m, \%-G\|%m, \%-G_%m, \%-G\\s%#, \%-GReading%m, \%-GParsing%m, \%-GCompiling%m, \%-GHugs\ Session%m, \%-GType%m, \%-G%.%#Leaving\ Hugs%.%# " but hugs can do more for us.. " if exists("g:haskell_functions") finish endif let g:haskell_functions = "hugs" if has("win32") " let g:hugs_path = "C:\\Program\ Files\\Hugs98\\" let g:hugs_path = "" else let g:hugs_path = "" endif " load current file into Hugs98, " ask it about the type of current selection " insert type as line before current " map _t "ty:call Type()"tP map _T 0vf h"ty:call Type()"tP function Type() let hugs=g:hugs_path."hugs -98 " let hugsCmd="echo :t " if has("win32") let grep="find" let esc='<>%' else let grep="grep" let esc='$<>()' endif let output=system(hugsCmd.escape("(".@t.")",esc)." | ".hugs.expand("%")." | ".grep." \"::\"") if has("win32") let output=substitute(output,"[^>]*> ","","") endif let @t=output endfunction " load current file into Hugs98, " ask it to find definition of current selection " map _f "fy:call Find() function Find() let hugs=g:hugs_path."hugs -98 " let hugsCmd="echo :f " if has("win32") let editor="" let esc='<>%' else let editor="-E\"xterm -e vim +%d %s\" " let esc='$<>()' endif call system(hugsCmd.escape(@f,esc)." | ".hugs.editor.expand("%")) endfunction " load current file into Hugs98, " ask it to browse current (_b,_e) or imported module (_i) " insert resulting type infos as comment at top of file (_b) " or as module export header (_e) " or as module import list (_i) if has("win32") map _B :call Browse(""):call New()"bpdf>x map _b :call Browse("")1GO{- -} 1G"bpdf>x map _e :call Browse("")1G:call Module()1Gw~"bpdf>x:call Format() map _I 0/[A-Z]/"bye:call Browse(@b):call New()"bp map _i 0/[A-Z]/"bye:call Browse(@b)$a ( )"bP:call Format() else map _B :call Browse(""):call New()"bp map _b :call Browse("")1GO{- -} 1G"bp map _e :call Browse("")1G:call Module()1Gw~"bp:call Format() map _I 0/[A-Z]/"bye:call Browse(@b):call New()"bp map _i 0/[A-Z]/"bye:call Browse(@b)$a ( )"bP:call Format() endif function New() new set buftype=nowrite set bufhidden=delete set noswapfile endfunction function Browse(module) let hugs=g:hugs_path."hugs -98 " let hugsCmd="echo :browse ".a:module." " if has("win32") let grep="find" else let grep="grep" endif let @b=system(hugsCmd." | ".hugs.expand("%")." | ".grep." \"::\"") endfunction function Module() call append(0,"") call append(0," ) where") call append(0,"module ".fnamemodify(expand("%"),":t:r")." (") endfunction function Format() let m=0 let l0 = line(".") let l=l0 let m1=stridx(getline(l),"::") while m1 > -1 if m1 > m let m=m1 endif let l=l+1 let m1=stridx(getline(l),"::") endw let l=l0 let m1=stridx(getline(l),"::") while m1 > -1 if l>l0 let prefix = " ," else let prefix = " " endif call setline(l,prefix.substitute(getline(l),"::",X(m-m1," ")."-- ::","")) let l=l+1 let m1=stridx(getline(l),"::") endw endfunction function X(n,s) let r="" let c=a:n while c > 0 let r=r.a:s let c=c-1 endw return r endfunction