feat(view): add option `ui.pills`. Set to `false` to disable the top buttons in the lazy window (#938)

* add option `ui.button`

* add option `ui.button`

* refactor: rename button to pills

---------

Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
This commit is contained in:
3719e04 2023-07-20 16:48:50 -05:00 committed by GitHub
parent 25beed5e2e
commit 84266b9f0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 22 deletions

View File

@ -339,6 +339,8 @@ return {
border = "none", border = "none",
title = nil, ---@type string only works when border is not "none" title = nil, ---@type string only works when border is not "none"
title_pos = "center", ---@type "center" | "left" | "right" title_pos = "center", ---@type "center" | "left" | "right"
-- Show pills on top of the Lazy window
pills = true, ---@type boolean
icons = { icons = {
cmd = " ", cmd = " ",
config = "", config = "",

View File

@ -50,6 +50,8 @@ M.defaults = {
border = "none", border = "none",
title = nil, ---@type string only works when border is not "none" title = nil, ---@type string only works when border is not "none"
title_pos = "center", ---@type "center" | "left" | "right" title_pos = "center", ---@type "center" | "left" | "right"
-- Show pills on top of the Lazy window
pills = true, ---@type boolean
icons = { icons = {
cmd = "", cmd = "",
config = "", config = "",

View File

@ -112,11 +112,13 @@ function M:get_plugin(row)
end end
function M:title() function M:title()
self:nl():nl() self:nl()
local modes = vim.tbl_filter(function(c) local modes = vim.tbl_filter(function(c)
return c.button return c.button
end, ViewConfig.get_commands()) end, ViewConfig.get_commands())
if Config.options.ui.pills then
self:nl()
for c, mode in ipairs(modes) do for c, mode in ipairs(modes) do
local title = " " .. mode.name:sub(1, 1):upper() .. mode.name:sub(2) .. " (" .. mode.key .. ") " local title = " " .. mode.name:sub(1, 1):upper() .. mode.name:sub(2) .. " (" .. mode.key .. ") "
if mode.name == "home" then if mode.name == "home" then
@ -144,6 +146,7 @@ function M:title()
self:append(" ") self:append(" ")
end end
self:nl() self:nl()
end
if self.progress.done < self.progress.total then if self.progress.done < self.progress.total then
self:progressbar() self:progressbar()
end end