Fix multiple setup.buffer

This commit is contained in:
hrsh7th
2021-08-29 22:23:54 +09:00
parent b9ef85d483
commit 25a4d9c0be
2 changed files with 12 additions and 3 deletions

View File

@@ -26,9 +26,9 @@ end
---@param c cmp.ConfigSchema
---@param bufnr number|nil
config.set_buffer = function(c, bufnr)
local revision = (config.buffers[bufnr] or {}).revision or 1
config.buffers[bufnr] = c
config.buffers[bufnr].revision = config.buffers[bufnr].revision or 1
config.buffers[bufnr].revision = config.buffers[bufnr].revision + 1
config.buffers[bufnr].revision = revision + 1
end
---@return cmp.ConfigSchema

View File

@@ -48,10 +48,17 @@ end
core.get_context = function(option)
local prev = core.context:clone()
prev.prev_context = nil
core.context = context.new(prev, option)
local ctx = context.new(prev, option)
core.set_context(ctx)
return core.context
end
---Set new context
---@param ctx cmp.Context
core.set_context = function(ctx)
core.context = ctx
end
---Get sources that sorted by priority
---@param statuses cmp.SourceStatus[]
---@return cmp.Source[]
@@ -149,6 +156,8 @@ end
---Invoke completion
---@param ctx cmp.Context
core.complete = function(ctx)
core.set_context(ctx)
local callback = function()
local new = context.new(ctx)
if new:changed(new.prev_context) then