nvim-dbee icon indicating copy to clipboard operation
nvim-dbee copied to clipboard

Option to simplify/toggle ui

Open taybart opened this issue 4 months ago • 7 comments

Hello, love the plugin so far.

Would it be possible to toggle the drawer and the call log on and off? I typically have a couple of tmux panes in the same window open and after i connect to the database I don't need to see the connection/notes window. Additionally, if I am just looking for db changes i don't really need the call log. Would it be possible to have some kind of toggle?

Also side note, it would be super awesome to be able to jump between columns instead of just jumping by word or something like /\w\+<cr> in the column headers because i might want to just jump between columns in the result rows.

taybart avatar Jul 20 '25 16:07 taybart

Hey @taybart!!

The toggle feature should be possible and I also think it'll be a nice one to add. I'll try to work on this on the next few days when I have some time and I'll get back to you if i get any progress. I'm just not sure if we should implement it as an exposed function call that can be mapped by the user or if it should use a builtin keymap. Maybe some other contributors can hop in here to suggest what is better.

Talking about the jump between columns mapping. I thought a little about this but could find an elegant way of doing it. I guess we could run :normal f│w and :normal F│b to jump right and left, but this seems a little bit janky.

eduardofuncao avatar Jul 21 '25 20:07 eduardofuncao

I think an api function that can be key mapped is perfect.

Yeah i was messing with different keymaps for jumping and they all didn't work how i was hoping. Maybe injecting <200b> into the beginning of each column entry and searching for that? It would be so awesome to just jump from column to column on some of the databases I work on (they always end up having jsonb columns for whatever reason ¯_(ツ)_/¯). It might just end up too janky to be worth it though. Thanks for the response!

taybart avatar Jul 21 '25 21:07 taybart

Hey, just got the sidebar toggle working! I'll probably tidy up the code a bit and post the PR here tomorrow.

Also, try this in your config to jump from column to column - not really sure if that's what you were looking for exactly.

vim.api.nvim_create_autocmd('FileType', {
  pattern = 'dbee',
  callback = function()
    vim.keymap.set('n', '<C-l>', 'f│w')
    vim.keymap.set('n', '<C-h>', 'F│b')
  end,
})
vim.opt.sidescrolloff = 8

Thanks for the great suggestions!! All the best

eduardofuncao avatar Jul 22 '25 02:07 eduardofuncao

Thats awesome, let me know if you want me to test anything. That keymap works great! Thank you.

taybart avatar Jul 22 '25 18:07 taybart

Thanks! I'd really appreciate it. It's already somewhat working, you can try using this branch in my fork (it's up to date with master from the main repo with only this commit added). If you use lazy.nvim:

{
  "eduardofuncao/nvim-dbee",
  branch = "feat/toggle-sidebar",
  name = "nvim-dbee",
  
  dependencies = {
  "MunifTanjim/nui.nvim",
  },
  build = function()
  -- Install tries to automatically detect the install method.
  -- if it fails, try calling it with one of these parameters:
  --    "curl", "wget", "bitsadmin", "go"
  require("dbee").install()
  end,
  -- rest of your dbee config
}

You might have to uninstall and install the plugin again using :Lazy Then, you can call the toggle sidebar function with :lua require("dbee").api.ui.sidebar_toggle()

There's an annoying thing though. If you have any expanded databases (showing the tables), when you toggle the sidebar back on, it has to reload the table names, so it lags for a bit. I'll try to cache this in memory somehow so we don't have this little wait time. Another thing i should probably do is to set the cursor to the top of the drawer window after the sidebar toggles back on.

Here's a preview for others to see as well:

https://github.com/user-attachments/assets/6edf8fe2-2aef-4eb7-8607-79b0a7c07adb

eduardofuncao avatar Jul 22 '25 22:07 eduardofuncao

Yeah, works great! thanks!

taybart avatar Jul 23 '25 20:07 taybart

Hey @taybart! Here's the PR. I updated the way to call the function: for simplicity, now you can run :lua require("dbee").sidebar_toggle() or just run the command :Dbee sidebarToggle

eduardofuncao avatar Jul 24 '25 00:07 eduardofuncao