[nvim] redirect PutOutput into a preview window

This commit is contained in:
Dmytro Meleshko 2021-06-03 20:40:36 +03:00
parent 4c3f20a0ce
commit 20c3f3b524

View file

@ -78,7 +78,13 @@ set commentstring=//%s
nmap <silent> <leader>] m'yygccp`'j nmap <silent> <leader>] m'yygccp`'j
nmap <silent> <leader>[ m'yygccP`'k nmap <silent> <leader>[ m'yygccP`'k
command! -nargs=+ -complete=command PutOutput execute 'put =execute(' . escape(string(<q-args>), '|"') . ')' function! PutOutput(cmd)
let output = execute(a:cmd)
execute "noswapfile pedit" "+" . fnameescape("setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile") fnameescape("preview://" . a:cmd)
wincmd P
call setline(1, split(output, "\n"))
endfunction
command! -nargs=+ -complete=command PutOutput silent call PutOutput(<q-args>)
" ,c is easier to type than "+ because it doesn't require pressing Shift " ,c is easier to type than "+ because it doesn't require pressing Shift
noremap <leader>c "+ noremap <leader>c "+