diff options
-rw-r--r-- | changelog.md | 1 | ||||
-rw-r--r-- | script/config.lua | 7 | ||||
-rw-r--r-- | script/provider/provider.lua | 18 |
3 files changed, 20 insertions, 6 deletions
diff --git a/changelog.md b/changelog.md index cee79f6f..e2223eea 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,7 @@ ## 1.21.0 * `CHG` `LuaDoc`: supports `---@param self TYPE` +* `CHG` completion: does not show suggests after `\n`, `{` and `,`, unless your setting `editor.acceptSuggestionOnEnter` is `off` ## 1.20.1 `2021-3-27` diff --git a/script/config.lua b/script/config.lua index effd3016..7991e1ad 100644 --- a/script/config.lua +++ b/script/config.lua @@ -198,9 +198,10 @@ local ConfigTemplate = { } local OtherTemplate = { - associations = {{}, Hash(String, String)}, - exclude = {{}, Hash(String, Boolean)}, - semantic = {'', Or(Boolean, String)}, + associations = {{}, Hash(String, String)}, + exclude = {{}, Hash(String, Boolean)}, + semantic = {'', Or(Boolean, String)}, + acceptSuggestionOnEnter = {'on', String}, } local function init() diff --git a/script/provider/provider.lua b/script/provider/provider.lua index f8592d0c..59af1c7a 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -41,6 +41,10 @@ local function updateConfig() scopeUri = workspace.uri, section = 'editor.semanticHighlighting.enabled', }, + { + scopeUri = workspace.uri, + section = 'editor.acceptSuggestionOnEnter', + }, }, }) if not configs or not configs[1] then @@ -50,9 +54,10 @@ local function updateConfig() local updated = configs[1] local other = { - associations = configs[2], - exclude = configs[3], - semantic = configs[4], + associations = configs[2], + exclude = configs[3], + semantic = configs[4], + acceptSuggestionOnEnter = configs[5], } local oldConfig = util.deepCopy(config.config) @@ -443,6 +448,13 @@ proto.on('textDocument/completion', function (params) if not files.exists(uri) then return nil end + if config.other.acceptSuggestionOnEnter ~= 'off' then + if params.context.triggerCharacter == '\n' + or params.context.triggerCharacter == '{' + or params.context.triggerCharacter == ',' then + return + end + end await.setPriority(1000) local clock = os.clock() local offset = files.offset(uri, params.position) |