diff --git a/setting/build.lua b/setting/build.lua index c523fb5e5ab1802ec9378e360990b97ff34a0f28..1d13ced22fcda81d0e26ad51b8848931c10a9fad 100644 --- a/setting/build.lua +++ b/setting/build.lua @@ -4,12 +4,32 @@ require 'utility' local json = require 'json' local configuration = require 'package.configuration' -local setting = { - ['$schema'] = '', - title = 'setting', - description = 'Setting of sumneko.lua', - type = 'object', - properties = configuration, -} - -io.save(fs.path'setting/schema.json', json.encode(setting)) +local function copyWithNLS(t, callback) + local nt = {} + for k, v in pairs(t) do + if type(v) == 'string' then + nt[k] = callback(v) or v + elseif type(v) == 'table' then + nt[k] = copyWithNLS(v, callback) + else + nt[k] = v + end + end + return nt +end + +for _, lang in ipairs {'', '-zh-cn'} do + local nls = require('package.nls' .. lang) + + local setting = { + ['$schema'] = '', + title = 'setting', + description = 'Setting of sumneko.lua', + type = 'object', + properties = copyWithNLS(configuration, function (str) + return str:gsub('^%%(.+)%%$', nls) + end), + } + + io.save(fs.path'setting/schema'..lang..'.json', json.encode(setting)) +end diff --git a/setting/schema-zh-cn.json b/setting/schema-zh-cn.json new file mode 100644 index 0000000000000000000000000000000000000000..1971209fc4c258b3cbf42ebbc8e5e5726a69a22b --- /dev/null +++ b/setting/schema-zh-cn.json @@ -0,0 +1,394 @@ +{ + "$schema": "", + "description": "Setting of sumneko.lua", + "properties": { + "Lua.color.mode": { + "default": "Semantic", + "enum": [ + "Grammar", + "Semantic" + ], + "markdownDescription": "着色模式。", + "markdownEnumDescriptions": [ + "语法着色。", + "语义着色(测试中。你的颜色主题必须要支持语义着色才有效。)。" + ], + "scope": "resource", + "type": "string" + }, + "Lua.completion.callSnippet": { + "default": "Disable", + "enum": [ + "Disable", + "Both", + "Replace" + ], + "markdownDescription": "显示函数调用片段。", + "markdownEnumDescriptions": [ + "只显示 `函数名`。", + "显示 `函数名` 与 `调用片段`。", + "只显示 `调用片段`。" + ], + "scope": "resource", + "type": "string" + }, + "Lua.completion.enable": { + "default": true, + "markdownDescription": "启用自动完成。", + "scope": "resource", + "type": "boolean" + }, + "Lua.completion.keywordSnippet": { + "default": "Replace", + "enum": [ + "Disable", + "Both", + "Replace" + ], + "markdownDescription": "显示关键字语法片段", + "markdownEnumDescriptions": [ + "只显示 `关键字`。", + "显示 `关键字` 与 `语法片段`。", + "只显示 `语法片段`。" + ], + "scope": "resource", + "type": "string" + }, + "Lua.develop.debuggerPort": { + "default": 11412, + "markdownDescription": "调试器监听端口。", + "scope": "resource", + "type": "integer" + }, + "Lua.develop.debuggerWait": { + "default": false, + "markdownDescription": "调试器连接之前挂起。", + "scope": "resource", + "type": "boolean" + }, + "Lua.develop.enable": { + "default": false, + "markdownDescription": "开发者模式。请勿开启,会影响性能。", + "scope": "resource", + "type": "boolean" + }, + "Lua.diagnostics.disable": { + "items": { + "type": "string" + }, + "markdownDescription": "禁用的诊断(使用浮框括号内的代码)。\n```json\n\"Lua.diagnostics.disable\" : [\n \"unused-local\",\n \"lowercase-global\"\n]\n```\n", + "scope": "resource", + "type": "array" + }, + "Lua.diagnostics.enable": { + "default": true, + "markdownDescription": "启用诊断。", + "scope": "resource", + "type": "boolean" + }, + "Lua.diagnostics.globals": { + "items": { + "type": "string" + }, + "markdownDescription": "已定义的全局变量。\n```json\n\"Lua.diagnostics.globals\" : [\n \"GLOBAL1\",\n \"GLOBAL2\"\n]\n```\n", + "scope": "resource", + "type": "array" + }, + "Lua.diagnostics.severity": { + "markdownDescription": "修改诊断等级。\n```json\n\"Lua.diagnostics.severity\" : {\n \"redefined-local\" : \"Warning\",\n \"emmy-lua\" : \"Hint\"\n}\n```\n", + "properties": { + "ambiguity-1": { + "default": "Warning", + "enum": [ + "Error", + "Warning", + "Information", + "Hint" + ], + "scope": "resource", + "type": "string" + }, + "duplicate-index": { + "default": "Warning", + "enum": [ + "Error", + "Warning", + "Information", + "Hint" + ], + "scope": "resource", + "type": "string" + }, + "duplicate-method": { + "default": "Warning", + "enum": [ + "Error", + "Warning", + "Information", + "Hint" + ], + "scope": "resource", + "type": "string" + }, + "emmy-lua": { + "default": "Warning", + "enum": [ + "Error", + "Warning", + "Information", + "Hint" + ], + "scope": "resource", + "type": "string" + }, + "empty-block": { + "default": "Hint", + "enum": [ + "Error", + "Warning", + "Information", + "Hint" + ], + "scope": "resource", + "type": "string" + }, + "global-in-nil-env": { + "default": "Warning", + "enum": [ + "Error", + "Warning", + "Information", + "Hint" + ], + "scope": "resource", + "type": "string" + }, + "lowercase-global": { + "default": "Information", + "enum": [ + "Error", + "Warning", + "Information", + "Hint" + ], + "scope": "resource", + "type": "string" + }, + "newfield-call": { + "default": "Warning", + "enum": [ + "Error", + "Warning", + "Information", + "Hint" + ], + "scope": "resource", + "type": "string" + }, + "newline-call": { + "default": "Information", + "enum": [ + "Error", + "Warning", + "Information", + "Hint" + ], + "scope": "resource", + "type": "string" + }, + "redefined-local": { + "default": "Hint", + "enum": [ + "Error", + "Warning", + "Information", + "Hint" + ], + "scope": "resource", + "type": "string" + }, + "redundant-parameter": { + "default": "Hint", + "enum": [ + "Error", + "Warning", + "Information", + "Hint" + ], + "scope": "resource", + "type": "string" + }, + "redundant-value": { + "default": "Hint", + "enum": [ + "Error", + "Warning", + "Information", + "Hint" + ], + "scope": "resource", + "type": "string" + }, + "set-const": { + "default": "Error", + "enum": [ + "Error", + "Warning", + "Information", + "Hint" + ], + "scope": "resource", + "type": "string" + }, + "trailing-space": { + "default": "Hint", + "enum": [ + "Error", + "Warning", + "Information", + "Hint" + ], + "scope": "resource", + "type": "string" + }, + "undefined-env-child": { + "default": "Information", + "enum": [ + "Error", + "Warning", + "Information", + "Hint" + ], + "scope": "resource", + "type": "string" + }, + "undefined-global": { + "default": "Warning", + "enum": [ + "Error", + "Warning", + "Information", + "Hint" + ], + "scope": "resource", + "type": "string" + }, + "unused-function": { + "default": "Hint", + "enum": [ + "Error", + "Warning", + "Information", + "Hint" + ], + "scope": "resource", + "type": "string" + }, + "unused-label": { + "default": "Hint", + "enum": [ + "Error", + "Warning", + "Information", + "Hint" + ], + "scope": "resource", + "type": "string" + }, + "unused-local": { + "default": "Hint", + "enum": [ + "Error", + "Warning", + "Information", + "Hint" + ], + "scope": "resource", + "type": "string" + }, + "unused-vararg": { + "default": "Hint", + "enum": [ + "Error", + "Warning", + "Information", + "Hint" + ], + "scope": "resource", + "type": "string" + } + }, + "scope": "resource", + "title": "severity", + "type": "object" + }, + "Lua.runtime.path": { + "default": [ + "?.lua", + "?/init.lua", + "?/?.lua" + ], + "items": { + "type": "string" + }, + "markdownDescription": "`package.path`", + "scope": "resource", + "type": "array" + }, + "Lua.runtime.version": { + "default": "Lua 5.3", + "enum": [ + "Lua 5.1", + "Lua 5.2", + "Lua 5.3", + "Lua 5.4", + "LuaJIT" + ], + "markdownDescription": "Lua运行版本。", + "scope": "resource", + "type": "string" + }, + "Lua.workspace.ignoreDir": { + "default": [ + ".vscode" + ], + "items": { + "type": "string" + }, + "markdownDescription": "忽略的目录(使用 `.gitignore` 语法)。\n```json\n\"Lua.workspace.ignoreDir\" : [\n \"temp/*.*\",\n \"!temp/*.lua\"\n]\n```\n", + "scope": "resource", + "type": "array" + }, + "Lua.workspace.ignoreSubmodules": { + "default": true, + "markdownDescription": "忽略子模块。", + "scope": "resource", + "type": "boolean" + }, + "Lua.workspace.library": { + "markdownDescription": "加载外部函数库。\n该功能可以加载外部的Lua文件,用于函数定义、自动完成等功能。注意,语言服务不会监视外部文件的变化,如果修改了外部文件需要重启。\n下面这个例子表示加载`C:/lua`与`../lib`中的所有文件,但不加载`../lib/temp`中的文件。\n```json\n\"Lua.workspace.library\": {\n \"C:/lua\": true,\n \"../lib\": [\n \"temp/*\"\n ]\n}\n```\n", + "scope": "resource", + "type": "object" + }, + "Lua.workspace.maxPreload": { + "default": 300, + "markdownDescription": "最大预加载文件数。", + "scope": "resource", + "type": "integer" + }, + "Lua.workspace.preloadFileSize": { + "default": 100, + "markdownDescription": "预加载时跳过大小大于该值(KB)的文件。", + "scope": "resource", + "type": "integer" + }, + "Lua.workspace.useGitIgnore": { + "default": true, + "markdownDescription": "忽略 `.gitignore` 中列举的文件。", + "scope": "resource", + "type": "boolean" + } + }, + "title": "setting", + "type": "object" +} \ No newline at end of file diff --git a/setting/schema.json b/setting/schema.json index 8f3a8606273b59479bde5f9f7c27ce039348713c..73c320d1616175549ed61f1d6178984d17e036c2 100644 --- a/setting/schema.json +++ b/setting/schema.json @@ -8,10 +8,10 @@ "Grammar", "Semantic" ], - "markdownDescription": "%config.color.mode%", + "markdownDescription": "Color mode.", "markdownEnumDescriptions": [ - "%config.color.mode.Grammar%", - "%config.color.mode.Semantic%" + "Grammar color.", + "Semantic color (Testing. Your color theme must support semantic coloring to be effective.)." ], "scope": "resource", "type": "string" @@ -23,18 +23,18 @@ "Both", "Replace" ], - "markdownDescription": "%config.completion.callSnippet%", + "markdownDescription": "Shows function call snippets.", "markdownEnumDescriptions": [ - "%config.completion.callSnippet.Disable%", - "%config.completion.callSnippet.Both%", - "%config.completion.callSnippet.Replace%" + "Only shows `function name`.", + "Shows `function name` and `call snippet`.", + "Only shows `call snippet.`" ], "scope": "resource", "type": "string" }, "Lua.completion.enable": { "default": true, - "markdownDescription": "%config.completion.enable%", + "markdownDescription": "Enable completion.", "scope": "resource", "type": "boolean" }, @@ -45,30 +45,30 @@ "Both", "Replace" ], - "markdownDescription": "%config.completion.keywordSnippet%", + "markdownDescription": "Shows keyword syntax snippets.", "markdownEnumDescriptions": [ - "%config.completion.keywordSnippet.Disable%", - "%config.completion.keywordSnippet.Both%", - "%config.completion.keywordSnippet.Replace%" + "Only shows `keyword`.", + "Shows `keyword` and `syntax snippet`.", + "Only shows `syntax snippet`." ], "scope": "resource", "type": "string" }, "Lua.develop.debuggerPort": { "default": 11412, - "markdownDescription": "%config.develop.debuggerPort%", + "markdownDescription": "Listen port of debugger.", "scope": "resource", "type": "integer" }, "Lua.develop.debuggerWait": { "default": false, - "markdownDescription": "%config.develop.debuggerWait%", + "markdownDescription": "Suspend before debugger connects.", "scope": "resource", "type": "boolean" }, "Lua.develop.enable": { "default": false, - "markdownDescription": "%config.develop.enable%", + "markdownDescription": "Developer mode. Do not enable, performance will be affected.", "scope": "resource", "type": "boolean" }, @@ -76,13 +76,13 @@ "items": { "type": "string" }, - "markdownDescription": "%config.diagnostics.disable%", + "markdownDescription": "Disabled diagnostic (Use code in hover brackets).\n```json\n\"Lua.diagnostics.disable\" : [\n \"unused-local\",\n \"lowercase-global\"\n]\n```\n", "scope": "resource", "type": "array" }, "Lua.diagnostics.enable": { "default": true, - "markdownDescription": "%config.diagnostics.enable%", + "markdownDescription": "Enable diagnostics.", "scope": "resource", "type": "boolean" }, @@ -90,12 +90,12 @@ "items": { "type": "string" }, - "markdownDescription": "%config.diagnostics.globals%", + "markdownDescription": "Defined global variables.\n```json\n\"Lua.diagnostics.globals\" : [\n \"GLOBAL1\",\n \"GLOBAL2\"\n]\n```\n", "scope": "resource", "type": "array" }, "Lua.diagnostics.severity": { - "markdownDescription": "%config.diagnostics.severity%", + "markdownDescription": "Modified diagnostic severity.\n```json\n\"Lua.diagnostics.severity\" : {\n \"redefined-local\" : \"Warning\",\n \"emmy-lua\" : \"Hint\"\n}\n```\n", "properties": { "ambiguity-1": { "default": "Warning", @@ -331,7 +331,7 @@ "items": { "type": "string" }, - "markdownDescription": "%config.runtime.path%", + "markdownDescription": "`package.path`", "scope": "resource", "type": "array" }, @@ -344,7 +344,7 @@ "Lua 5.4", "LuaJIT" ], - "markdownDescription": "%config.runtime.version%", + "markdownDescription": "Lua runtime version.", "scope": "resource", "type": "string" }, @@ -355,36 +355,36 @@ "items": { "type": "string" }, - "markdownDescription": "%config.workspace.ignoreDir%", + "markdownDescription": "Ignored directories (Use `.gitignore` grammar).\n```json\n\"Lua.workspace.ignoreDir\" : [\n \"temp/*.*\",\n \"!temp/*.lua\"\n]\n```\n", "scope": "resource", "type": "array" }, "Lua.workspace.ignoreSubmodules": { "default": true, - "markdownDescription": "%config.workspace.ignoreSubmodules%", + "markdownDescription": "Ignore submodules.", "scope": "resource", "type": "boolean" }, "Lua.workspace.library": { - "markdownDescription": "%config.workspace.library%", + "markdownDescription": "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", "scope": "resource", "type": "object" }, "Lua.workspace.maxPreload": { "default": 300, - "markdownDescription": "%config.workspace.maxPreload%", + "markdownDescription": "Max preloaded files.", "scope": "resource", "type": "integer" }, "Lua.workspace.preloadFileSize": { "default": 100, - "markdownDescription": "%config.workspace.preloadFileSize%", + "markdownDescription": "Skip files larger than this value (KB) when preloading.", "scope": "resource", "type": "integer" }, "Lua.workspace.useGitIgnore": { "default": true, - "markdownDescription": "%config.workspace.useGitIgnore%", + "markdownDescription": "Ignore files list in `.gitignore` .", "scope": "resource", "type": "boolean" } diff --git a/setting/setting.json b/setting/setting.json new file mode 100644 index 0000000000000000000000000000000000000000..a40ca84002ec2a5c750ae5c43b444975743ad5bb --- /dev/null +++ b/setting/setting.json @@ -0,0 +1,3 @@ +{ + "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json" +}