Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to remember column number in buffer picker #2386

Closed
mehalter opened this issue Feb 16, 2023 · 7 comments · Fixed by #2416
Closed

Add option to remember column number in buffer picker #2386

mehalter opened this issue Feb 16, 2023 · 7 comments · Fixed by #2416
Labels
enhancement Enhancement to performance, inner workings or existent features

Comments

@mehalter
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I love using the built in buffer picker as my normal buffer navigation, but I get frustrated when I always have my cursor moved to the beginning of the line rather than where I left last off.

Describe the solution you'd like
I would like the buffer picker to remember where my cursor was in the column along with the line number similar to if I just switched to the buffer with something like bnext and bprev. To me this seems like a good default to have since that's the default behavior when switching buffers with other methods, but this could also be a configurable option in the buffer picker as well.

Describe alternatives you've considered
The only other alternative I can think of is to use something else for buffer picking.

@mehalter mehalter added the enhancement Enhancement to performance, inner workings or existent features label Feb 16, 2023
@jamestrew
Copy link
Contributor

Can I suggest https://github.com/ThePrimeagen/harpoon?
You can use it to "mark" files. It remembers the cursor location. You can bind the marks to keymappings for quick switching but also has it's own UI for managing the marked files. The marks are also persistent between neovim sessions and is saved on a per project basis.
It also has telescope integration.

I think for your use case, it's a much better alternative and also alleviates telescope itself from adding this feature.

@mehalter
Copy link
Contributor Author

mehalter commented Mar 4, 2023

@jamestrew I actually use vim views in my workflow (which save my previous position and everything like I like) and have autocmds in my configuration for restoring my previous view when entering a buffer telescope actually breaks this completely because when you enter a buffer from the telescope menu it calls the specific line number. So it will always bring me to the beginning of the line even if I am restoring my view on bufenter. It seems that telescope has just half implemented this feature in a way that is extremely obtrusive. It would make more sense to just switch to the buffer number rather than calling the file at a specific line number as to not be intrusive to anyone's workflow.

@A-Lamia
Copy link

A-Lamia commented Mar 4, 2023

@jamestrew I don't think this is a good replacement, i use grapple (something like harpoon) and buffer picker, they are used very differently, grapple for accessing hot files i end up returning back to frequently in a project and buffer picker for actually navigating open buffers it helps when you have a lot of buffers open.

@jamestrew
Copy link
Contributor

Ok valid points.
I'm open to implement this - should be fairly easy provided one thing:
Do either of you know of a way to get a buffer's cursor position (not necessary the current buffer/window)? getbufinfo gives line number of not column number. Since cursor position is more tied to windows than buffers, I'm having some difficulties relating any given buffer to an appropriate line AND column number.

If I were to implement this, I'd want to keep it simple. I don't want to create a separate cache for buffer numbers and cursor positions.

@mehalter
Copy link
Contributor Author

mehalter commented Mar 4, 2023

@jamestrew it might be easier to just not worry about the position and storing them. Just maintain the buffer number and just switch to the buffer. The buffer switching by default doesn't move the cursor

@mehalter
Copy link
Contributor Author

mehalter commented Mar 4, 2023

@jamestrew something like vim.cmd.b(bufnr)

@jamestrew
Copy link
Contributor

Good idea.
I'll look into this a more later.

col = vim.F.if_nil(entry.col, 1)

jamestrew added a commit to jamestrew/telescope.nvim that referenced this issue Mar 7, 2023
jamestrew added a commit to jamestrew/telescope.nvim that referenced this issue Mar 7, 2023
jamestrew added a commit to jamestrew/telescope.nvim that referenced this issue Mar 7, 2023
tjdevries pushed a commit that referenced this issue Mar 21, 2023
Conni2461 pushed a commit that referenced this issue Apr 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement to performance, inner workings or existent features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants