Check buftype is prompt

Improve incomplete handling
This commit is contained in:
hrsh7th
2021-08-10 16:57:54 +09:00
parent 35d04be45e
commit 22ec3ad442
4 changed files with 41 additions and 28 deletions

18
lua/cmp/utils/check.lua Normal file
View File

@@ -0,0 +1,18 @@
local check = {}
check.ok = function()
local ng = false
ng = ng or vim.api.nvim_buf_get_option(0, 'buftype') == 'prompt'
ng = ng or string.sub(vim.api.nvim_get_mode().mode, 1, 1) ~= 'i'
return not ng
end
check.wrap = function(callback)
return function(...)
if check.ok() then
callback(...)
end
end
end
return check