nvim: after: ftplugin: Clean up Haskell
This commit is contained in:
parent
3bc32b2e34
commit
682c735651
1 changed files with 26 additions and 26 deletions
|
@ -20,10 +20,32 @@ 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>
|
||||
" Taken from https://github.com/danidiaz/miscellany/blob/master/linux/.vim/ftplugin/haskell/movements.vim
|
||||
" Next top-level type signature
|
||||
nnoremap <script> <silent> ]f /^\w[^:=$]*\(::\\|\n\s*::\)<CR>
|
||||
" Previous top-level type signature
|
||||
nnoremap <script> <silent> [f ?^\w[^:=$]*::\(::\\|\n\s*::\)<CR>
|
||||
" Next type signature
|
||||
nnoremap <script> <silent> ]l /^\s*\w[^:=$]*\(::\\|\n\s*::\)<CR>
|
||||
" Previous type signature
|
||||
nnoremap <script> <silent> [l ?^\s*\w[^:=$]*\(::\\|\n\s*::\)<CR>
|
||||
" Next data declaration
|
||||
nnoremap <script> <silent> ]t /^\(data \\|newtype \\|type \\|class\)<CR>
|
||||
" Previous data declaration
|
||||
nnoremap <script> <silent> [t ?^\(data \\|newtype \\|type \\|class\)<CR>
|
||||
" Beginning of imports
|
||||
nnoremap <script> <silent> [i gg/^import <CR>z<CR>
|
||||
" End of imports
|
||||
nnoremap <script> <silent> [I G?^import <CR>zb
|
||||
" Beginning of module exports
|
||||
nnoremap <script> <silent> [m gg/^module <CR>z<CR>
|
||||
" End of module exports (wonky)
|
||||
nnoremap <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
|
||||
nnoremap <script> <silent> ]n /^-- \$\w\+<CR>z<CR>
|
||||
" Previous named chunk of documentation
|
||||
nnoremap <script> <silent> [n ?^-- \$\w\+<CR>z<CR>
|
||||
|
||||
let g:haskell_classic_highlighting = 1
|
||||
let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
|
||||
|
@ -57,25 +79,3 @@ 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
|
||||
|
|
Loading…
Reference in a new issue