vim-haredoc

[vim] haredoc plugin
git clone https://git.torresjrjr.com/vim-haredoc.git
Log | Files | Refs | README | LICENSE

haredoc.vim (1206B)


      1 " Haredoc plugin -- Hare documentation in vim
      2 " Maintainer: Byron Torres <b@torresjrjr.com>
      3 " Last Updated: 2022-06-15
      4 " License: Vim License
      5 
      6 command -nargs=? Haredoc  :call Haredoc(<q-args>)
      7 
      8 function Haredoc(symbol)
      9 	let symbol = a:symbol
     10 	let popup = symbol == '.' ? 1 : 0
     11 	if (symbol == '.' || symbol == ',')
     12 		let oldiskeyword = &iskeyword
     13 		setlocal iskeyword+=:
     14 		let symbol = expand('<cword>')
     15 		let &iskeyword = oldiskeyword
     16 	endif
     17 	if popup == 1 && has('popupwin') && has('terminal')
     18 		let minheight = 1 + system(
     19 		\	"haredoc -Ftty '"..symbol.."' 2>&1 | wc -l"
     20 		\ )
     21 		let buf = term_start(
     22 		\	[
     23 		\		'sh', '-c',
     24 		\		"haredoc -Ftty '"..symbol.."' 2>&1 | less -RK",
     25 		\	],
     26 		\	#{hidden: 1, term_finish: 'close'},
     27 		\ )
     28 		let winid = popup_atcursor(
     29 		\	buf,
     30 		\	#{
     31 		\		col: 'cursor-'..virtcol('.'),
     32 		\		minwidth: 84,
     33 		\		minheight: minheight,
     34 		\		fixed: v:false,
     35 		\		wrap: v:false,
     36 		\		border: [1, 1, 1, 1],
     37 		\	},
     38 		\ )
     39 	elseif has('terminal')
     40 		execute 'terminal ++noclose haredoc '..symbol
     41 		set nonumber filetype=hare
     42 		nnoremap <buffer> q  :close<CR>
     43 		nnoremap <buffer> <nowait> u  <C-U>
     44 		nnoremap <buffer> <nowait> d  <C-D>
     45 	else
     46 		execute '!haredoc '..symbol
     47 	endif
     48 endfunction