dotfiles/nvim/.config/nvim/after/ftplugin/haskell.vim
Sanchayan Maity 932e3ffc42 nvim: LSP cleanup and refactor
LSP does not work all the time. Either client breaks, server breaks or
it does not work because of the project structure. Removing LSP for the
umpteenth time.

asyncomplete does not seem to work at all for tags. For example, in the
gst-build directory the generated tags file can be 200MB+ in size. Even
with the file size limit set to unlimited it does not seem to give any
tag suggestions at all. Same is the case for Haskell.

Mucomplete can be slow in such cases where tag file is very large or
search space is extensively large and being synchronous this is to be
expected. To alleviate this, it is necessary to have a minimum prefix
length of 2 and perhaps trigger completion only when required. However,
this was still not good enough.

We are back to deoplete with custom source configuration. It is pretty
clear vimscript solutions are not up to the mark. Enable python provider
and also reintroduce language specific solutions like racer and jedi.

Refactor out language/file type specific settings. init.vim should only
have global keybindings, plugins and plugin settings. Also some other
minor cleanups, additions and rearrangements.

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
2020-04-15 09:27:36 +05:30

83 lines
2.8 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 <LocalLeader>b :Neomake!<CR>
nmap <LocalLeader>t :NeomakeSh stack exec -- hasktags -x -c .<CR>
nmap <LocalLeader>td :NeomakeSh stack exec -- haskdogs<CR>
nmap <LocalLeader>g :Ghcid<CR>
nmap <LocalLeader>k :GhcidKill<CR>
nmap <LocalLeader>c :HoogleClose<CR>
nmap <LocalLeader>o :exe ':Hoogle ' . expand('<cword>')<CR>
nmap <LocalLeader>i :exe ':HoogleInfo ' . expand('<cword>')<CR>
" Tabular helpers
vnoremap <Leader>= :Tabularize /=<CR>
vnoremap <Leader>- :Tabularize /-><CR>
vnoremap <Leader>< :Tabularize /<-<CR>
vnoremap <Leader>, :Tabularize /,<CR>
vnoremap <Leader># :Tabularize /#-}<CR>
vnoremap <Leader>: :Tabularize /::<CR>
vnoremap <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_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_classic_highlighting = 0
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