Add borders and background to floating windows
This commit is contained in:
parent
96fcac9aa0
commit
80d6db97cf
3 changed files with 50 additions and 3 deletions
|
|
@ -9,8 +9,8 @@ return {
|
|||
-- ============================================================================
|
||||
|
||||
Normal = { fg = c.fg, bg = c.bg },
|
||||
NormalFloat = { fg = c.fg, bg = c.NONE },
|
||||
FloatBorder = { fg = c.fg_stronger, bg = c.NONE },
|
||||
NormalFloat = { fg = c.fg, bg = c.bg_ui },
|
||||
FloatBorder = { fg = c.fg_weaker, bg = c.bg_ui },
|
||||
|
||||
-- ============================================================================
|
||||
-- Cursor & Line Highlighting
|
||||
|
|
|
|||
|
|
@ -95,9 +95,55 @@ vim.diagnostic.config({
|
|||
update_in_insert = false, -- Don't update diagnostics while typing
|
||||
severity_sort = true, -- Sort by severity (errors first)
|
||||
float = {
|
||||
border = "rounded",
|
||||
border = "single",
|
||||
source = "always", -- Show diagnostic source
|
||||
header = "",
|
||||
prefix = "",
|
||||
},
|
||||
})
|
||||
|
||||
-- Configure LSP floating windows with borders and padding
|
||||
-- Custom border with box-drawing characters flush to window edges
|
||||
-- Using heavy/light box-drawing characters positioned at cell edges
|
||||
local border = {
|
||||
{ "🭽", "FloatBorder" }, -- top-left corner
|
||||
{ "▔", "FloatBorder" }, -- top horizontal line (at top edge)
|
||||
{ "🭾", "FloatBorder" }, -- top-right corner
|
||||
{ "▕", "FloatBorder" }, -- right vertical line (at right edge)
|
||||
{ "🭿", "FloatBorder" }, -- bottom-right corner
|
||||
{ "▁", "FloatBorder" }, -- bottom horizontal line (at bottom edge)
|
||||
{ "🭼", "FloatBorder" }, -- bottom-left corner
|
||||
{ "▏", "FloatBorder" }, -- left vertical line (at left edge)
|
||||
}
|
||||
|
||||
-- Override the default open_floating_preview to add padding by modifying content
|
||||
local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview
|
||||
function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...)
|
||||
opts = opts or {}
|
||||
opts.border = opts.border or border
|
||||
|
||||
-- Add padding by wrapping content with empty lines and spacing
|
||||
if type(contents) == "table" and #contents > 0 then
|
||||
-- Add empty lines at top and bottom
|
||||
table.insert(contents, 1, "")
|
||||
table.insert(contents, 1, "")
|
||||
table.insert(contents, "")
|
||||
table.insert(contents, "")
|
||||
|
||||
-- Add horizontal padding (spaces) to each content line
|
||||
for i = 3, #contents - 2 do
|
||||
if type(contents[i]) == "string" then
|
||||
contents[i] = " " .. contents[i] .. " "
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return orig_util_open_floating_preview(contents, syntax, opts, ...)
|
||||
end
|
||||
|
||||
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
|
||||
border = border,
|
||||
})
|
||||
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
|
||||
border = border,
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue