axkirillov / hbac.nvim

Heuristic buffer auto-close
MIT License
197 stars 10 forks source link

Integrate with `Telescope buffers` to show pinned buffers #7

Closed technicalpickles closed 1 year ago

technicalpickles commented 1 year ago

This is probably a stretch, but I would love to be able to show when buffers are pinned when using Telescope buffers.

CleanShot 2023-05-16 at 13 28 34

I was looking at the source for it, but I think it'd basically involve re-implementing it: https://github.com/nvim-telescope/telescope.nvim/blob/40c31fdde93bcd85aeb3447bb3e2a3208395a868/lua/telescope/builtin/__internal.lua#L868-L938C1

ditsuke commented 1 year ago

Thanks for opening an issue. @al-ce is already working on this #5

axkirillov commented 1 year ago

This is now in the latest release https://github.com/axkirillov/hbac.nvim/releases/tag/v1.2.0 Just call Hbac telescope and you get the buffer picker experience + pin state and mappings to toggle pin state / delete buffer etc.

axkirillov commented 1 year ago

Be free to give us any feedback on whether it works as you expect it and if there is any friction!

technicalpickles commented 1 year ago

That is great news, thanks! Updated, and gave it a try. Some initial impressions:

For comparison, I use these options for buffer:

            pickers = {
                buffers = {
                    sort_lastused = true,
                    sort_mru = true,
                    ignore_current_buffer = true,
                },
            }

The end result of those is that it hides the buffer I'm currently in, and then default selected item is the most recent buffer.

al-ce commented 1 year ago

Thanks for giving it a try and for the feedback @technicalpickles. Yes, @ditsuke pointed out the sorting / order issue as we were closing it and we have plans to open a PR to address that. That's my fault for not checking where each of the possible opts belonged in different parts of the picker.

Fair point about the icons, we can consider that in future commits. In the meantime, try setting the unpinned icon to an empty string in the opts (you can also change their hl groups)

require("hbac").setup({
  telescope = {
    pin_icons = {
      unpinned = { "" },
    },
  },
})

Thanks again! I'll try to remember to ping you when there's progress on the sorting.

axkirillov commented 1 year ago

That is great news, thanks! Updated, and gave it a try. Some initial impressions:

* having icons for both pinned and unpinned is kinda confusing. I think it's fine to leave it blank for unpinned.

* I'm not sure what order it's showing them in, or if it's configurable at all

For comparison, I use these options for buffer:

          pickers = {
              buffers = {
                  sort_lastused = true,
                  sort_mru = true,
                  ignore_current_buffer = true,
              },
          }

The end result of those is that it hides the buffer I'm currently in, and then default selected item is the most recent buffer.

Thank you for the suggestions! I think all of your points make a lot of sense, and I would love to see them in hbac. I agree that having only an icon for the pinned state would probably be more straightforward.

As for the ordering opts you mentioned I think it's also a good idea for us to implement them.