Skip to content

Commit

Permalink
feat(background): enable change background color in preview window
Browse files Browse the repository at this point in the history
  • Loading branch information
orumin committed Mar 22, 2024
1 parent 238070a commit 76ddfba
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lua/glow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ local glow = {}
---@field pager boolean display output in pager style
---@field width integer floating window width
---@field height integer floating window height
---@field background string? floating window background color
-- default configurations
local config = {
glow_path = vim.fn.exepath("glow"),
Expand All @@ -33,6 +34,7 @@ local config = {
pager = false,
width = 100,
height = 100,
background = nil
}

-- default configs
Expand Down Expand Up @@ -126,11 +128,15 @@ local function open_window(cmd_args)
-- create preview buffer and set local options
buf = vim.api.nvim_create_buf(false, true)
win = vim.api.nvim_open_win(buf, true, win_opts)

local nsid = vim.api.nvim_create_namespace("glow")
vim.api.nvim_win_set_hl_ns(win, nsid)
-- options
vim.api.nvim_win_set_option(win, "winblend", 0)
vim.api.nvim_buf_set_option(buf, "bufhidden", "wipe")
vim.api.nvim_buf_set_option(buf, "filetype", "glowpreview")
vim.wo[win].winblend = 0
vim.bo[buf].bufhidden = "wipe"
vim.bo[buf].filetype = "glowpreview"
if glow.config.background then
vim.api.nvim_set_hl(nsid, "NormalFloat", {bg=glow.config.background})
end

-- keymaps
local keymaps_opts = { silent = true, buffer = buf }
Expand Down

0 comments on commit 76ddfba

Please sign in to comment.