Skip to content

Commit

Permalink
feat: hide mapping boilerplate (#6)
Browse files Browse the repository at this point in the history
* hide mapping boilerplate

* hiding logic moved higher & ignore user-set labels
  • Loading branch information
michaelb committed Apr 28, 2021
1 parent 731fffe commit b3357de
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ WhichKey comes with the following defaults:
width = { min = 20, max = 50 }, -- min and max width of the columns
spacing = 3, -- spacing between columns
},
hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ "}, -- hide mapping boilerplate
show_help = true -- show help message on the command line when the popup is visible
}
```
Expand Down
1 change: 1 addition & 0 deletions lua/which-key/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ local defaults = {
width = { min = 20, max = 50 }, -- min and max width of the columns
spacing = 3, -- spacing between columns
},
hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "^:", "^ ", "^call ", "^lua "}, -- hide mapping boilerplate
show_help = true, -- show a help message in the command line for using WhichKey
}

Expand Down
6 changes: 5 additions & 1 deletion lua/which-key/keys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ function M.get_mappings(mode, prefix, buf)
value.label = value.label:gsub("^%+", "")
value.label = Config.options.icons.group .. value.label
else
value.label = value.label or value.cmd
local clean_value_cmd = value.cmd
for i,v in ipairs(Config.options.hidden) do
clean_value_cmd = clean_value_cmd:gsub(v, "")
end
value.label = value.label or clean_value_cmd
end
table.insert(tmp, value)
end
Expand Down
2 changes: 2 additions & 0 deletions lua/which-key/text.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local config = require("which-key.config")

---@class Text
---@field lines string[]
---@field hl Highlight[]
Expand Down

0 comments on commit b3357de

Please sign in to comment.