Closed MunifTanjim closed 1 year ago
Could you show me your customized title? I'm not sure why the users need it, current title has shown since this plugin release, and no one ask to customize it.
Could you show me your customized title?
It's mostly like the built-in one. But for files under the current directory, the current directory is stripped out. And the truncation has some additional steps:
This shows as much information as possible, as long as possible. Also, the built-in one has a hardcoded 15 width reserved, so sometimes title disappears even when there's room to show it.
I've added the screenshots in PR description.
Thanks to contribute this plugin, but I think it's not worthy for this. As a maintainer, I don't want to expose unnecessary (few users use) API function to users. I hate breaking change and just want to easy to iterate modules in the future.
Not sure how giving user more customizability is unnecessary, or how this will lead to breaking change... but it's your call.
The current way of doing this is very hacky.
```lua require("bqf.preview.floatwin").generateTitle = function (self, bufnr, idx, size) local position = (" [%d/%d] "):format(idx, size) local buffer = ("buf %d: "):format(bufnr) local flags = vim.bo[bufnr].modified and " [+] " or " " local max_width = self.width - 4 - vim.fn.strwidth(buffer) - vim.fn.strwidth(position) - vim.fn.strwidth(flags) local fname = vim.fn.fnamemodify(vim.fn.bufname(bufnr), ":p:~:.") local attempt = 3 while max_width < vim.fn.strwidth(fname) do if attempt == -1 then fname = "" break elseif attempt == 0 then fname = vim.fn.fnamemodify(fname, ":t") else fname = vim.fn.pathshorten(fname, attempt * 2 - 1) end attempt = attempt - 1 end return ("%s%s%s%s"):format(position, buffer, fname, flags) end ```This config will enable user to do it cleanly:
Outside current directory (under root):
Outside current directory (under home):
Inside current directory:
Truncations:
3:
2:
1:
0:
-1: