mirror of
https://git.decapod.one/brethil/dotfiles
synced 2024-12-05 01:01:30 +01:00
vim: add completion to Man and Cmd functions
This commit is contained in:
parent
2d4d0fa481
commit
74add58517
|
@ -92,7 +92,7 @@ function! GitStatus()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" Redirect command into scractch buffer. Stolen from romainl
|
" Redirect command into scratch buffer. Stolen from romainl
|
||||||
function! Redir(cmd, rng, start, end)
|
function! Redir(cmd, rng, start, end)
|
||||||
for win in range(1, winnr('$'))
|
for win in range(1, winnr('$'))
|
||||||
if getwinvar(win, 'scratch')
|
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>)
|
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)
|
function! Man(cmd)
|
||||||
let output = system('man ' . a:cmd)
|
|
||||||
vnew
|
vnew
|
||||||
let w:scratch=1
|
let w:scratch=1
|
||||||
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile filetype=man
|
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile filetype=man
|
||||||
setlocal nonumber norelativenumber
|
setlocal nonumber norelativenumber
|
||||||
|
let output = system('man ' . a:cmd)
|
||||||
call setline(1, split(output, '\n'))
|
call setline(1, split(output, '\n'))
|
||||||
endfunction
|
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
|
" Execute the given command and print it in a scratch buffer
|
||||||
function! Cmd(cmd)
|
function! Cmd(cmd)
|
||||||
|
@ -147,4 +147,4 @@ function! Cmd(cmd)
|
||||||
call setline(1, split(output, '\n'))
|
call setline(1, split(output, '\n'))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
command! -nargs=1 -complete=command Cmd silent call Cmd(<q-args>)
|
command! -nargs=1 -complete=shellcmd Cmd silent call Cmd(<q-args>)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user