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

Buffers rework (indicators and sorting) #208

Merged
merged 1 commit into from
Nov 23, 2020

Conversation

Conni2461
Copy link
Member

@Conni2461 Conni2461 commented Oct 30, 2020

Close #179
Close #245

This is currently WIP. Basically it is hacked together.

This reworks builtin.buffers, so that we also display the indicators.
I'm currently parsing the output of :buffers. I'm not sure if i can get the indicators on another way.
This currently shows all buffer, also unloaded buffers. (So show_all_buffers = true does nothing)(Should now work as before)

This also adds a function, which could help us display outputs in a more table like format, like suggested in #118.
This does not change the other builtins to be to a table format. (I plan to do this in another pr).

I also briefly looked into #179 and i think we can use unpack(vim.fn.getbufinfo(tonumber(bufnr))).lastused to sort the buffers list. (I think this should be configurable. either pick the current solution or based on lastused.). I might do this in this PR aswell. If I can figure out how the whole sorting part works.
Previous Buffer is default selection. Should be configurable. Configurable with sort_lastused = true

Before PR New
currently new

@sunjon Would be great if you could comment the new layout(display output with the indicators).
Currently does not handle readonly buffers.
If no buffer has a write indicator the column will not be printed.

@Stanislav-Lapata and @sunjon when i sort the buffers after lastused, do you want the active buffer be displayed or should we filter out the current one?

@Stanislav-Lapata
Copy link

@Conni2461
I think current buffer should be displayed but it should be disabled
Active line should be previous buffer
buffers@2x

@Conni2461 Conni2461 force-pushed the better_buffers branch 3 times, most recently from 0e4e4ad to c784cbe Compare October 31, 2020 13:20
@Conni2461
Copy link
Member Author

@Conni2461
I think current buffer should be displayed but it should be disabled
Active line should be previous buffer
buffers@2x

Thanks that made it clearer for me.
I'm still not sure what you mean with disable current buffer. Do you mean this buffer can't be selected at all? Because i can't really image how the workflow would be if a buffer in the middle of a big list is disabled.

I got the other think working(active line should be previous buffer), but i think @tjdevries would not be happy with this code. It's currently pretty hacky and i think it should only work with sorting_strategy = 'descending'.

But could you test it anyway @Stanislav-Lapata?

I would clean up the code tomorrow, @tjdevries.

@Conni2461 Conni2461 changed the title WIP: Buffers rework, show indicator in table view WIP: Buffers rework, show indicator in table view and last buffers as default selection Oct 31, 2020
@Stanislav-Lapata
Copy link

@Conni2461
I described fzf.vim logic
Install fzf.vim if you are comfortable.

Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
Plug 'junegunn/fzf.vim'

And run :Buffer

You shouldn't repeat fzf.vim logic fully. I would just do sorting for a start and show all buffers without disabling current buffer.

Sorry for my English

@Conni2461
Copy link
Member Author

Conni2461 commented Oct 31, 2020

@Stanislav-Lapata
I haven't used fzf in a while. Okay i tested fzf and made some changes. I think this is more like fzf.
Could you try it out by running :lua require'telescope.builtin'.buffers{ show_all_buffers = true } and report back.
The selection of the current buffer is still possible and i think implementing a disable could be quiet tricky.

Both sorting_strategy should work now.

@Stanislav-Lapata
Copy link

@Conni2461
Looks nice. Thank you 👍

@Conni2461 Conni2461 changed the title WIP: Buffers rework, show indicator in table view and last buffers as default selection WIP: Buffers rework (indicators and sorting) Oct 31, 2020
lua/telescope/pickers.lua Outdated Show resolved Hide resolved
lua/telescope/pickers.lua Outdated Show resolved Hide resolved
@tjdevries
Copy link
Member

@Conni2461 I will probably take some of the code you have there for making a display table and do something very similar and then you can rebase this branch off of it at some point.

I will take a look at the other parts, particularly the selection strategy stuff, later. If you want to submit a separate PR for the selection strategy fixes, I will definitely take a look. Thanks!

@Conni2461
Copy link
Member Author

The selection_strategy fix for row and follow is in #218.
I will continue to work on this one in the next couple of days. Have to do other stuff first 😆.
Thanks for picking up my display table stuff. I took a brief look at it and it looks good.

@Conni2461 Conni2461 force-pushed the better_buffers branch 4 times, most recently from 42f6ce0 to 4846f95 Compare November 4, 2020 09:08
@Conni2461 Conni2461 marked this pull request as ready for review November 4, 2020 09:08
@Conni2461 Conni2461 force-pushed the better_buffers branch 2 times, most recently from e7c09d9 to 78d950b Compare November 4, 2020 09:28
@Conni2461 Conni2461 changed the title WIP: Buffers rework (indicators and sorting) Buffers rework (indicators and sorting) Nov 4, 2020
@Conni2461 Conni2461 force-pushed the better_buffers branch 3 times, most recently from 5b3de56 to 6ac2a8e Compare November 6, 2020 11:09
@Conni2461
Copy link
Member Author

@tjdevries Should be good to review. If you find some time.

vim.fn.bufload(bufnr)

vim.cmd([[doautocmd filetypedetect BufRead ]] .. filename)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does calling bufload do this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes i think so. I have highlighting for unloaded buffers and it seems like for loaded buffers i don't have to do anything

@Conni2461 Conni2461 force-pushed the better_buffers branch 3 times, most recently from 1e14ff8 to acb4e59 Compare November 17, 2020 09:02
@tjdevries
Copy link
Member

What's left for this PR?

@Conni2461
Copy link
Member Author

Conni2461 commented Nov 22, 2020

Basically i also added @sunjon wish to view unnamed buffers but i haven't figured out a way to open them.
:e #nr will result in Vim(edit):E499: Empty file name for '%' or '#', only works with ":p:h", so is my only option vim.api.nvim_win_set_buf(winnr, unnamed_bufnr)? Besides that i think done

Have figured it out. show_all_buffers = true should also show unnamed buffers now

@Conni2461 Conni2461 force-pushed the better_buffers branch 2 times, most recently from 13fc451 to 8167ce8 Compare November 22, 2020 10:36
@Conni2461
Copy link
Member Author

@tjdevries Should be done from my side. You can take a look at this.

@tjdevries tjdevries merged commit 863328a into nvim-telescope:master Nov 23, 2020
kkharji pushed a commit that referenced this pull request Nov 27, 2020
…o builtin_runner_insert_issue

* 'master' of github.com:nvim-telescope/telescope.nvim:
  Refactor builtin (#287)
  fix: Use noremap when mapping. (#286)
  Fix the bug report template to suggest -u
  Add gitter tag
  feat: highlighter only
  Filter the completion of the command (#279)
  feat: Buffers rework (indicators and sorting) (#208)
  feat: v0.1 of extensions (#278)
  Register finder (#275)
  Various previewer fixes (#260)
  docs: fix builtin table formatting (#272)
  feat: Add highlights builtin (#267)
  Fixed minor typos (#271)
  Feat: Add filetypes builtin (#263)
  Fix: cwd detection of builtin.git_ (#264)
@Conni2461 Conni2461 deleted the better_buffers branch December 3, 2020 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

builtin.buffers() does not show unnamed buffers. Sort buffers by fricensy of use
3 participants