Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(view): add option ui.button #938

Merged
merged 3 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "",
Expand Down
2 changes: 2 additions & 0 deletions lua/lazy/core/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "",
Expand Down
45 changes: 24 additions & 21 deletions lua/lazy/view/render.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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) "
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
if self.view.state.mode == "home" then
title = " lazy.nvim " .. Config.options.ui.icons.lazy
else
title = " lazy.nvim (H) "
end
end
end

if self.view.state.mode == mode.name then
if mode.name == "home" then
self:append(title, "LazyH1", { wrap = true })
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" })
end
if c == #modes then
break
if c == #modes then
break
end
self:append(" ")
end
self:append(" ")
self:nl()
end
self:nl()
if self.progress.done < self.progress.total then
self:progressbar()
end
Expand Down