mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
feat(float): add winborder option (#31074)
Problem: There is currently no global option to define the default border style for floating windows. This leads to repetitive code when developers need consistent styling across multiple floating windows. Solution: Introduce a global option winborder to specify the default border style for floating windows. When a floating window is created without explicitly specifying a border style, the value of the winborder option will be used. This simplifies configuration and ensures consistency in floating window appearance. Co-authored-by: Gregory Anders <greg@gpanders.com>
This commit is contained in:
@@ -6,17 +6,6 @@ local uv = vim.uv
|
||||
|
||||
local M = {}
|
||||
|
||||
local default_border = {
|
||||
{ '', 'NormalFloat' },
|
||||
{ '', 'NormalFloat' },
|
||||
{ '', 'NormalFloat' },
|
||||
{ ' ', 'NormalFloat' },
|
||||
{ '', 'NormalFloat' },
|
||||
{ '', 'NormalFloat' },
|
||||
{ '', 'NormalFloat' },
|
||||
{ ' ', 'NormalFloat' },
|
||||
}
|
||||
|
||||
--- @param border string|(string|[string,string])[]
|
||||
local function border_error(border)
|
||||
error(
|
||||
@@ -43,7 +32,11 @@ local border_size = {
|
||||
--- @return integer height
|
||||
--- @return integer width
|
||||
local function get_border_size(opts)
|
||||
local border = opts and opts.border or default_border
|
||||
local border = opts and opts.border or vim.o.winborder
|
||||
|
||||
if border == '' then
|
||||
border = 'none'
|
||||
end
|
||||
|
||||
if type(border) == 'string' then
|
||||
if not border_size[border] then
|
||||
@@ -884,7 +877,7 @@ function M.make_floating_popup_options(width, height, opts)
|
||||
or 'cursor',
|
||||
style = 'minimal',
|
||||
width = width,
|
||||
border = opts.border or default_border,
|
||||
border = opts.border,
|
||||
zindex = opts.zindex or (api.nvim_win_get_config(0).zindex or 49) + 1,
|
||||
title = title,
|
||||
title_pos = title_pos,
|
||||
|
Reference in New Issue
Block a user