This commit is contained in:
hrsh7th
2021-11-03 03:16:45 +09:00
parent c67ed9d8bc
commit 2a58b8f926
3 changed files with 5 additions and 10 deletions

View File

@@ -11,7 +11,6 @@ local api = require('cmp.utils.api')
---@field public option cmp.ContextOption ---@field public option cmp.ContextOption
---@field public filetype string ---@field public filetype string
---@field public time number ---@field public time number
---@field public mode string
---@field public bufnr number ---@field public bufnr number
---@field public cursor vim.Position|lsp.Position ---@field public cursor vim.Position|lsp.Position
---@field public cursor_line string ---@field public cursor_line string
@@ -45,7 +44,6 @@ context.new = function(prev_context, option)
self.option = option or { reason = types.cmp.ContextReason.None } self.option = option or { reason = types.cmp.ContextReason.None }
self.filetype = vim.api.nvim_buf_get_option(0, 'filetype') self.filetype = vim.api.nvim_buf_get_option(0, 'filetype')
self.time = vim.loop.now() self.time = vim.loop.now()
self.mode = vim.api.nvim_get_mode().mode
self.bufnr = vim.api.nvim_get_current_buf() self.bufnr = vim.api.nvim_get_current_buf()
local cursor = api.get_cursor() local cursor = api.get_cursor()

View File

@@ -270,13 +270,10 @@ cmp.setup = setmetatable({
}) })
autocmd.subscribe('InsertEnter', function() autocmd.subscribe('InsertEnter', function()
-- Avoid unexpected mode detection (mode() function will returns `normal mode` on the InsertEnter event.)
vim.schedule(function()
if config.enabled() then if config.enabled() then
cmp.core:prepare() cmp.core:prepare()
cmp.core:on_change('InsertEnter') cmp.core:on_change('InsertEnter')
end end
end)
end) end)
autocmd.subscribe('TextChanged', function() autocmd.subscribe('TextChanged', function()

View File

@@ -17,7 +17,7 @@ api.is_insert_mode = function()
'i', 'i',
'ic', 'ic',
'ix', 'ix',
}, vim.api.nvim_get_mode().mode) }, vim.api.nvim_get_mode().mode) or vim.v.insertmode == 'i'
end end
api.is_cmdline_mode = function() api.is_cmdline_mode = function()