aboutsummaryrefslogtreecommitdiff
path: root/nvim
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-08-05 15:48:22 +0100
committerAkshay <[email protected]>2020-08-05 15:48:22 +0100
commit9f4180abeab0067ba8404a6e56e22e69425e16ce (patch)
tree21cf84eabfee6ae312295ec29ce954727823b24a /nvim
parentd4a4a67fcb1b7a8cf7f987c1e3012043fd84e076 (diff)
add haskell augroups
Diffstat (limited to 'nvim')
-rw-r--r--nvim/.config/nvim/ftplugin/haskell.vim29
1 files changed, 29 insertions, 0 deletions
diff --git a/nvim/.config/nvim/ftplugin/haskell.vim b/nvim/.config/nvim/ftplugin/haskell.vim
new file mode 100644
index 0000000..c389121
--- /dev/null
+++ b/nvim/.config/nvim/ftplugin/haskell.vim
@@ -0,0 +1,29 @@
1function! 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)
8endfunction
9
10function! 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
21endfunction
22
23augroup haskell-formatting
24 autocmd!
25 autocmd BufWritePost *.hs call s:RunStylishHaskell()
26augroup END
27
28
29set formatprg=stylish-haskell