This commit is contained in:
hrsh7th
2022-05-09 11:55:29 +09:00
parent f81bfee109
commit a226b6a4ff

View File

@@ -285,39 +285,33 @@ cmp.setup = setmetatable({
}) })
-- In InsertEnter autocmd, vim will detects mode=normal unexpectedly. -- In InsertEnter autocmd, vim will detects mode=normal unexpectedly.
autocmd.subscribe( local on_insert_enter = function()
{ 'InsertEnter', 'CmdlineEnter' }, if config.enabled() then
async.debounce_next_tick(function() cmp.config.compare.scopes:update()
if config.enabled() then cmp.config.compare.locality:update()
cmp.config.compare.scopes:update() cmp.core:prepare()
cmp.config.compare.locality:update() cmp.core:on_change('InsertEnter')
cmp.core:prepare() end
cmp.core:on_change('InsertEnter') end
end autocmd.subscribe({ 'InsertEnter', 'CmdlineEnter' }, async.debounce_next_tick(on_insert_enter))
end)
)
-- async.throttle is needed for performance. The mapping `:<C-u>...<CR>` will fire `CmdlineChanged` for each character. -- async.throttle is needed for performance. The mapping `:<C-u>...<CR>` will fire `CmdlineChanged` for each character.
autocmd.subscribe( local on_text_changed = function()
{ 'TextChangedI', 'TextChangedP', 'CmdlineChanged' }, if config.enabled() then
async.debounce_next_tick(function() cmp.core:on_change('TextChanged')
if config.enabled() then end
cmp.core:on_change('TextChanged') end
end autocmd.subscribe({ 'TextChangedI', 'TextChangedP' }, on_text_changed)
end) autocmd.subscribe('CmdlineChanged', async.debounce_next_tick(on_text_changed))
)
autocmd.subscribe( autocmd.subscribe('CursorMovedI', function()
'CursorMovedI', if config.enabled() then
async.debounce_next_tick(function() cmp.core:on_moved()
if config.enabled() then
cmp.core:on_moved()
else else
cmp.core:reset() cmp.core:reset()
cmp.core.view:close() cmp.core.view:close()
end end
end) end)
)
-- If make this asynchronous, the completion menu will not close when the command output is displayed. -- If make this asynchronous, the completion menu will not close when the command output is displayed.
autocmd.subscribe({ 'InsertLeave', 'CmdlineLeave' }, function() autocmd.subscribe({ 'InsertLeave', 'CmdlineLeave' }, function()