From 9f4180abeab0067ba8404a6e56e22e69425e16ce Mon Sep 17 00:00:00 2001 From: Akshay Date: Wed, 5 Aug 2020 20:18:22 +0530 Subject: add haskell augroups --- bash/.bash_aliases | 2 +- bash/.bashrc | 3 +++ nvim/.config/nvim/ftplugin/haskell.vim | 29 +++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 nvim/.config/nvim/ftplugin/haskell.vim diff --git a/bash/.bash_aliases b/bash/.bash_aliases index fa78f7b..da283b5 100644 --- a/bash/.bash_aliases +++ b/bash/.bash_aliases @@ -12,7 +12,7 @@ alias spdtst='curl -o /dev/null http://speedtest.wdc01.softlayer.com/downloads/t alias tmux='tmux -u' alias tree='tree -C' alias vim='nvim' -alias vime='nvim ~/.vim/vimrc' +alias vime='nvim ~/.config/nvim/init.vim' # git aliases alias gb='git branch -v' diff --git a/bash/.bashrc b/bash/.bashrc index c61dc42..abd37e7 100644 --- a/bash/.bashrc +++ b/bash/.bashrc @@ -78,6 +78,8 @@ export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion +eval "$(stack --bash-completion-script stack)" + # pfetch export PF_INFO="ascii title os kernel uptime pkgs shell " export PF_SEP=" " @@ -142,3 +144,4 @@ export BRANCH_COLOR="bright black" # if HEAD ref peels to a commit (detached state) export COMMIT_COLOR="green" + 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 @@ +function! s:OverwriteBuffer(output) + let winview = winsaveview() + silent! undojoin + normal! gg"_dG + call append(0, split(a:output, '\v\n')) + normal! G"_dd + call winrestview(winview) +endfunction + +function! s:RunStylishHaskell() + let output = system("stylish-haskell" . " " . bufname("%")) + let errors = matchstr(output, '\(Language\.Haskell\.Stylish\.Parse\.parseModule:[^\x0]*\)') + if v:shell_error != 0 + echom output + elseif empty(errors) + call s:OverwriteBuffer(output) + write + else + echom errors + endif +endfunction + +augroup haskell-formatting + autocmd! + autocmd BufWritePost *.hs call s:RunStylishHaskell() +augroup END + + +set formatprg=stylish-haskell -- cgit v1.2.3