dotfiles/nvim/.config/nvim/after/ftplugin/haskell.vim
Sanchayan Maity 467a660409 nvim: Drop neomake, QFGrep and vim-grepper
Profiling with below
nvim -c 'profile start vim.log' -c 'profile func *' -c 'q'

shows that neomake adds to the start up time. Currently we only use it
for two tasks. Running hlint for Haskell and stack build asynchronously.

Use asyncdo and define a generic wrapper command for running makeprg
asynchronously. This can be used for anything as long as makeprg is
set correctly.

vim-grepper also adds somewhat to the startup time though not much. We
do not need the functionality of switching between grep tools. Here
again just use asyncdo and define a generic command for running grepprg
asynchronously.

Drop QFGrep as we can use in built Cfilter plugin for filtering the
quickfix list.

Note that all start times mentioned above are a few milliseconds not
even more than 5ms. However, we would like to be as fast as possible
and use in built functions.

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
2020-05-21 16:39:06 +05:30

83 lines
2.9 KiB
VimL

" https://www.reddit.com/r/neovim/comments/es8wn7/haskell_makeprg_for_stack_build/
" https://github.com/maxigit/vimrc/tree/2020/compiler
compiler stack
setlocal makeprg=stack\ build
setlocal keywordprg=:Hoogle
nmap <buffer> <LocalLeader>t :AsyncDo stack exec -- hasktags -x -c .<CR>
nmap <buffer> <LocalLeader>td :AsyncDo stack exec -- haskdogs<CR>
nmap <buffer> <LocalLeader>g :Ghcid<CR>
nmap <buffer> <LocalLeader>k :GhcidKill<CR>
nmap <buffer> <LocalLeader>c :HoogleClose<CR>
nmap <buffer> <LocalLeader>o :exe ':Hoogle ' . expand('<cword>')<CR>
nmap <buffer> <LocalLeader>i :exe ':HoogleInfo ' . expand('<cword>')<CR>
" Tabular helpers
vnoremap <buffer> <Leader>= :Tabularize /=<CR>
vnoremap <buffer> <Leader>- :Tabularize /-><CR>
vnoremap <buffer> <Leader>< :Tabularize /<-<CR>
vnoremap <buffer> <Leader>, :Tabularize /,<CR>
vnoremap <buffer> <Leader># :Tabularize /#-}<CR>
vnoremap <buffer> <Leader>: :Tabularize /::<CR>
vnoremap <buffer> <Leader>[ :Tabularize /[<CR>
nmap <buffer><silent> ]] :call JumpHaskellFunction(0)<CR>
nmap <buffer><silent> [[ :call JumpHaskellFunction(1)<CR>
imap <buffer> ;; <ESC>:call MakeArrow(1)<CR>
imap <buffer> ;: <ESC>:call MakeArrow(0)<CR>
let g:haskell_classic_highlighting = 1
let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`
let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles
let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static`
let g:haskell_backpack = 1 " to enable highlighting of backpack keywords
let g:haskell_indent_if = 3
let g:haskell_indent_case = 2
let g:haskell_indent_let = 4
let g:haskell_indent_where = 6
let g:haskell_indent_before_where = 2
let g:haskell_indent_after_bare_where = 2
let g:haskell_indent_do = 3
let g:haskell_indent_in = 1
let g:haskell_indent_guard = 2
let g:haskell_indent_case_alternative = 1
let g:cabal_indent_section = 2
" Either check empty($IN_NIX_SHELL) for nix specific or executable('ghcid')
if executable('ghcid')
let g:ghcid_command = 'ghcid'
else
let g:ghcid_command = 'stack exec -- ghcid'
endif
if executable('hoogle')
let g:hoogle_search_bin = 'hoogle'
else
let g:hoogle_search_bin = 'stack exec -- hoogle'
endif
let g:hoogle_search_count = 30
function! JumpHaskellFunction(reverse)
call search('\C[[:alnum:]]*\s*::', a:reverse ? 'bW' : 'W')
endfunction
function! MakeArrow(type)
if a:type
if (matchstr(getline('.'), '\%' . col('.') . 'c.') ==? ' ')
exe "norm! a-> "
else
exe "norm! a -> "
endif
exe "startreplace"
else
if (matchstr(getline('.'), '\%' . col('.') . 'c.') ==? ' ')
exe "norm! a=> "
else
exe "norm! a => "
endif
exe "startreplace"
endif
endfunction