summaryrefslogtreecommitdiffstats
path: root/vim/.vim/plugin/keywordprg.vim
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2023-10-08 12:09:20 -0400
committerJesse Luehrs <doy@tozt.net>2023-10-08 12:59:10 -0400
commit49570c8dd03448240897b37b68567352b790f16f (patch)
tree6c192a52046d5d0dd1b84a838befd8e777cfeafb /vim/.vim/plugin/keywordprg.vim
parent66939c71da756c1d9e07a88a4a8ea2a018650060 (diff)
downloadconf-49570c8dd03448240897b37b68567352b790f16f.tar.gz
conf-49570c8dd03448240897b37b68567352b790f16f.zip
convert to stow
Diffstat (limited to 'vim/.vim/plugin/keywordprg.vim')
-rw-r--r--vim/.vim/plugin/keywordprg.vim33
1 files changed, 33 insertions, 0 deletions
diff --git a/vim/.vim/plugin/keywordprg.vim b/vim/.vim/plugin/keywordprg.vim
new file mode 100644
index 0000000..dfedd80
--- /dev/null
+++ b/vim/.vim/plugin/keywordprg.vim
@@ -0,0 +1,33 @@
+function! Help(visual, iskeyword, command)
+ let l:iskeyword = &iskeyword
+ for l:kw in a:iskeyword
+ exe 'set iskeyword+=' . l:kw
+ endfor
+ if a:visual
+ let l:oldreg = @a
+ normal! gv"aygv
+ let l:word = @a
+ let @a = l:oldreg
+ else
+ let l:word = expand('<cword>')
+ endif
+ let &iskeyword = l:iskeyword
+
+ exe 'noswapfile ' . &helpheight . 'new ' . l:word
+ setlocal buftype=nofile
+ setlocal bufhidden=wipe
+ setlocal nobuflisted
+
+ setlocal modifiable
+ exe 'call ' . a:command . '("' . l:word . '")'
+ normal! ggdd
+ setlocal nomodifiable
+endfunction
+
+function! s:man(word)
+ exe 'silent read! man -Pcat ' . a:word
+ setlocal filetype=man
+endfunction
+
+nnoremap <silent>K :call Help(0, [], '<SID>man')<CR>
+xnoremap <silent>K :call Help(1, [], '<SID>man')<CR>