joereynolds / SQHell.vim

An SQL wrapper for vim
MIT License
132 stars 9 forks source link

Re-use buffer or hide other buffers for results #7

Closed joereynolds closed 6 years ago

joereynolds commented 6 years ago

This is possible by modifying the function call for InsertResultsToNewBuffer to be

function! InsertResultsToNewBuffer(local_filetype, query_results)

    let window_for_buffer = bufwinnr('^_sqhell_$')

    if window_for_buffer >= 0
        buffers window_for_buffer
        normal ggdG
        put =a:query_results
    else
        new _sqhell_ | put =a:query_results
    endif

    setlocal buftype=nofile
    setlocal bufhidden=hide
    setlocal noswapfile
    execute 'setlocal filetype=' . a:local_filetype
endfunction

However, the drawback is that once we navigate to our new buffer, we can't jump back to the old one (with ctrl-o).

Figure this out...

joereynolds commented 6 years ago

Changed my mind on this, I quite like multiple buffers being open. If there's demand for this we can revisit