From 84266b9f0ff314319e69adfeb1a86bd72d1aff91 Mon Sep 17 00:00:00 2001 From: 3719e04 <56977205+3719e04@users.noreply.github.com> Date: Thu, 20 Jul 2023 16:48:50 -0500 Subject: [PATCH] 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 --- README.md | 2 ++ lua/lazy/core/config.lua | 2 ++ lua/lazy/view/render.lua | 47 +++++++++++++++++++++------------------- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index eb3faa1..31ddfb7 100644 --- a/README.md +++ b/README.md @@ -339,6 +339,8 @@ return { border = "none", title = nil, ---@type string only works when border is not "none" title_pos = "center", ---@type "center" | "left" | "right" + -- Show pills on top of the Lazy window + pills = true, ---@type boolean icons = { cmd = " ", config = "", diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua index 505db78..9f51a78 100644 --- a/lua/lazy/core/config.lua +++ b/lua/lazy/core/config.lua @@ -50,6 +50,8 @@ M.defaults = { border = "none", title = nil, ---@type string only works when border is not "none" title_pos = "center", ---@type "center" | "left" | "right" + -- Show pills on top of the Lazy window + pills = true, ---@type boolean icons = { cmd = " ", config = "", diff --git a/lua/lazy/view/render.lua b/lua/lazy/view/render.lua index 19a6feb..fe9f87e 100644 --- a/lua/lazy/view/render.lua +++ b/lua/lazy/view/render.lua @@ -112,38 +112,41 @@ function M:get_plugin(row) end function M:title() - self:nl():nl() + self:nl() local modes = vim.tbl_filter(function(c) return c.button end, ViewConfig.get_commands()) - for c, mode in ipairs(modes) do - local title = " " .. mode.name:sub(1, 1):upper() .. mode.name:sub(2) .. " (" .. mode.key .. ") " - if mode.name == "home" then - if self.view.state.mode == "home" then - title = " lazy.nvim " .. Config.options.ui.icons.lazy - else - title = " lazy.nvim (H) " - end - end - - if self.view.state.mode == mode.name then + if Config.options.ui.pills then + self:nl() + for c, mode in ipairs(modes) do + local title = " " .. mode.name:sub(1, 1):upper() .. mode.name:sub(2) .. " (" .. mode.key .. ") " if mode.name == "home" then - self:append(title, "LazyH1", { wrap = true }) + if self.view.state.mode == "home" then + title = " lazy.nvim " .. Config.options.ui.icons.lazy + else + title = " lazy.nvim (H) " + end + end + + if self.view.state.mode == mode.name then + if mode.name == "home" then + self:append(title, "LazyH1", { wrap = true }) + else + self:append(title, "LazyButtonActive", { wrap = true }) + self:highlight({ ["%(.%)"] = "LazySpecial" }) + end else - self:append(title, "LazyButtonActive", { wrap = true }) + self:append(title, "LazyButton", { wrap = true }) self:highlight({ ["%(.%)"] = "LazySpecial" }) end - else - self:append(title, "LazyButton", { wrap = true }) - self:highlight({ ["%(.%)"] = "LazySpecial" }) + if c == #modes then + break + end + self:append(" ") end - if c == #modes then - break - end - self:append(" ") + self:nl() end - self:nl() if self.progress.done < self.progress.total then self:progressbar() end