summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package.json6
-rw-r--r--package.nls.json3
-rw-r--r--package.nls.zh-cn.json1
-rw-r--r--server/src/config.lua3
-rw-r--r--server/src/core/completion.lua18
-rw-r--r--server/test/build_package.lua11
6 files changed, 32 insertions, 10 deletions
diff --git a/package.json b/package.json
index 0794cbf2..57b536f5 100644
--- a/package.json
+++ b/package.json
@@ -16,6 +16,12 @@
"contributes": {
"configuration": {
"properties": {
+ "Lua.completion.callSnippet": {
+ "default": true,
+ "markdownDescription": "%config.completion.callSnippet%",
+ "scope": "resource",
+ "type": "boolean"
+ },
"Lua.diagnostics.disable": {
"items": {
"type": "string"
diff --git a/package.nls.json b/package.nls.json
index 4403a790..cc782acd 100644
--- a/package.nls.json
+++ b/package.nls.json
@@ -1,4 +1,5 @@
{
+ "config.completion.callSnippet": "Show function call snippets.",
"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",
@@ -7,7 +8,7 @@
"config.runtime.version": "Lua runtime version.",
"config.workspace.ignoreDir": "Ignored directories (Use `.gitignore` grammar).\n```json\n\"Lua.workspace.ignoreDir\" : [\n \"temp/*.*\",\n \"!temp/*.lua\"\n]\n```\n",
"config.workspace.ignoreSubmodules": "Ignore submodules.",
- "config.workspace.library": "(Plz help me to translate these into nice English!)\nLoad external library.\nThis feature can load external Lua files, which can be used for definition, automatic completion and other functions. Note that the language server does not monitor changes in external files and needs to restart if the external files are modified.\nThe following example shows loaded files in `C:/lua` and `../lib` ,exclude `../lib/temp`.\n```json\n\"Lua.workspace.library\": {\n \"C:/lua\": true,\n \"../lib\": [\n \"temp/*\"\n ]\n}\n```\n",
+ "config.workspace.library": "Load external library.\nThis feature can load external Lua files, which can be used for definition, automatic completion and other functions. Note that the language server does not monitor changes in external files and needs to restart if the external files are modified.\nThe following example shows loaded files in `C:/lua` and `../lib` ,exclude `../lib/temp`.\n```json\n\"Lua.workspace.library\": {\n \"C:/lua\": true,\n \"../lib\": [\n \"temp/*\"\n ]\n}\n```\n",
"config.workspace.maxPreload": "Max preloaded files.",
"config.workspace.preloadFileSize": "Skip files larger than this value (KB) when preloading.",
"config.workspace.useGitIgnore": "Ignore files list in `.gitignore` ."
diff --git a/package.nls.zh-cn.json b/package.nls.zh-cn.json
index a8f3e102..da16fd8b 100644
--- a/package.nls.zh-cn.json
+++ b/package.nls.zh-cn.json
@@ -1,4 +1,5 @@
{
+ "config.completion.callSnippet": "显示函数调用片段。",
"config.diagnostics.disable": "禁用的诊断(使用浮框括号内的代码)。\n```json\n\"Lua.diagnostics.disable\" : [\n \"unused-local\",\n \"lowercase-global\"\n]\n```\n",
"config.diagnostics.enable": "启用诊断。",
"config.diagnostics.globals": "已定义的全局变量。\n```json\n\"Lua.diagnostics.globals\" : [\n \"GLOBAL1\",\n \"GLOBAL2\"\n]\n```\n",
diff --git a/server/src/config.lua b/server/src/config.lua
index ec01bd08..24e0d53e 100644
--- a/server/src/config.lua
+++ b/server/src/config.lua
@@ -119,6 +119,9 @@ local ConfigTemplate = {
Or(Boolean, Array(String))
)}
},
+ completion = {
+ callSnippet = {true, Boolean},
+ },
}
local OtherTemplate = {
diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua
index b9191568..d47f768f 100644
--- a/server/src/core/completion.lua
+++ b/server/src/core/completion.lua
@@ -930,13 +930,17 @@ local function makeList(source, pos, word)
end
list[#list+1] = data
if data.snip 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
+ if config.config.completion.callSnippet 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
+ end
end
end, list
end
diff --git a/server/test/build_package.lua b/server/test/build_package.lua
index 6622c3bd..f4d0e7c0 100644
--- a/server/test/build_package.lua
+++ b/server/test/build_package.lua
@@ -129,7 +129,13 @@ local package = {
scope = 'resource',
type = 'object',
markdownDescription = "%config.workspace.library%"
- }
+ },
+ ["Lua.completion.callSnippet"] = {
+ scope = "resource",
+ type = "boolean",
+ default = true,
+ markdownDescription = "%config.completion.callSnippet%"
+ },
}
},
grammars = {
@@ -224,11 +230,11 @@ io.save(ROOT:parent_path() / 'package.nls.json', json.encode {
["config.workspace.maxPreload"] = "Max preloaded files.",
["config.workspace.preloadFileSize"] = "Skip files larger than this value (KB) when preloading.",
["config.workspace.library"] = [[
-(Plz help me to translate these into nice English!)
Load external library.
This feature can load external Lua files, which can be used for definition, automatic completion and other functions. Note that the language server does not monitor changes in external files and needs to restart if the external files are modified.
The following example shows loaded files in `C:/lua` and `../lib` ,exclude `../lib/temp`.
]] .. example.library,
+ ['config.completion.callSnippet'] = 'Show function call snippets.',
})
io.save(ROOT:parent_path() / 'package.nls.zh-cn.json', json.encode {
@@ -248,4 +254,5 @@ io.save(ROOT:parent_path() / 'package.nls.zh-cn.json', json.encode {
该功能可以加载外部的Lua文件,用于函数定义、自动完成等功能。注意,语言服务不会监视外部文件的变化,如果修改了外部文件需要重启。
下面这个例子表示加载`C:/lua`与`../lib`中的所有文件,但不加载`../lib/temp`中的文件。
]] .. example.library,
+ ['config.completion.callSnippet'] = '显示函数调用片段。',
})