mirror of https://github.com/folke/lazy.nvim.git
feat(ui): backdrop for the lazy floating window. Can be disabled with `opts.ui.backdrop`
This commit is contained in:
parent
08954f723b
commit
a6b74f30d5
83
README.md
83
README.md
|
@ -38,7 +38,7 @@ You can add the following Lua code to your `init.lua` to bootstrap **lazy.nvim**
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||||
if not vim.loop.fs_stat(lazypath) then
|
if not vim.uv.fs_stat(lazypath) then
|
||||||
vim.fn.system({
|
vim.fn.system({
|
||||||
"git",
|
"git",
|
||||||
"clone",
|
"clone",
|
||||||
|
@ -308,11 +308,12 @@ return {
|
||||||
-- leave nil when passing the spec as the first argument to setup()
|
-- leave nil when passing the spec as the first argument to setup()
|
||||||
spec = nil, ---@type LazySpec
|
spec = nil, ---@type LazySpec
|
||||||
lockfile = vim.fn.stdpath("config") .. "/lazy-lock.json", -- lockfile generated after running update.
|
lockfile = vim.fn.stdpath("config") .. "/lazy-lock.json", -- lockfile generated after running update.
|
||||||
concurrency = jit.os:find("Windows") and (vim.loop.available_parallelism() * 2) or nil, ---@type number limit the maximum amount of concurrent tasks
|
---@type number? limit the maximum amount of concurrent tasks
|
||||||
|
concurrency = jit.os:find("Windows") and (vim.uv.available_parallelism() * 2) or nil,
|
||||||
git = {
|
git = {
|
||||||
-- defaults for the `Lazy log` command
|
-- 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
|
log = { "-8" }, -- show the last 8 commits
|
||||||
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,
|
||||||
|
@ -339,6 +340,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",
|
||||||
|
-- The backdrop opacity. 0 is fully opaque, 100 is fully transparent.
|
||||||
|
backdrop = 60,
|
||||||
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
|
-- Show pills on top of the Lazy window
|
||||||
|
@ -346,7 +349,7 @@ return {
|
||||||
icons = {
|
icons = {
|
||||||
cmd = " ",
|
cmd = " ",
|
||||||
config = "",
|
config = "",
|
||||||
event = "",
|
event = " ",
|
||||||
ft = " ",
|
ft = " ",
|
||||||
init = " ",
|
init = " ",
|
||||||
import = " ",
|
import = " ",
|
||||||
|
@ -358,7 +361,7 @@ return {
|
||||||
runtime = " ",
|
runtime = " ",
|
||||||
require = " ",
|
require = " ",
|
||||||
source = " ",
|
source = " ",
|
||||||
start = "",
|
start = " ",
|
||||||
task = "✔ ",
|
task = "✔ ",
|
||||||
list = {
|
list = {
|
||||||
"●",
|
"●",
|
||||||
|
@ -514,7 +517,7 @@ Any operation can be started from the UI, with a sub command or an API function:
|
||||||
<!-- commands:start -->
|
<!-- commands:start -->
|
||||||
|
|
||||||
| Command | Lua | Description |
|
| Command | Lua | Description |
|
||||||
| ------------------------- | -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| --- | --- | --- | --- |
|
||||||
| `:Lazy build {plugins}` | `require("lazy").build(opts)` | Rebuild a plugin |
|
| `:Lazy build {plugins}` | `require("lazy").build(opts)` | Rebuild a plugin |
|
||||||
| `:Lazy check [plugins]` | `require("lazy").check(opts?)` | Check for updates and show the log (git fetch) |
|
| `:Lazy check [plugins]` | `require("lazy").check(opts?)` | Check for updates and show the log (git fetch) |
|
||||||
| `:Lazy clean [plugins]` | `require("lazy").clean(opts?)` | Clean plugins that are no longer needed |
|
| `:Lazy clean [plugins]` | `require("lazy").clean(opts?)` | Clean plugins that are no longer needed |
|
||||||
|
@ -782,39 +785,39 @@ To uninstall **lazy.nvim**, you need to remove the following files and directori
|
||||||
<!-- colors:start -->
|
<!-- colors:start -->
|
||||||
|
|
||||||
| Highlight Group | Default Group | Description |
|
| Highlight Group | Default Group | Description |
|
||||||
| --------------------- | -------------------------- | --------------------------------------------------- |
|
| --- | --- | --- |
|
||||||
| **LazyButton** | **_CursorLine_** | |
|
| **LazyButton** | ***CursorLine*** | |
|
||||||
| **LazyButtonActive** | **_Visual_** | |
|
| **LazyButtonActive** | ***Visual*** | |
|
||||||
| **LazyComment** | **_Comment_** | |
|
| **LazyComment** | ***Comment*** | |
|
||||||
| **LazyCommit** | **_@variable.builtin_** | commit ref |
|
| **LazyCommit** | ***@variable.builtin*** | commit ref |
|
||||||
| **LazyCommitIssue** | **_Number_** | |
|
| **LazyCommitIssue** | ***Number*** | |
|
||||||
| **LazyCommitScope** | **_Italic_** | conventional commit scope |
|
| **LazyCommitScope** | ***Italic*** | conventional commit scope |
|
||||||
| **LazyCommitType** | **_Title_** | conventional commit type |
|
| **LazyCommitType** | ***Title*** | conventional commit type |
|
||||||
| **LazyDimmed** | **_Conceal_** | property |
|
| **LazyDimmed** | ***Conceal*** | property |
|
||||||
| **LazyDir** | **_@markup.link_** | directory |
|
| **LazyDir** | ***@markup.link*** | directory |
|
||||||
| **LazyH1** | **_IncSearch_** | home button |
|
| **LazyH1** | ***IncSearch*** | home button |
|
||||||
| **LazyH2** | **_Bold_** | titles |
|
| **LazyH2** | ***Bold*** | titles |
|
||||||
| **LazyLocal** | **_Constant_** | |
|
| **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 |
|
||||||
| **LazyProgressTodo** | **_LineNr_** | progress bar todo |
|
| **LazyProgressTodo** | ***LineNr*** | progress bar todo |
|
||||||
| **LazyProp** | **_Conceal_** | property |
|
| **LazyProp** | ***Conceal*** | property |
|
||||||
| **LazyReasonCmd** | **_Operator_** | |
|
| **LazyReasonCmd** | ***Operator*** | |
|
||||||
| **LazyReasonEvent** | **_Constant_** | |
|
| **LazyReasonEvent** | ***Constant*** | |
|
||||||
| **LazyReasonFt** | **_Character_** | |
|
| **LazyReasonFt** | ***Character*** | |
|
||||||
| **LazyReasonImport** | **_Identifier_** | |
|
| **LazyReasonImport** | ***Identifier*** | |
|
||||||
| **LazyReasonKeys** | **_Statement_** | |
|
| **LazyReasonKeys** | ***Statement*** | |
|
||||||
| **LazyReasonPlugin** | **_Special_** | |
|
| **LazyReasonPlugin** | ***Special*** | |
|
||||||
| **LazyReasonRequire** | **_@variable.parameter_** | |
|
| **LazyReasonRequire** | ***@variable.parameter*** | |
|
||||||
| **LazyReasonRuntime** | **_@macro_** | |
|
| **LazyReasonRuntime** | ***@macro*** | |
|
||||||
| **LazyReasonSource** | **_Character_** | |
|
| **LazyReasonSource** | ***Character*** | |
|
||||||
| **LazyReasonStart** | **_@variable.member_** | |
|
| **LazyReasonStart** | ***@variable.member*** | |
|
||||||
| **LazySpecial** | **_@punctuation.special_** | |
|
| **LazySpecial** | ***@punctuation.special*** | |
|
||||||
| **LazyTaskError** | **_ErrorMsg_** | task errors |
|
| **LazyTaskError** | ***ErrorMsg*** | task errors |
|
||||||
| **LazyTaskOutput** | **_MsgArea_** | task output |
|
| **LazyTaskOutput** | ***MsgArea*** | task output |
|
||||||
| **LazyUrl** | **_@markup.link_** | url |
|
| **LazyUrl** | ***@markup.link*** | url |
|
||||||
| **LazyValue** | **_@string_** | value of a property |
|
| **LazyValue** | ***@string*** | value of a property |
|
||||||
|
|
||||||
<!-- colors:end -->
|
<!-- colors:end -->
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,8 @@ M.defaults = {
|
||||||
-- leave nil when passing the spec as the first argument to setup()
|
-- leave nil when passing the spec as the first argument to setup()
|
||||||
spec = nil, ---@type LazySpec
|
spec = nil, ---@type LazySpec
|
||||||
lockfile = vim.fn.stdpath("config") .. "/lazy-lock.json", -- lockfile generated after running update.
|
lockfile = vim.fn.stdpath("config") .. "/lazy-lock.json", -- lockfile generated after running update.
|
||||||
concurrency = jit.os:find("Windows") and (vim.uv.available_parallelism() * 2) or nil, ---@type number limit the maximum amount of concurrent tasks
|
---@type number? limit the maximum amount of concurrent tasks
|
||||||
|
concurrency = jit.os:find("Windows") and (vim.uv.available_parallelism() * 2) or nil,
|
||||||
git = {
|
git = {
|
||||||
-- defaults for the `Lazy log` command
|
-- defaults for the `Lazy log` command
|
||||||
-- log = { "--since=3 days ago" }, -- show commits from the last 3 days
|
-- log = { "--since=3 days ago" }, -- show commits from the last 3 days
|
||||||
|
@ -48,6 +49,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",
|
||||||
|
-- The backdrop opacity. 0 is fully opaque, 100 is fully transparent.
|
||||||
|
backdrop = 60,
|
||||||
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
|
-- Show pills on top of the Lazy window
|
||||||
|
|
|
@ -15,12 +15,15 @@ local ViewConfig = require("lazy.view.config")
|
||||||
---@field persistent? boolean
|
---@field persistent? boolean
|
||||||
---@field ft? string
|
---@field ft? string
|
||||||
---@field noautocmd? boolean
|
---@field noautocmd? boolean
|
||||||
|
---@field backdrop? float
|
||||||
|
|
||||||
---@class LazyFloat
|
---@class LazyFloat
|
||||||
---@field buf number
|
---@field buf number
|
||||||
---@field win number
|
---@field win number
|
||||||
---@field opts LazyFloatOptions
|
---@field opts LazyFloatOptions
|
||||||
---@field win_opts LazyWinOpts
|
---@field win_opts LazyWinOpts
|
||||||
|
---@field backdrop_buf number
|
||||||
|
---@field backdrop_win number
|
||||||
---@overload fun(opts?:LazyFloatOptions):LazyFloat
|
---@overload fun(opts?:LazyFloatOptions):LazyFloat
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
|
@ -43,6 +46,7 @@ function M:init(opts)
|
||||||
size = Config.options.ui.size,
|
size = Config.options.ui.size,
|
||||||
style = "minimal",
|
style = "minimal",
|
||||||
border = Config.options.ui.border or "none",
|
border = Config.options.ui.border or "none",
|
||||||
|
backdrop = Config.options.ui.backdrop or 60,
|
||||||
zindex = 50,
|
zindex = 50,
|
||||||
}, opts or {})
|
}, opts or {})
|
||||||
|
|
||||||
|
@ -62,7 +66,7 @@ function M:init(opts)
|
||||||
}
|
}
|
||||||
self:mount()
|
self:mount()
|
||||||
self:on_key(ViewConfig.keys.close, self.close)
|
self:on_key(ViewConfig.keys.close, self.close)
|
||||||
self:on({ "BufDelete", "BufHidden" }, self.close, { once = true })
|
self:on({ "BufDelete", "BufHidden" }, self.close, { once = false })
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -114,6 +118,24 @@ function M:mount()
|
||||||
self.buf = vim.api.nvim_create_buf(false, true)
|
self.buf = vim.api.nvim_create_buf(false, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self.opts.backdrop and self.opts.backdrop < 100 then
|
||||||
|
self.backdrop_buf = vim.api.nvim_create_buf(false, true)
|
||||||
|
self.backdrop_win = vim.api.nvim_open_win(self.backdrop_buf, false, {
|
||||||
|
relative = "editor",
|
||||||
|
width = vim.o.columns,
|
||||||
|
height = vim.o.lines,
|
||||||
|
row = 0,
|
||||||
|
col = 0,
|
||||||
|
style = "minimal",
|
||||||
|
focusable = false,
|
||||||
|
zindex = self.opts.zindex - 1,
|
||||||
|
})
|
||||||
|
vim.api.nvim_set_hl(0, "LazyBackdrop", { bg = "#000000", default = true })
|
||||||
|
Util.wo(self.backdrop_win, "winhighlight", "Normal:LazyBackdrop")
|
||||||
|
Util.wo(self.backdrop_win, "winblend", self.opts.backdrop)
|
||||||
|
vim.bo[self.backdrop_buf].buftype = "nofile"
|
||||||
|
end
|
||||||
|
|
||||||
self:layout()
|
self:layout()
|
||||||
self.win = vim.api.nvim_open_win(self.buf, true, self.win_opts)
|
self.win = vim.api.nvim_open_win(self.buf, true, self.win_opts)
|
||||||
self:focus()
|
self:focus()
|
||||||
|
@ -149,6 +171,14 @@ function M:mount()
|
||||||
end
|
end
|
||||||
config.style = self.opts.style ~= "" and self.opts.style or nil
|
config.style = self.opts.style ~= "" and self.opts.style or nil
|
||||||
vim.api.nvim_win_set_config(self.win, config)
|
vim.api.nvim_win_set_config(self.win, config)
|
||||||
|
|
||||||
|
if self.backdrop_win and vim.api.nvim_win_is_valid(self.backdrop_win) then
|
||||||
|
vim.api.nvim_win_set_config(self.backdrop_win, {
|
||||||
|
width = vim.o.columns,
|
||||||
|
height = vim.o.lines,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
opts()
|
opts()
|
||||||
vim.api.nvim_exec_autocmds("User", { pattern = "LazyFloatResized", modeline = false })
|
vim.api.nvim_exec_autocmds("User", { pattern = "LazyFloatResized", modeline = false })
|
||||||
end,
|
end,
|
||||||
|
@ -204,7 +234,18 @@ function M:close(opts)
|
||||||
if wipe then
|
if wipe then
|
||||||
self.buf = nil
|
self.buf = nil
|
||||||
end
|
end
|
||||||
|
local backdrop_buf = self.backdrop_buf
|
||||||
|
local backdrop_win = self.backdrop_win
|
||||||
|
self.backdrop_buf = nil
|
||||||
|
self.backdrop_win = nil
|
||||||
|
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
|
if backdrop_win and vim.api.nvim_win_is_valid(backdrop_win) then
|
||||||
|
vim.api.nvim_win_close(backdrop_win, true)
|
||||||
|
end
|
||||||
|
if backdrop_buf and vim.api.nvim_buf_is_valid(backdrop_buf) then
|
||||||
|
vim.api.nvim_buf_delete(backdrop_buf, { force = true })
|
||||||
|
end
|
||||||
if win and vim.api.nvim_win_is_valid(win) then
|
if win and vim.api.nvim_win_is_valid(win) then
|
||||||
vim.api.nvim_win_close(win, true)
|
vim.api.nvim_win_close(win, true)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue