.nvimrc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. " Enable hlint and GHC via Cabal
  2. let g:ale_linters = {'haskell': ['hlint', 'cabal-build']}
  3. " ... only
  4. let g:ale_linters_explicit = 1
  5. " Don't lint until I save
  6. let g:ale_lint_on_text_changed = 'never'
  7. let g:ale_lint_on_insert_leave = 0
  8. let g:ale_lint_on_enter = 0
  9. call ale#Set('haskell_cabal_build_options', '--enable-tests --disable-optimization')
  10. function! GetCabalCommand(buffer) abort
  11. let l:flags = ale#Var(a:buffer, 'haskell_cabal_build_options')
  12. return 'cabal new-build ' . l:flags
  13. endfunction
  14. call ale#linter#Define('haskell', {
  15. \ 'name': 'cabal_build',
  16. \ 'aliases': ['cabal-build'],
  17. \ 'output_stream': 'stderr',
  18. \ 'executable': 'cabal',
  19. \ 'command': function('GetCabalCommand'),
  20. \ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
  21. \})
  22. " Configure Neoformat to use ormolu for Haskell
  23. let g:neoformat_enabled_haskell = ['ormolu']
  24. let g:neoformat_haskell_ormolu = { 'exe': 'ormolu', 'args': [] }
  25. " Configure Neoformat to use cabal-fmt for cabal files
  26. let g:neoformat_cabal_cabalfmt = { 'exe': 'cabal-fmt', 'args': [] }
  27. let g:neoformat_enabled_cabal = ['cabalfmt']
  28. " Enable automagic autoformatting
  29. augroup fmt
  30. autocmd!
  31. autocmd BufWritePre * undojoin | Neoformat
  32. augroup end