Skip to content

Commit

Permalink
feat(ui): added support for setting a title of the lazy window. Fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed May 27, 2023
1 parent 97c2f88 commit 9dce081
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ require("lazy").setup({
| **keys** | `string?` or `string[]` or `LazyKeys[]` or `fun(self:LazyPlugin, keys:string[]):(string \| LazyKeys)[]` | Lazy-load on key mapping |
| **module** | `false?` | Do not automatically load this Lua module when it's required somewhere |
| **priority** | `number?` | Only useful for **start** plugins (`lazy=false`) to force loading certain plugins first. Default priority is `50`. It's recommended to set this to a high number for colorschemes. |
| **optional** | `boolean?` | When a spec is tagged optional, it will only be included in the final spec, when the same plugin has been specified at least once somewhere else without `optional`. This is mainly useful for Neovim distros, to allow setting options on plugins that may/may not be part of the user's plugins |
| **optional** | `boolean?` | When a spec is tagged optional, it will only be included in the final spec, when the same plugin has been specified at least once somewhere else without `optional`. This is mainly useful for Neovim distros, to allow setting options on plugins that may/may not be part of the user's plugins |

### Lazy Loading

Expand Down Expand Up @@ -310,7 +310,7 @@ return {
git = {
-- defaults for the `Lazy log` command
-- 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
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,
Expand All @@ -337,6 +337,8 @@ return {
wrap = true, -- wrap the lines in the ui
-- The border to use for the UI window. Accepts same border values as |nvim_open_win()|.
border = "none",
title = nil, ---@type string only works when border is not "none"
title_pos = "center", ---@type "center" | "left" | "right"
icons = {
cmd = "",
config = "",
Expand Down Expand Up @@ -757,6 +759,7 @@ To uninstall **lazy.nvim**, you need to remove the following files and directori
| **LazyDir** | **_@text.reference_** | directory |
| **LazyH1** | **_IncSearch_** | home button |
| **LazyH2** | **_Bold_** | titles |
| **LazyLocal** | **_Constant_** | |
| **LazyNoCond** | **_DiagnosticWarn_** | unloaded icon for a plugin where `cond()` was false |
| **LazyNormal** | **_NormalFloat_** | |
| **LazyProgressDone** | **_Constant_** | progress bar done |
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 @@ -48,6 +48,8 @@ M.defaults = {
wrap = true, -- wrap the lines in the ui
-- The border to use for the UI window. Accepts same border values as |nvim_open_win()|.
border = "none",
title = nil, ---@type string only works when border is not "none"
title_pos = "center", ---@type "center" | "left" | "right"
icons = {
cmd = "",
config = "",
Expand Down
4 changes: 4 additions & 0 deletions lua/lazy/view/float.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ local ViewConfig = require("lazy.view.config")
---@field zindex? number
---@field style? "" | "minimal"
---@field border? "none" | "single" | "double" | "rounded" | "solid" | "shadow"
---@field title? string
---@field title_pos? "center" | "left" | "right"

---@class LazyFloat
---@field buf number
Expand Down Expand Up @@ -50,6 +52,8 @@ function M:init(opts)
border = self.opts.border,
zindex = self.opts.zindex,
noautocmd = true,
title = self.opts.title,
title_pos = self.opts.title and self.opts.title_pos or nil,
}
self:mount()
self:on_key(ViewConfig.keys.close, self.close)
Expand Down
5 changes: 4 additions & 1 deletion lua/lazy/view/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ end
function M.create()
local self = setmetatable({}, { __index = setmetatable(M, { __index = Float }) })
---@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
vim.wo[self.win].wrap = true
Expand Down

0 comments on commit 9dce081

Please sign in to comment.