1
0
mirror of https://git.decapod.one/brethil/dotfiles synced 2024-11-22 03:21:30 +01:00

vim: add completion to Man and Cmd functions

This commit is contained in:
bretello 2021-03-13 14:41:36 +01:00
parent 9dd2aa7ac4
commit e50cc58941
Signed by: brethil
GPG Key ID: 876AAC6290170FE7

View File

@ -92,7 +92,7 @@ function! GitStatus()
endfunction
" Redirect command into scractch buffer. Stolen from romainl
" Redirect command into scratch buffer. Stolen from romainl
function! Redir(cmd, rng, start, end)
for win in range(1, winnr('$'))
if getwinvar(win, 'scratch')
@ -124,17 +124,17 @@ endfunction
command! -nargs=1 -complete=command -bar -range Redir silent call Redir(<q-args>, <range>, <line1>, <line2>)
" Gets the manul page for the given command
" Gets the man page for the given command
function! Man(cmd)
let output = system('man ' . a:cmd)
vnew
let w:scratch=1
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile filetype=man
setlocal nonumber norelativenumber
let output = system('man ' . a:cmd)
call setline(1, split(output, '\n'))
endfunction
command! -nargs=1 -complete=command Man silent call Man(<q-args>)
command! -nargs=1 -complete=shellcmd Man silent call Man(<q-args>)
" Execute the given command and print it in a scratch buffer
function! Cmd(cmd)
@ -147,4 +147,4 @@ function! Cmd(cmd)
call setline(1, split(output, '\n'))
endfunction
command! -nargs=1 -complete=command Cmd silent call Cmd(<q-args>)
command! -nargs=1 -complete=shellcmd Cmd silent call Cmd(<q-args>)