vim-dadbod icon indicating copy to clipboard operation
vim-dadbod copied to clipboard

Get output file path

Open jlesquembre opened this issue 7 years ago • 6 comments

The result of every query is saved in a temp file. I'd like to use that file, is it possible to get the path programmatically? (for the last query)

jlesquembre avatar Apr 19 '18 13:04 jlesquembre

You could grab it with a hack like:

autocmd BufReadPost *.dbout let g:last_dadbod_file = expand('%:p')

What are you planning on using it for?

tpope avatar Apr 19 '18 17:04 tpope

Thanks for the tip, it works for me.

I have 2 reasons:

  • Sometimes I want to save the results to share them or to look to them later again.
  • I find easier to understand some results if I open them with pspg (postgres pager). My idea is to create a map to start a new terminal window and execute pspg with the latest result

jlesquembre avatar Apr 20 '18 07:04 jlesquembre

@jlesquembre This may be helpful for your case https://github.com/kristijanhusak/vim-dadbod-ui

kristijanhusak avatar Apr 02 '20 12:04 kristijanhusak

@jlesquembre in case you are still looking for a solution for that, i found this way, creating ~/.vim/ftplugin/dbout.vim with content

nnoremap <buffer> P :terminal ++curwin ++close pspg --no-watch-file -s 4 --force-uniborder -f %<cr>

Now pressing P in a DB buffer will open pspg in place and the terminal will exit when pressing q.

tshirtman avatar Aug 18 '22 13:08 tshirtman

@tshirtman your solution is exactly what I was looking for, but when I try to implemented I got an error message E21: Cannot make changes, 'modifiable' is off

I am trying to implement it on neovim. Do you have any tips?

FYI: I am very very noob on vim, I am trying to migrate from VS-Code to neovim as a personal challenge.

lupionpe avatar Dec 09 '22 13:12 lupionpe

Might be a difference in neovim, check that the binding is active, looks like it's trying to paste into the buffer.

tshirtman avatar Dec 09 '22 16:12 tshirtman