Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #386 from ranjithshegde/floating_opts
Browse files Browse the repository at this point in the history
Add border to floating windows
  • Loading branch information
vigoux authored Aug 2, 2021
2 parents 22624f0 + 713f3fc commit 139fb6c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
11 changes: 11 additions & 0 deletions doc/completion-nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@ g:completion_enable_auto_signature *g:completion_enable_auto_signature*

default value: 1

g:completion_popup_border *g:completion_popup_border*

This variable sets border for auto hover popup and signature help popup.
The variable is not created by default so that there is no border by
default. You can set it as per neovim's popup/preview
window sepcifications.

available options: 'single', 'double', 'rounded', 'solid' and 'shadow'

default value: variable not declared

g:completion_enable_auto_paren *g:completion_enable_auto_paren*

Enable the auto insert parenthesis feature. completion-nvim will
Expand Down
12 changes: 12 additions & 0 deletions lua/completion/hover.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ local make_floating_popup_options = function(width, height, opts)
col = opts.col - width - 1
end

local default_border = {
{"", "NormalFloat"},
{"", "NormalFloat"},
{"", "NormalFloat"},
{" ", "NormalFloat"},
{"", "NormalFloat"},
{"", "NormalFloat"},
{"", "NormalFloat"},
{" ", "NormalFloat"},
}

return {
col = col,
height = height,
Expand All @@ -81,6 +92,7 @@ local make_floating_popup_options = function(width, height, opts)
focusable = false,
style = 'minimal',
width = width,
border = vim.g.completion_popup_border or default_border
}
end

Expand Down
6 changes: 5 additions & 1 deletion lua/completion/signature_help.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,15 @@ M.autoOpenSignatureHelp = function()

-- if `lines` can be trimmed, it is modified in place
local trimmed_lines_filetype = vim.lsp.util.try_trim_markdown_code_blocks(lines)
local opts = {}
if vim.g.completion_popup_border then
opts.border = vim.g.completion_popup_border
end
local bufnr, _ = vim.lsp.util.open_floating_preview(
-- TODO show popup when signatures is empty?
vim.lsp.util.trim_empty_lines(lines),
trimmed_lines_filetype,
{}
opts
)
-- setup a variable for floating window, fix #223
vim.api.nvim_buf_set_var(bufnr, "lsp_floating", true)
Expand Down

0 comments on commit 139fb6c

Please sign in to comment.