nvim-lualine / lualine.nvim

A blazing fast and easy to configure neovim statusline plugin written in pure lua.
MIT License
5.95k stars 462 forks source link

Feat: show shortened path in tabline when there’re two tabs with same name #883

Open GoldsteinE opened 1 year ago

GoldsteinE commented 1 year ago

Requested feature

When there’re two tabs with same filename, they’re indistinguishable. It’d be useful if (probably abbreviated) part of the path was shown before the filename in that case.

Motivation

That often happens with e.g. Rust’s mod.rs files. It’s already supported in tabline.nvim, but tabline.nvim doesn’t support being on the left side of tabline, so there’s currently no way to create a classical tabline with this feature.

GoldsteinE commented 1 year ago

show_modified_status (as in windows) would also be useful

loyd commented 1 year ago

You can use the fmt option to define any custom logic, e.g. iterate over tabs and construct the desired name. I haven't tried it, but I use fmt to extract a project name out of the full file path.

However, your proposal seems to be a good default behavior for the plugin.

GoldsteinE commented 1 year ago

It’s already supported for windows component tho (via show_filename_only = false), so duplicating logic in user config would be somewhat weird here.

GoldsteinE commented 1 year ago

Also fmt gets only tab name, so it’s impossible to distinguish between two tabs with same names.

GoldsteinE commented 1 year ago

It’s possible to achieve this by updating t:tabname tho: https://github.com/GoldsteinE/nixos/blob/1efbdc78560310c4e5d6bc1594539c73b83145ef/dotfiles/.config/nvim/lua/lualine_conf.lua#L3-L35