dotfiles/nvim/.config/nvim/after/ftplugin/haskell.vim
Sanchayan Maity e6397864d0 nvim: after: ftplugin: Fix various key mappings
Make sure we use <buffer> to make a local mapping just for the active
buffer.
2021-05-02 19:23:57 +05:30

64 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
nmap <buffer> <LocalLeader>t :AsyncDo hasktags -x -c .<CR>
nmap <buffer> <LocalLeader>h :AsyncDo hlint %<CR>
nmap <buffer> <LocalLeader>g :Ghcid<CR>
nmap <buffer> <LocalLeader>k :GhcidKill<CR>
" Taken from https://github.com/danidiaz/miscellany/blob/master/linux/.vim/ftplugin/haskell/movements.vim
" Next top-level type signature
nmap <buffer> <script> <silent> ]f /^\w[^:=$]*\(::\\|\n\s*::\)<CR>
" Previous top-level type signature
nmap <buffer> <script> <silent> [f ?^\w[^:=$]*::\(::\\|\n\s*::\)<CR>
" Next type signature
nmap <buffer> <script> <silent> ]l /^\s*\w[^:=$]*\(::\\|\n\s*::\)<CR>
" Previous type signature
nmap <buffer> <script> <silent> [l ?^\s*\w[^:=$]*\(::\\|\n\s*::\)<CR>
" Next data declaration
nmap <buffer> <script> <silent> ]t /^\(data \\|newtype \\|type \\|class\)<CR>
" Previous data declaration
nmap <buffer> <script> <silent> [t ?^\(data \\|newtype \\|type \\|class\)<CR>
" Beginning of imports
nmap <buffer> <script> <silent> [i gg/^import <CR>z<CR>
" End of imports
nmap <buffer> <script> <silent> [I G?^import <CR>zb
" Beginning of module exports
nmap <buffer> <script> <silent> [m gg/^module <CR>z<CR>
" End of module exports (wonky)
nmap <buffer> <script> <silent> [M gg/^\s*)\s*where\s*$<CR>zb<CR>
" Next named chunk of documentation
" https://www.haskell.org/haddock/doc/html/ch03s05.html
nmap <buffer> <script> <silent> ]n /^-- \$\w\+<CR>z<CR>
" Previous named chunk of documentation
nmap <buffer> <script> <silent> [n ?^-- \$\w\+<CR>z<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