diff options
Diffstat (limited to 'nvim/.config/nvim/ftplugin/haskell.vim')
-rw-r--r-- | nvim/.config/nvim/ftplugin/haskell.vim | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/nvim/.config/nvim/ftplugin/haskell.vim b/nvim/.config/nvim/ftplugin/haskell.vim index c389121..5bcdd4c 100644 --- a/nvim/.config/nvim/ftplugin/haskell.vim +++ b/nvim/.config/nvim/ftplugin/haskell.vim | |||
@@ -1,29 +1,30 @@ | |||
1 | function! s:OverwriteBuffer(output) | 1 | function! s:OverwriteBuffer(output) |
2 | let winview = winsaveview() | 2 | let winview = winsaveview() |
3 | silent! undojoin | 3 | silent! undojoin |
4 | normal! gg"_dG | 4 | normal! gg"_dG |
5 | call append(0, split(a:output, '\v\n')) | 5 | call append(0, split(a:output, '\v\n')) |
6 | normal! G"_dd | 6 | normal! G"_dd |
7 | call winrestview(winview) | 7 | call winrestview(winview) |
8 | endfunction | 8 | endfunction |
9 | 9 | ||
10 | function! s:RunStylishHaskell() | 10 | function! s:RunStylishHaskell() |
11 | let output = system("stylish-haskell" . " " . bufname("%")) | 11 | let output = system("stylish-haskell" . " " . bufname("%")) |
12 | let errors = matchstr(output, '\(Language\.Haskell\.Stylish\.Parse\.parseModule:[^\x0]*\)') | 12 | let errors = matchstr(output, '\(Language\.Haskell\.Stylish\.Parse\.parseModule:[^\x0]*\)') |
13 | if v:shell_error != 0 | 13 | if v:shell_error != 0 |
14 | echom output | 14 | echom output |
15 | elseif empty(errors) | 15 | elseif empty(errors) |
16 | call s:OverwriteBuffer(output) | 16 | call s:OverwriteBuffer(output) |
17 | write | 17 | write |
18 | else | 18 | else |
19 | echom errors | 19 | echom errors |
20 | endif | 20 | endif |
21 | endfunction | 21 | endfunction |
22 | 22 | ||
23 | augroup haskell-formatting | ||
24 | autocmd! | ||
25 | autocmd BufWritePost *.hs call s:RunStylishHaskell() | ||
26 | augroup END | ||
27 | |||
28 | |||
29 | set formatprg=stylish-haskell | 23 | set formatprg=stylish-haskell |
24 | set makeprg=hlint | ||
25 | |||
26 | augroup HaskellLint | ||
27 | autocmd! | ||
28 | autocmd BufWritePost *.hs | silent make! <afile> | silent redraw! | ||
29 | autocmd QuickFixCmdPost [^l]* cwindow | ||
30 | augroup END | ||