Add completion.get_trigger_characters as configurable option

This commit is contained in:
hrsh7th
2021-08-26 16:49:43 +09:00
parent 698c3c4bf5
commit ec3f8aedaf
4 changed files with 15 additions and 2 deletions

View File

@@ -187,6 +187,11 @@ length of the word to the left of the cursor is less than `keyword_length`.
Default: `1`
### completion.get_trigger_characters (type: fun(trigger_characters: string[]): string[])
The function to resolve trigger_characters.
Default: `function(trigger_characters) return trigger_characters end`
#### completion.completeopt (type: string)

View File

@@ -13,6 +13,9 @@ return function()
completeopt = 'menu,menuone,noselect',
keyword_pattern = [[\%(-\?\d\+\%(\.\d\+\)\?\|\h\w*\%(-\w*\)*\)]],
keyword_length = 1,
get_trigger_characters = function(trigger_characters)
return trigger_characters
end
},
snippet = {

View File

@@ -196,12 +196,16 @@ end
---Get trigger_characters
---@return string[]
source.get_trigger_characters = function(self)
local trigger_characters = {}
if self.source.get_trigger_characters then
return self.source:get_trigger_characters({
trigger_characters = self.source:get_trigger_characters({
option = self:get_option(),
}) or {}
end
return {}
if config.get().completion.get_trigger_characters then
return config.get().completion.get_trigger_characters(trigger_characters)
end
return trigger_characters
end
---Invoke completion

View File

@@ -63,6 +63,7 @@ cmp.PreselectMode.None = 'none'
---@field public completeopt string
---@field public keyword_pattern string
---@field public keyword_length number
---@field public get_trigger_characters fun(trigger_characters: string[]): string[]
---@class cmp.DocumentationConfig
---@field public border string[]