vim-dadbod
vim-dadbod copied to clipboard
Get output file path
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)
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?
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
pspgwith the latest result
@jlesquembre This may be helpful for your case https://github.com/kristijanhusak/vim-dadbod-ui
@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 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.
Might be a difference in neovim, check that the binding is active, looks like it's trying to paste into the buffer.