aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorByron Torres <b@torresjrjr.com>2022-06-14 23:48:57 +0100
committerByron Torres <b@torresjrjr.com>2022-06-15 03:19:18 +0100
commite7a6d6ef762945d979044e924cd12452acb50459 (patch)
treec39e851e779daacce04a285f8cf00bc12d4c7e98
parentREADME.md: add links to other plugins (diff)
downloadvim-haredoc-e7a6d6ef762945d979044e924cd12452acb50459.tar.gz
add plugin/haredoc.vim, make :Haredoc global
Diffstat (limited to '')
-rw-r--r--ftplugin/hare.vim48
-rw-r--r--plugin/haredoc.vim47
2 files changed, 51 insertions, 44 deletions
diff --git a/ftplugin/hare.vim b/ftplugin/hare.vim
index 9a8be3c..2d31f90 100644
--- a/ftplugin/hare.vim
+++ b/ftplugin/hare.vim
@@ -1,48 +1,8 @@
" Haredoc plugin -- Hare documentation in vim
" Maintainer: Byron Torres <b@torresjrjr.com>
-" Last Updated: 2022-05-22
+" Last Updated: 2022-06-15
" License: Vim License
-set keywordprg=haredoc
-nnoremap K :call Haredoc('.')<CR>
-command -nargs=? Haredoc :call Haredoc(<q-args>)
-function Haredoc(symbol)
- let symbol = a:symbol
- let popup = 0
- if symbol == '.'
- let popup = 1
- let oldiskeyword = &iskeyword
- setlocal iskeyword+=:
- let symbol = expand('<cword>')
- 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 <buffer> q :close<CR>
- else
- execute '!haredoc '..symbol
- endif
-endfunction
+setlocal keywordprg=haredoc
+
+nnoremap <buffer> K :call Haredoc('.')<CR>
diff --git a/plugin/haredoc.vim b/plugin/haredoc.vim
new file mode 100644
index 0000000..65171fa
--- /dev/null
+++ b/plugin/haredoc.vim
@@ -0,0 +1,47 @@
+" Haredoc plugin -- Hare documentation in vim
+" Maintainer: Byron Torres <b@torresjrjr.com>
+" Last Updated: 2022-06-15
+" License: Vim License
+
+command -nargs=? Haredoc :call Haredoc(<q-args>)
+
+function Haredoc(symbol)
+ let symbol = a:symbol
+ let popup = 0
+ if symbol == '.'
+ let popup = 1
+ let oldiskeyword = &iskeyword
+ setlocal iskeyword+=:
+ let symbol = expand('<cword>')
+ 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 <buffer> q :close<CR>
+ else
+ execute '!haredoc '..symbol
+ endif
+endfunction