Skip to content

Commit

Permalink
feat: change Fidget window border color (close #174)
Browse files Browse the repository at this point in the history
  • Loading branch information
j-hui committed Dec 6, 2023
1 parent 08c4e13 commit b0ca757
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
9 changes: 9 additions & 0 deletions doc/fidget.md
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ i.e., message text.
Note that we use this blanket highlight for all messages to avoid adding
separate highlights to each line (whose lengths may vary).

Set to empty string to keep your theme defaults.

With `winblend` set to anything less than `100`, this will also affect the
background color in the notification box area (see `winblend` docs).

Expand Down Expand Up @@ -502,6 +504,13 @@ See also: options for [nvim_open_win()](<https://neovim.io/doc/user/api.html#nvi

Type: `"none" | "single" | "double" | "rounded" | "solid" | "shadow" | string[]` (default: `"none"`)

notification.window.border_hl
: Highlight group for notification window border

Set to empty string to keep your theme's default `FloatBorder` highlight.

Type: `string` (default: `""`)

notification.window.zindex
: Stacking priority of the notification window

Expand Down
22 changes: 21 additions & 1 deletion lua/fidget/notification/window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ require("fidget.options").declare(M, "notification.window", {
--- Note that we use this blanket highlight for all messages to avoid adding
--- separate highlights to each line (whose lengths may vary).
---
--- Set to empty string to keep your theme defaults.
---
--- With `winblend` set to anything less than `100`, this will also affect the
--- background color in the notification box area (see `winblend` docs).
---
Expand Down Expand Up @@ -50,6 +52,13 @@ require("fidget.options").declare(M, "notification.window", {
---@type "none" | "single" | "double" | "rounded" | "solid" | "shadow" | string[]
border = "none",

--- Highlight group for notification window border
---
--- Set to empty string to keep your theme's default `FloatBorder` highlight.
---
---@type string
border_hl = "",

--- Stacking priority of the notification window
---
--- Note that the default priority for Vim windows is 50.
Expand Down Expand Up @@ -353,9 +362,20 @@ function M.get_window(row, col, anchor, width, height)
})
end

local winhighlight = ""

if M.options.normal_hl ~= "" then
-- Instead of NormalFloat
winhighlight = winhighlight .. "NormalNC:" .. M.options.normal_hl
end

if M.options.border_hl ~= "" then
winhighlight = winhighlight .. ",FloatBorder:" .. M.options.border_hl
end

M.win_set_local_options(state.window_id, {
winblend = M.options.winblend, -- Transparent background
winhighlight = "NormalNC:" .. M.options.normal_hl, -- Instead of NormalFloat
winhighlight = winhighlight ~= "" and winhighlight or nil,
})
return state.window_id
end
Expand Down

0 comments on commit b0ca757

Please sign in to comment.