Files
w0rp 41603564b7 Add :NeuralExplain
Add a new command for visual mode to explain the highlighted lines of
text. Explanations will be printed to a preview window.
2023-09-22 01:08:44 +01:00

28 lines
790 B
VimL

" Author: w0rp <[email protected]>
" Description: Preview windows for showing whatever information in.
" Open a preview window and show some lines in it.
" The second argument allows options to be passed in.
"
" filetype - The filetype to use, defaulting to 'neural-preview'
" stay_here - If 1, stay in the window you came from.
function! neural#preview#Show(lines, options) abort
silent pedit NeuralPreviewWindow
wincmd P
setlocal modifiable
setlocal noreadonly
setlocal nobuflisted
setlocal buftype=nofile
setlocal bufhidden=wipe
:%d
call setline(1, a:lines)
setlocal nomodifiable
setlocal readonly
let &l:filetype = get(a:options, 'filetype', 'neural-preview')
if get(a:options, 'stay_here')
wincmd p
endif
endfunction