cmp-buffer icon indicating copy to clipboard operation
cmp-buffer copied to clipboard

How to make the `:bd ` buffer completion show the buffer number alongside its name?

Open Dolfost opened this issue 1 year ago • 1 comments

For example, I type in command mode:

Screenshot 2024-01-06 at 9 43 28 PM

And this is what I get.

How to make it show a number AND buffer name from :ls command?

Screenshot 2024-01-06 at 9 44 09 PM

for example, init.lua has number 3. Sow in buffer completion it would looked like

3 init.lua

This idea may break something, I just don't know. Is it easy to implement -- or stuff is already hard-coded so it will be bad idea. Any help or information are welcome.

Dolfost avatar Jan 06 '24 19:01 Dolfost

This source is not responsible for completing buffer names, rather, it completes words found inside the buffers. What you are getting in cmdline is actually coming from Vim itself, try it for yourself: run nvim -u NORC, open a few files, enter :bd and press <Tab> -- the buffers will be listed by name, not by bufnr. Showing those in an autocomplete menu is the responsibility of https://github.com/hrsh7th/cmp-cmdline, but under the hood it just asks Neovim for completion results, and those are, unfortunately, hard-coded in the source code of the editor.

dmitmel avatar May 16 '25 16:05 dmitmel