Skip to content
eagletmt edited this page Mar 2, 2012 · 13 revisions

Global variables

g:ghcmod_ghc_options

ghc-mod passes these options to GHC.
By default, ghcmod.vim doesn’t pass any GHC options.

Example: passing -idir1 and -idir2 to GHC

let g:ghcmod_ghc_options = ['-idir1', '-idir2']

g:ghcmod_type_highlight

The highlight group used in :GhcModType.
By default, the Search group is used.
See :help :highlight for details on Vim’s highlighting.

Example: highlighting sub-expressions with yellow background

hi ghcmodType ctermbg=yellow
let g:ghcmod_type_highlight = 'ghcmodType'

Auto-checking on writing

Put the below in your ~/.vimrc.
When you write *.hs buffer to a file, both check and lint are run.

autocmd BufWritePost *.hs call s:check_and_lint()
function! s:check_and_lint()
  let l:qflist = ghcmod#make('check')
  call extend(l:qflist, ghcmod#make('lint'))
  lcd `=expand('%:p:h')`
  call setqflist(l:qflist)
  lcd -
  cwindow
endfunction

If you like asynchronous checking, put the below instead.

autocmd BufWritePost *.hs call GhcModCheckAndLintAsync
Clone this wiki locally