diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/src/config.lua | 3 | ||||
-rw-r--r-- | server/src/core/completion.lua | 18 | ||||
-rw-r--r-- | server/test/build_package.lua | 11 |
3 files changed, 23 insertions, 9 deletions
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'] = '显示函数调用片段。', }) |