fix(help): better align local-additions #38097

Problem:
Descriptions of plugins often contain taglinks which are generally
concealed. This misaligns them by 2 characters with descriptions that
don't have a taglink in them.

Solution:
Don't count "bar" characters (`|`) for the description width.

Example:

Actual buffer content:
```
myplugin.txt                  |lsp| is cool
myplugin.txt        this is a nice plugin
```

Rendered as:
```
myplugin.txt                  lsp is cool
myplugin.txt        this is a nice plugin
```
This commit is contained in:
Yochem van Rosmalen
2026-02-27 23:50:51 +01:00
committed by GitHub
parent dc5d313d66
commit 4a4de73043
2 changed files with 24 additions and 6 deletions

View File

@@ -175,7 +175,8 @@ function M.local_additions()
if plugname and desc then
-- left-align taglink and right-align description by inserting spaces in between
local plug_width = vim.fn.strdisplaywidth(plugname)
local desc_width = vim.fn.strdisplaywidth(desc)
local _, concealed_chars = desc:gsub('|', '')
local desc_width = vim.fn.strdisplaywidth(desc) - concealed_chars
-- max(l, 1) forces at least one space for if the description is too long
local spaces = string.rep(' ', math.max(textwidth - desc_width - plug_width - 2, 1))
local fmt = string.format('|%s|%s%s', plugname, spaces, desc)