diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-10-21 21:10:58 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-10-21 21:10:58 +0800 |
commit | e56a441ac4cfaa17348ad4130c79c2168f46191e (patch) | |
tree | e67c9f9e7c11c7e0f24993c7668debcd467e376a | |
parent | 8ae08f9e748e8de96fbde454138f6cd0d0bcb95d (diff) | |
download | lua-language-server-e56a441ac4cfaa17348ad4130c79c2168f46191e.zip |
自定义调用片段
-rw-r--r-- | package.json | 12 | ||||
-rw-r--r-- | package.nls.json | 6 | ||||
-rw-r--r-- | server-beta/src/config.lua | 6 | ||||
-rw-r--r-- | server/build_package.lua | 18 | ||||
-rw-r--r-- | server/src/config.lua | 5 | ||||
-rw-r--r-- | server/src/core/completion.lua | 13 |
6 files changed, 26 insertions, 34 deletions
diff --git a/package.json b/package.json index de563eea..a552f452 100644 --- a/package.json +++ b/package.json @@ -20,15 +20,13 @@ "default": "Disable", "enum": [ "Disable", - "Show after", - "Show before", + "Both", "Replace" ], "markdownDescription": "%config.completion.callSnippet%", "markdownEnumDescriptions": [ "%config.completion.callSnippet.Disable%", - "%config.completion.callSnippet.Show after%", - "%config.completion.callSnippet.Show before%", + "%config.completion.callSnippet.Both%", "%config.completion.callSnippet.Replace%" ], "scope": "resource", @@ -44,15 +42,13 @@ "default": "Replace", "enum": [ "Disable", - "Show after", - "Show before", + "Both", "Replace" ], "markdownDescription": "%config.completion.keywordSnippet%", "markdownEnumDescriptions": [ "%config.completion.keywordSnippet.Disable%", - "%config.completion.keywordSnippet.Show after%", - "%config.completion.keywordSnippet.Show before%", + "%config.completion.keywordSnippet.Both%", "%config.completion.keywordSnippet.Replace%" ], "scope": "resource", diff --git a/package.nls.json b/package.nls.json index 3ec8bf00..aed98c27 100644 --- a/package.nls.json +++ b/package.nls.json @@ -1,15 +1,13 @@ { "config.completion.callSnippet": "Shows function call snippets.", + "config.completion.callSnippet.Both": "Shows `function name` and `call snippet`.", "config.completion.callSnippet.Disable": "Only shows `function name`.", "config.completion.callSnippet.Replace": "Only shows `call snippet.`", - "config.completion.callSnippet.Show after": "Shows `function name` and `call snippet`.", - "config.completion.callSnippet.Show before": "Shows `call snippet` and `function name`.", "config.completion.enable": "Enable completion.", "config.completion.keywordSnippet": "Shows keyword syntax snippets.", + "config.completion.keywordSnippet.Both": "Shows `keyword` and `syntax snippet`.", "config.completion.keywordSnippet.Disable": "Only shows `keyword`.", "config.completion.keywordSnippet.Replace": "Only shows `syntax snippet`.", - "config.completion.keywordSnippet.Show after": "Shows `keyword` and `syntax snippet`.", - "config.completion.keywordSnippet.Show before": "Shows `syntax snippet` and `keyword`.", "config.diagnostics.disable": "Disabled diagnostic (Use code in hover brackets).\n```json\n\"Lua.diagnostics.disable\" : [\n \"unused-local\",\n \"lowercase-global\"\n]\n```\n", "config.diagnostics.enable": "Enable diagnostics.", "config.diagnostics.globals": "Defined global variables.\n```json\n\"Lua.diagnostics.globals\" : [\n \"GLOBAL1\",\n \"GLOBAL2\"\n]\n```\n", diff --git a/server-beta/src/config.lua b/server-beta/src/config.lua index 778045e2..758402b0 100644 --- a/server-beta/src/config.lua +++ b/server-beta/src/config.lua @@ -124,9 +124,9 @@ local ConfigTemplate = { )} }, completion = { - enable = {true, Boolean}, - callSnippet = {'Disable', String}, - keywordSnippet = {'Replace', String}, + enable = {true, Boolean}, + callSnippet = {'Both', String}, + keywordSnippet = {'Both', String}, }, plugin = { enable = {false, Boolean}, 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 |