From a45c59d69c9860e9816e1a5ebbe0e5d095b21bb2 Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Mon, 27 Jan 2020 20:59:02 +0530 Subject: [PATCH] nvim: Add some Haskell niceties Some niceties taken from http://silly-bytes.blogspot.com/2016/08/vim-haskell_11.html Signed-off-by: Sanchayan Maity --- nvim/.config/nvim/init.vim | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim index bef9110..644bb7a 100644 --- a/nvim/.config/nvim/init.vim +++ b/nvim/.config/nvim/init.vim @@ -397,6 +397,11 @@ augroup haskell_maps au FileType haskell nmap c :HoogleClose au FileType haskell nmap o :exe ':Hoogle ' . expand('') au FileType haskell nmap i :exe ':HoogleInfo ' . expand('') + + au FileType haskell nnoremap ]] :call JumpHaskellFunction(0) + au FileType haskell nnoremap [[ :call JumpHaskellFunction(1) + au FileType haskell inoremap ;; :call MakeArrow(1) + au FileType haskell inoremap ;: :call MakeArrow(0) augroup END augroup purescript_maps @@ -721,6 +726,28 @@ function! s:incsearch_config(...) abort \ }), get(a:, 1, {})) endfunction +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 + function! SetLspKeybindings() nnoremap gd :call LanguageClient#textDocument_definition() nnoremap gr :call LanguageClient#textDocument_rename()