Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
deathbeam committed Apr 25, 2024
1 parent ca7224e commit 24dea4f
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions lua/autocomplete/buffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,6 @@ local function complete(prefix, cmp_start, items)
vim.fn.complete(cmp_start + 1, items)
end

local function update_info(value, selected)
if not value or #value == 0 then
return false
end

local wininfo = vim.api.nvim_complete_set(selected, { info = value })
if wininfo.winid and wininfo.bufnr then
vim.wo[wininfo.winid].conceallevel = 2
vim.wo[wininfo.winid].concealcursor = 'niv'
vim.bo[wininfo.bufnr].syntax = 'markdown'
return true
end

return false
end

local function complete_treesitter(bufnr, prefix, cmp_start)
-- Check if treesitter is available
local ok, parsers = pcall(require, 'nvim-treesitter.parsers')
Expand Down Expand Up @@ -218,7 +202,7 @@ local function complete_changed(args)
methods.completionItem_resolve,
completion_item,
function(result)
if not result.documentation then
if not result.documentation or not result.documentation.value or #result.documentation.value == 0 then
return
end

Expand All @@ -227,7 +211,12 @@ local function complete_changed(args)
return
end

update_info(result.documentation.value, selected)
local wininfo = vim.api.nvim_complete_set(selected, { info = result.documentation.value })
if wininfo.winid and wininfo.bufnr then
vim.wo[wininfo.winid].conceallevel = 2
vim.wo[wininfo.winid].concealcursor = 'niv'
vim.bo[wininfo.bufnr].syntax = 'markdown'
end
end,
args.buf
)
Expand Down

0 comments on commit 24dea4f

Please sign in to comment.