summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/build_package.lua18
-rw-r--r--server/src/config.lua5
-rw-r--r--server/src/core/completion.lua13
3 files changed, 17 insertions, 19 deletions
diff --git a/server/build_package.lua b/server/build_package.lua
index 37e55bb9..844875a1 100644
--- a/server/build_package.lua
+++ b/server/build_package.lua
@@ -145,14 +145,12 @@ local package = {
default = "Disable",
enum = {
"Disable",
- "Show after",
- "Show before",
+ "Both",
"Replace",
},
markdownEnumDescriptions = {
"%config.completion.callSnippet.Disable%",
- "%config.completion.callSnippet.Show after%",
- "%config.completion.callSnippet.Show before%",
+ "%config.completion.callSnippet.Both%",
"%config.completion.callSnippet.Replace%",
},
markdownDescription = "%config.completion.callSnippet%"
@@ -163,14 +161,12 @@ local package = {
default = "Replace",
enum = {
"Disable",
- "Show after",
- "Show before",
+ "Both",
"Replace",
},
markdownEnumDescriptions = {
"%config.completion.keywordSnippet.Disable%",
- "%config.completion.keywordSnippet.Show after%",
- "%config.completion.keywordSnippet.Show before%",
+ "%config.completion.keywordSnippet.Both%",
"%config.completion.keywordSnippet.Replace%",
},
markdownDescription = "%config.completion.keywordSnippet%"
@@ -294,13 +290,11 @@ The following example shows loaded files in `C:/lua` and `../lib` ,exclude `../l
['config.completion.enable'] = 'Enable completion.',
['config.completion.callSnippet'] = 'Shows function call snippets.',
['config.completion.callSnippet.Disable'] = "Only shows `function name`.",
- ['config.completion.callSnippet.Show after'] = "Shows `function name` and `call snippet`.",
- ['config.completion.callSnippet.Show before'] = "Shows `call snippet` and `function name`.",
+ ['config.completion.callSnippet.Both'] = "Shows `function name` and `call snippet`.",
['config.completion.callSnippet.Replace'] = "Only shows `call snippet.`",
['config.completion.keywordSnippet'] = 'Shows keyword syntax snippets.',
['config.completion.keywordSnippet.Disable'] = "Only shows `keyword`.",
- ['config.completion.keywordSnippet.Show after'] = "Shows `keyword` and `syntax snippet`.",
- ['config.completion.keywordSnippet.Show before'] = "Shows `syntax snippet` and `keyword`.",
+ ['config.completion.keywordSnippet.Both'] = "Shows `keyword` and `syntax snippet`.",
['config.completion.keywordSnippet.Replace'] = "Only shows `syntax snippet`.",
['config.zzzzzz.cat'] = 'DO NOT TOUCH ME, LET ME SLEEP >_<\n\n(This will enable beta version, which are still in the early stages of development, and all features will fail after enabling this setting.)',
})
diff --git a/server/src/config.lua b/server/src/config.lua
index 491613b4..f58df498 100644
--- a/server/src/config.lua
+++ b/server/src/config.lua
@@ -120,8 +120,9 @@ local ConfigTemplate = {
)}
},
completion = {
- enable = {true, Boolean},
- callSnippet = {true, Boolean},
+ enable = {true, Boolean},
+ callSnippet = {'Both', String},
+ keywordSnippet = {'Both', String},
},
plugin = {
enable = {false, Boolean},
diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua
index 5c86aa7e..69d68a8a 100644
--- a/server/src/core/completion.lua
+++ b/server/src/core/completion.lua
@@ -941,17 +941,20 @@ local function makeList(source, pos, word)
end
list[#list+1] = data
if data.snip then
- if config.config.completion.callSnippet then
+ local snipType = config.config.completion.callSnippet
+ if snipType ~= 'Disable' then
local snipData = table.deepCopy(data)
snipData.insertText = data.snip
snipData.kind = CompletionItemKind.Snippet
snipData.label = snipData.label .. '()'
snipData.snip = nil
- data.snip = nil
- list[#list+1] = snipData
- else
- data.snip = nil
+ if snipType == 'Both' then
+ list[#list+1] = snipData
+ elseif snipType == 'Replace' then
+ list[#list] = snipData
+ end
end
+ data.snip = nil
end
end, list
end