From 5784e502033e4334af64a2c5dfb0eb607de192e6 Mon Sep 17 00:00:00 2001 From: Byron Torres Date: Wed, 11 May 2022 12:42:30 +0100 Subject: add ftplugin/hare.vim --- ftplugin/hare.vim | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 ftplugin/hare.vim diff --git a/ftplugin/hare.vim b/ftplugin/hare.vim new file mode 100644 index 0000000..2a03bb6 --- /dev/null +++ b/ftplugin/hare.vim @@ -0,0 +1,47 @@ +" Haredoc plugin -- Hare documentation in vim +" Maintainer: Byron Torres +" Last Updated: 2022-05-22 + +set keywordprg=haredoc +nnoremap K :call Haredoc('.') +command -nargs=? Haredoc :call Haredoc() +function Haredoc(symbol) + let symbol = a:symbol + let popup = 0 + if symbol == '.' + let popup = 1 + let oldiskeyword = &iskeyword + setlocal iskeyword+=: + let symbol = expand('') + let &iskeyword = oldiskeyword + endif + if has('terminal') && has('popupwin') && popup == 1 + let minheight = 1 + system( + \ "haredoc -Ftty '"..symbol.."' 2>&1 | wc -l" + \ ) + let buf = term_start( + \ [ + \ 'sh', '-c', + \ "haredoc -Ftty '"..symbol.."' 2>&1 | less -RK", + \ ], + \ #{hidden: 1, term_finish: 'close'}, + \ ) + let winid = popup_atcursor( + \ buf, + \ #{ + \ col: 'cursor-'..virtcol('.'), + \ minwidth: 84, + \ minheight: minheight, + \ fixed: v:false, + \ wrap: v:false, + \ border: [1, 1, 1, 1], + \ }, + \ ) + elseif has('terminal') + execute 'terminal ++noclose haredoc '..symbol + set nonumber + nnoremap q :close + else + execute '!haredoc '..symbol + endif +endfunction -- cgit v1.2.3