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