dev (#956)
* Adjust empty line count * Implement vim.api.nvim_create_autocmd (#844) * Implement vim.api.nvim_create_autocmd * Only use vim.api.nvim_create_autocmd on nighly * Cleanup * cleanup * Rename autos.lua to autocmds.lua * Fix forgot to rename autos to autocmds * Remove legacy autocmd * Add descriptions on autocmds * Update descriptions on autocmds * Update CmpStatus command to lua API (#922) Signed-off-by: Micah Halter <micah@balena.io> * Move highlights to nvim_set_hl lua API (#925) Signed-off-by: Micah Halter <micah@balena.io> * Add default to highlight * Refactor autocmds * fmt * Improve performance * Fix bug * Improve matching logic Fixes https://github.com/hrsh7th/nvim-cmp/discussions/954 * Fix format * Improve performance Fix #825 * Fix cmdline redraw bug * Fix event Co-authored-by: hrsh7th <> Co-authored-by: zer09 <zer09@users.noreply.github.com> Co-authored-by: Micah Halter <micah@mehalter.com>
This commit is contained in:
@@ -5,6 +5,7 @@ local feedkeys = require('cmp.utils.feedkeys')
|
||||
local autocmd = require('cmp.utils.autocmd')
|
||||
local keymap = require('cmp.utils.keymap')
|
||||
local misc = require('cmp.utils.misc')
|
||||
local async = require('cmp.utils.async')
|
||||
|
||||
local cmp = {}
|
||||
|
||||
@@ -283,51 +284,48 @@ cmp.setup = setmetatable({
|
||||
end,
|
||||
})
|
||||
|
||||
autocmd.subscribe('InsertEnter', function()
|
||||
feedkeys.call('', 'i', function()
|
||||
-- In InsertEnter autocmd, vim will detects mode=normal unexpectedly.
|
||||
autocmd.subscribe(
|
||||
{ 'InsertEnter', 'CmdlineEnter' },
|
||||
async.debounce_safe_state(function()
|
||||
if config.enabled() then
|
||||
cmp.config.compare.scopes:update()
|
||||
cmp.config.compare.locality:update()
|
||||
cmp.core:prepare()
|
||||
cmp.core:on_change('InsertEnter')
|
||||
end
|
||||
end)
|
||||
end)
|
||||
)
|
||||
|
||||
autocmd.subscribe('InsertLeave', function()
|
||||
cmp.core:reset()
|
||||
cmp.core.view:close()
|
||||
end)
|
||||
-- async.throttle is needed for performance. The mapping `:<C-u>...<CR>` will fire `CmdlineChanged` for each character.
|
||||
autocmd.subscribe(
|
||||
{ 'TextChangedI', 'TextChangedP', 'CmdlineChanged' },
|
||||
async.debounce_safe_state(function()
|
||||
if config.enabled() then
|
||||
cmp.core:on_change('TextChanged')
|
||||
end
|
||||
end)
|
||||
)
|
||||
|
||||
autocmd.subscribe('CmdlineEnter', function()
|
||||
-- If make this asynchronous, the completion menu will not close when the command output is displayed.
|
||||
autocmd.subscribe({ 'InsertLeave', 'CmdlineLeave' }, function()
|
||||
if config.enabled() then
|
||||
cmp.core:prepare()
|
||||
cmp.core:on_change('InsertEnter')
|
||||
end
|
||||
end)
|
||||
|
||||
autocmd.subscribe('CmdlineLeave', function()
|
||||
cmp.core:reset()
|
||||
cmp.core.view:close()
|
||||
end)
|
||||
|
||||
autocmd.subscribe('TextChanged', function()
|
||||
if config.enabled() then
|
||||
cmp.core:on_change('TextChanged')
|
||||
end
|
||||
end)
|
||||
|
||||
autocmd.subscribe('CursorMoved', function()
|
||||
if config.enabled() then
|
||||
cmp.core:on_moved()
|
||||
else
|
||||
cmp.core:reset()
|
||||
cmp.core.view:close()
|
||||
end
|
||||
end)
|
||||
|
||||
autocmd.subscribe('InsertEnter', function()
|
||||
cmp.config.compare.scopes:update()
|
||||
cmp.config.compare.locality:update()
|
||||
end)
|
||||
autocmd.subscribe(
|
||||
'CursorMovedI',
|
||||
async.debounce_safe_state(function()
|
||||
if config.enabled() then
|
||||
cmp.core:on_moved()
|
||||
else
|
||||
cmp.core:reset()
|
||||
cmp.core.view:close()
|
||||
end
|
||||
end)
|
||||
)
|
||||
|
||||
cmp.event:on('complete_done', function(evt)
|
||||
if evt.entry then
|
||||
|
||||
Reference in New Issue
Block a user