Closed przepompownia closed 3 years ago
I guess we could add that. I just need a database name at the beginning of the buffer name so I can figure out on which connection it belongs. Everything else after it can be dynamic.
I did not want to do this division myself because these parts are used in other cases.
Btw. this part https://github.com/kristijanhusak/vim-dadbod-ui/blob/master/autoload/db_ui/query.vim#L63-L65 has no chance to occur because of earlier return in the same case.
I added an ability to provide custom generator for name. See this section in documentation: https://github.com/kristijanhusak/vim-dadbod-ui/blob/master/doc/dadbod-ui.txt#L655
I would appreciate if you would give it a try and let me know how it works.
With a test generator
function s:bufferNameGenerator(opts) abort
let l:time = strftime('%Y-%m-%d %T')
return printf('%s .sql', l:time)
endfunction
let g:Db_ui_buffer_name_generator = function('s:bufferNameGenerator')
I got db_ui.dev2021-04-06 23:24:19 .sql
(as expected, thanks!). Its item on the drawer is displayed as sql
:
After quit from Vim and reopen DBUI those newly saved buffers does not appear on Buffers list.
We would get additional advantage from opts
. It probably could transfer the filetype specific to given database to avoid hardcoding it in the return value (like .sql
in the example above).
I did some additional updates to this. Before I was generating tmp file names with a long extension that held the information and date time. Now i'm generating real file names. This will allow adding custom extension like you just tried to do. It should be backward compatible with old structure in case someone is using custom tmp query location. Please pull and give it a try.
I see the result on buffers list without need to provide the leading separator :tada: Thanks! I can make the new issue for filetype name transfer through opts
.
I included filetype
into the opts now, so you have it available if you need.
Thanks again! It works without any problem.
With #80 we have saved buffer filenames with human readable date inside.
After some months of working with this plugin I figured I needed another filename format.
We would provide user callback to change the default behavior, e.g.
I have made some experiment with this substitution but I noticed a side effect. The buffer need to have the database name after
basename
to be correctly displayed in Buffers section. Maybe basename and database should not appear in such callback.What do you think about adding such flexibility?