Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(background): enable change background color in preview window #133

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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