j-morano / buffer_manager.nvim

A simple plugin to easily manage Neovim buffers.
MIT License
232 stars 12 forks source link

Feature Request: File Shortening Option #13

Closed DennisTheMenace780 closed 1 year ago

DennisTheMenace780 commented 1 year ago

Would it be possible to add an option that enables shortening of file paths? In the codebase I work on there are files that can be nested quite deeply, but I know which files they are and the ones I want to work with. So the Buffer Manager will look something like:

1. src/features/Friends/views/FriendList/FriendList.loader.tsx
2. src/features/Friends/views/FriendList/FriendList.graphql.ts
3. src/features/Friends/views/FriendList/FriendList.tsx
4. src/modules/Home/components/Today/Today.tsx

I think that a potential improvement could be if the way that the output of the buffer was displayed could be modified with a flag to use either the full file path, or just the file name so that instead of above, you can have something like this:

1. FriendList.loader.tsx
2. FriendList.graphql.ts
3. FriendList.tsx
4. Today.tsx

I have not dug into the plugin's implementation, but I imagine this can be implemented rather easily by storing the full file paths in a table, but then just displaying with a regex everything after the last /.

What do you think?

j-morano commented 1 year ago

Hello! I had also thought of something like that. However, I have to look at it with a bit of time, as it is not trivial, as the plugin, right now, allows you to edit the buffer with the buffer list as you want, and it is always mirroring the current buffer list (with the buffer name as it is). My idea is to have a table with the 'actual name' and the 'display name' of the buffers, so that they do not have to coincide, as is necessary now. I will work on it as soon as I can. I will keep you posted. Thanks for the feedback!

j-morano commented 1 year ago

Hello, I added the branch basename-only with the implementation of this feature. To test it, you have to change the branch in your plugin manager configuration. For example, for Packer:

  use { 'j-morano/buffer_manager.nvim', branch = 'basename-only' }

By default, the configuration option that allows this behaviour (basename_only) is set to false. So, it is also necessary to set it to true when calling the setup function of the plugin:

require("buffer_manager").setup({
  basename_only = true,
})

Let me know if everything works as it should.

j-morano commented 1 year ago

By the way, I have added an option to shorten terminal buffer names too:

require("buffer_manager").setup({
  short_term_names = true,
})
DennisTheMenace780 commented 1 year ago

Hey, haven't had an opportunity to test this out yet but I should be able to this week.

j-morano commented 1 year ago

It was working fine for me, so I merged it. Thanks for the feedback!