Add completion.get_trigger_characters as configurable option
This commit is contained in:
@@ -187,6 +187,11 @@ length of the word to the left of the cursor is less than `keyword_length`.
|
|||||||
|
|
||||||
Default: `1`
|
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)
|
#### completion.completeopt (type: string)
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ return function()
|
|||||||
completeopt = 'menu,menuone,noselect',
|
completeopt = 'menu,menuone,noselect',
|
||||||
keyword_pattern = [[\%(-\?\d\+\%(\.\d\+\)\?\|\h\w*\%(-\w*\)*\)]],
|
keyword_pattern = [[\%(-\?\d\+\%(\.\d\+\)\?\|\h\w*\%(-\w*\)*\)]],
|
||||||
keyword_length = 1,
|
keyword_length = 1,
|
||||||
|
get_trigger_characters = function(trigger_characters)
|
||||||
|
return trigger_characters
|
||||||
|
end
|
||||||
},
|
},
|
||||||
|
|
||||||
snippet = {
|
snippet = {
|
||||||
|
|||||||
@@ -196,12 +196,16 @@ end
|
|||||||
---Get trigger_characters
|
---Get trigger_characters
|
||||||
---@return string[]
|
---@return string[]
|
||||||
source.get_trigger_characters = function(self)
|
source.get_trigger_characters = function(self)
|
||||||
|
local trigger_characters = {}
|
||||||
if self.source.get_trigger_characters then
|
if self.source.get_trigger_characters then
|
||||||
return self.source:get_trigger_characters({
|
trigger_characters = self.source:get_trigger_characters({
|
||||||
option = self:get_option(),
|
option = self:get_option(),
|
||||||
}) or {}
|
}) or {}
|
||||||
end
|
end
|
||||||
return {}
|
if config.get().completion.get_trigger_characters then
|
||||||
|
return config.get().completion.get_trigger_characters(trigger_characters)
|
||||||
|
end
|
||||||
|
return trigger_characters
|
||||||
end
|
end
|
||||||
|
|
||||||
---Invoke completion
|
---Invoke completion
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ cmp.PreselectMode.None = 'none'
|
|||||||
---@field public completeopt string
|
---@field public completeopt string
|
||||||
---@field public keyword_pattern string
|
---@field public keyword_pattern string
|
||||||
---@field public keyword_length number
|
---@field public keyword_length number
|
||||||
|
---@field public get_trigger_characters fun(trigger_characters: string[]): string[]
|
||||||
|
|
||||||
---@class cmp.DocumentationConfig
|
---@class cmp.DocumentationConfig
|
||||||
---@field public border string[]
|
---@field public border string[]
|
||||||
|
|||||||
Reference in New Issue
Block a user