Skip to content

Commit

Permalink
fix(#2415): highlight help header and mappings (#2669)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-courtis authored Feb 11, 2024
1 parent b278fc2 commit 39e6fef
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lua/nvim-tree/help.lua
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,20 @@ local function compute()
-- increase desc if lines are shorter than the header
max_desc = math.max(max_desc, #head_lhs + #head_rhs1 - max_lhs)

-- header, not padded
local hl = { { "NvimTreeRootFolder", 0, 0, #head_lhs } }
-- header text, not padded
local lines = {
head_lhs .. string.rep(" ", max_desc + max_lhs - #head_lhs - #head_rhs1 + 2) .. head_rhs1,
string.rep(" ", max_desc + max_lhs - #head_rhs2 + 2) .. head_rhs2,
}
local width = #lines[1]

-- header highlight, assume one character keys
local hl = {
{ "NvimTreeFolderName", 0, 0, #head_lhs },
{ "NvimTreeFolderName", 0, width - 1, width },
{ "NvimTreeFolderName", 1, width - 1, width },
}

-- mappings, left padded 1
local fmt = string.format(" %%-%ds %%-%ds", max_lhs, max_desc)
for i, l in ipairs(mappings) do
Expand Down

0 comments on commit 39e6fef

Please sign in to comment.