feat(ui): added support for setting a title of the lazy window. Fixes #814

This commit is contained in:
Folke Lemaitre 2023-05-27 14:28:09 +02:00
parent 97c2f8858c
commit 9dce0816f1
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
4 changed files with 15 additions and 3 deletions

View File

@ -310,7 +310,7 @@ return {
git = { git = {
-- defaults for the `Lazy log` command -- defaults for the `Lazy log` command
-- log = { "-10" }, -- show the last 10 commits -- log = { "-10" }, -- show the last 10 commits
log = { "--since=3 days ago" }, -- show commits from the last 3 days log = { "-8" }, -- show commits from the last 3 days
timeout = 120, -- kill processes that take more than 2 minutes timeout = 120, -- kill processes that take more than 2 minutes
url_format = "https://github.com/%s.git", url_format = "https://github.com/%s.git",
-- lazy.nvim requires git >=2.19.0. If you really want to use lazy with an older version, -- lazy.nvim requires git >=2.19.0. If you really want to use lazy with an older version,
@ -337,6 +337,8 @@ return {
wrap = true, -- wrap the lines in the ui wrap = true, -- wrap the lines in the ui
-- The border to use for the UI window. Accepts same border values as |nvim_open_win()|. -- The border to use for the UI window. Accepts same border values as |nvim_open_win()|.
border = "none", border = "none",
title = nil, ---@type string only works when border is not "none"
title_pos = "center", ---@type "center" | "left" | "right"
icons = { icons = {
cmd = " ", cmd = " ",
config = "", config = "",
@ -757,6 +759,7 @@ To uninstall **lazy.nvim**, you need to remove the following files and directori
| **LazyDir** | **_@text.reference_** | directory | | **LazyDir** | **_@text.reference_** | directory |
| **LazyH1** | **_IncSearch_** | home button | | **LazyH1** | **_IncSearch_** | home button |
| **LazyH2** | **_Bold_** | titles | | **LazyH2** | **_Bold_** | titles |
| **LazyLocal** | **_Constant_** | |
| **LazyNoCond** | **_DiagnosticWarn_** | unloaded icon for a plugin where `cond()` was false | | **LazyNoCond** | **_DiagnosticWarn_** | unloaded icon for a plugin where `cond()` was false |
| **LazyNormal** | **_NormalFloat_** | | | **LazyNormal** | **_NormalFloat_** | |
| **LazyProgressDone** | **_Constant_** | progress bar done | | **LazyProgressDone** | **_Constant_** | progress bar done |

View File

@ -48,6 +48,8 @@ M.defaults = {
wrap = true, -- wrap the lines in the ui wrap = true, -- wrap the lines in the ui
-- The border to use for the UI window. Accepts same border values as |nvim_open_win()|. -- The border to use for the UI window. Accepts same border values as |nvim_open_win()|.
border = "none", border = "none",
title = nil, ---@type string only works when border is not "none"
title_pos = "center", ---@type "center" | "left" | "right"
icons = { icons = {
cmd = "", cmd = "",
config = "", config = "",

View File

@ -9,6 +9,8 @@ local ViewConfig = require("lazy.view.config")
---@field zindex? number ---@field zindex? number
---@field style? "" | "minimal" ---@field style? "" | "minimal"
---@field border? "none" | "single" | "double" | "rounded" | "solid" | "shadow" ---@field border? "none" | "single" | "double" | "rounded" | "solid" | "shadow"
---@field title? string
---@field title_pos? "center" | "left" | "right"
---@class LazyFloat ---@class LazyFloat
---@field buf number ---@field buf number
@ -50,6 +52,8 @@ function M:init(opts)
border = self.opts.border, border = self.opts.border,
zindex = self.opts.zindex, zindex = self.opts.zindex,
noautocmd = true, noautocmd = true,
title = self.opts.title,
title_pos = self.opts.title and self.opts.title_pos or nil,
} }
self:mount() self:mount()
self:on_key(ViewConfig.keys.close, self.close) self:on_key(ViewConfig.keys.close, self.close)

View File

@ -50,7 +50,10 @@ end
function M.create() function M.create()
local self = setmetatable({}, { __index = setmetatable(M, { __index = Float }) }) local self = setmetatable({}, { __index = setmetatable(M, { __index = Float }) })
---@cast self LazyView ---@cast self LazyView
Float.init(self) Float.init(self, {
title = Config.options.ui.title,
title_pos = Config.options.ui.title_pos,
})
if Config.options.ui.wrap then if Config.options.ui.wrap then
vim.wo[self.win].wrap = true vim.wo[self.win].wrap = true