Skip to content

Commit

Permalink
feat: run callback for cmp.show, even if menu is open
Browse files Browse the repository at this point in the history
  • Loading branch information
Saghen committed Dec 29, 2024
1 parent 33b82e5 commit a1476d3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lua/blink/cmp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ function cmp.is_visible()
or require('blink.cmp.completion.windows.ghost_text').is_open()
end

--- @params opts? { providers?: string[], callback?: fun() }
--- @params opts? { providers?: string[], callback?: fun(did_show: boolean) }
function cmp.show(opts)
if require('blink.cmp.completion.windows.menu').win:is_open() and not (opts and opts.providers) then return end
if require('blink.cmp.completion.windows.menu').win:is_open() and not (opts and opts.providers) then
if opts and opts.callback then opts.callback(false) end
return
end

vim.schedule(function()
require('blink.cmp.completion.windows.menu').auto_show = true
Expand All @@ -48,7 +51,7 @@ function cmp.show(opts)
providers = opts and opts.providers,
trigger_kind = 'manual',
})
if opts and opts.callback then opts.callback() end
if opts and opts.callback then opts.callback(true) end
end)
return true
end
Expand Down

0 comments on commit a1476d3

Please sign in to comment.