Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit eb58fef

Browse files
committed
Add support for documentation border
Signed-off-by: Tomas Slusny <[email protected]>
1 parent b837603 commit eb58fef

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ require("autocomplete.signature").setup {
4141

4242
-- buffer autocompletion with LSP and Tree-sitter
4343
require("autocomplete.buffer").setup {
44+
border = nil, -- Documentation border style
4445
entry_mapper = nil, -- Custom completion entry mapper
45-
debounce_delay = 100
46+
debounce_delay = 100,
4647
}
4748

4849
-- cmdline autocompletion

lua/autocomplete/buffer.lua

+14-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ local function complete(prefix, cmp_start, items)
3030
elseif entry1_under < entry2_under then
3131
return true
3232
end
33+
return false
3334
end)
3435

3536
vim.fn.complete(cmp_start + 1, items)
@@ -150,6 +151,14 @@ local function complete_changed(args)
150151
local cur_info = vim.fn.complete_info()
151152
local selected = cur_info.selected
152153

154+
if
155+
M.config.border
156+
and cur_info.preview_winid
157+
and vim.api.nvim_win_is_valid(cur_info.preview_winid)
158+
then
159+
vim.api.nvim_win_set_config(cur_info.preview_winid, { border = M.config.border })
160+
end
161+
153162
util.debounce(state.entries.info, M.config.debounce_delay, function()
154163
local completion_item = vim.tbl_get(cur_item, 'user_data', 'nvim', 'lsp', 'completion_item')
155164
if not completion_item then
@@ -175,7 +184,7 @@ local function complete_changed(args)
175184
end
176185

177186
local info = vim.fn.complete_info()
178-
if not info.items or not info.selected or not info.selected == selected then
187+
if not info.items or not info.selected or info.selected ~= selected then
179188
return
180189
end
181190

@@ -195,6 +204,7 @@ local function complete_changed(args)
195204
end
196205

197206
M.config = {
207+
border = nil, -- Documentation border style
198208
entry_mapper = nil, -- Custom completion entry mapper
199209
debounce_delay = 100,
200210
}
@@ -227,6 +237,9 @@ function M.setup(config)
227237
if not client then
228238
return
229239
end
240+
if not vim.lsp.completion or not vim.lsp.completion.enable then
241+
return
242+
end
230243
vim.lsp.completion.enable(true, client.id, event.buf, { autotrigger = false })
231244
end,
232245
})

0 commit comments

Comments
 (0)