Add SourceBaseApiParams

This commit is contained in:
hrsh7th
2021-08-25 11:27:14 +09:00
parent 46e5d1656d
commit f7bb6f1c6e
3 changed files with 11 additions and 6 deletions

View File

@@ -340,8 +340,9 @@ end
--- 1. Trigger keyword completion
--- 2. Detect menu start offset
--- 3. Reset completion state
---@param params cmp.SourceBaseApiParams
---@return string
function source:get_keyword_pattern()
function source:get_keyword_pattern(params)
return '???'
end
@@ -353,9 +354,9 @@ end
---Invoke completion (required).
--- If you want to abort completion, just call the callback without arguments.
---@param request cmp.CompletionRequest
---@param params cmp.SourceCompletionApiParams
---@param callback fun(response: lsp.CompletionResponse|nil)
function source:complete(request, callback)
function source:complete(params, callback)
callback({
{ label = 'January' },
{ label = 'February' },

View File

@@ -186,7 +186,9 @@ end
---@return string
source.get_keyword_pattern = function(self)
if self.source.get_keyword_pattern then
return self.source:get_keyword_pattern()
return self.source:get_keyword_pattern({
option = self:get_option(),
})
end
return config.get().completion.keyword_pattern
end

View File

@@ -37,9 +37,11 @@ cmp.ScrollDirection.Down = 'down'
---@field public buffer fun(c: cmp.ConfigSchema)
---@field public global fun(c: cmp.ConfigSchema)
---@class cmp.CompletionRequest
---@field public context cmp.Context
---@class cmp.SourceBaseApiParams
---@field public option table
---@class cmp.SourceCompletionApiParams : cmp.SourceBaseApiParams
---@field public context cmp.Context
---@field public offset number
---@field public completion_context lsp.CompletionContext