summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-04-02 18:14:54 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-04-02 18:14:54 +0800
commit55e7d5950398eb6816646d1612701565364fa08b (patch)
tree201c39c10848958d6acd3b6f4469082b691fef70 /script
parent913aced8f27185e1f078b64e4d3c147e73589165 (diff)
downloadlua-language-server-55e7d5950398eb6816646d1612701565364fa08b.zip
resolve #461
Diffstat (limited to 'script')
-rw-r--r--script/config.lua7
-rw-r--r--script/provider/provider.lua18
2 files changed, 19 insertions, 6 deletions
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)