From a01a33f9a8aea3eb19eb76601131c01e23d8e034 Mon Sep 17 00:00:00 2001 From: kiyan Date: Thu, 1 Jul 2021 10:35:01 +0200 Subject: [PATCH] fix(help ui): adapt to new bindings and fix code lint/format --- lua/nvim-tree/renderer.lua | 52 +++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/lua/nvim-tree/renderer.lua b/lua/nvim-tree/renderer.lua index dc7b4801..56268051 100644 --- a/lua/nvim-tree/renderer.lua +++ b/lua/nvim-tree/renderer.lua @@ -370,33 +370,43 @@ local M = {} function M.draw_help() local help_lines = {'HELP'} - local help_hl = {{'NvimTreeRootFolder', 0, 0, string.len('HELP')}} + local help_hl = {{'NvimTreeRootFolder', 0, 0, #help_lines[1]}} local bindings = view.View.bindings local processed = {} - for i, v in pairs(bindings) do - if v:sub(1,35) == view.nvim_tree_callback('test'):sub(1,35) then - v = v:match("'[^']+'[^']*$") - v = v:match("'[^']+'") - table.insert(processed,{i,v,true}) + for _, b in pairs(bindings) do + local cb = b.cb + local key = b.key + if cb:sub(1,35) == view.nvim_tree_callback('test'):sub(1,35) then + cb = cb:match("'[^']+'[^']*$") + cb = cb:match("'[^']+'") + table.insert(processed, {key, cb, true}) else - v = '"' .. v .. '"' - table.insert(processed,{i,v,false}) + cb = '"' .. cb .. '"' + table.insert(processed, {key, cb, false}) end end - table.sort(processed,function(a,b) - return (a[3]==b[3] and (a[2]