diff options
-rw-r--r-- | script-beta/config.lua | 6 | ||||
-rw-r--r-- | script-beta/core/completion.lua | 36 | ||||
-rw-r--r-- | script-beta/core/document-symbol.lua | 28 | ||||
-rw-r--r-- | script-beta/core/keyword.lua | 44 | ||||
-rw-r--r-- | script-beta/core/semantic-tokens.lua | 29 | ||||
-rw-r--r-- | script-beta/core/workspace-symbol.lua | 8 | ||||
-rw-r--r-- | script-beta/define/CompletionItemKind.lua | 27 | ||||
-rw-r--r-- | script-beta/define/DiagnosticDefaultSeverity.lua | 22 | ||||
-rw-r--r-- | script-beta/define/DiagnosticSeverity.lua | 6 | ||||
-rw-r--r-- | script-beta/define/ErrorCodes.lua | 16 | ||||
-rw-r--r-- | script-beta/define/SymbolKind.lua | 28 | ||||
-rw-r--r-- | script-beta/define/TokenModifiers.lua | 8 | ||||
-rw-r--r-- | script-beta/define/TokenTypes.lua | 21 | ||||
-rw-r--r-- | script-beta/proto/define.lua | 112 | ||||
-rw-r--r-- | script-beta/proto/proto.lua | 6 | ||||
-rw-r--r-- | script-beta/provider/semantic-tokens.lua | 7 | ||||
-rw-r--r-- | test-beta/completion/init.lua | 342 | ||||
-rw-r--r-- | test-beta/document_symbol/init.lua | 100 |
18 files changed, 414 insertions, 432 deletions
diff --git a/script-beta/config.lua b/script-beta/config.lua index fce52234..99f701fd 100644 --- a/script-beta/config.lua +++ b/script-beta/config.lua @@ -1,5 +1,5 @@ -local util = require 'utility' -local DiagnosticDefaultSeverity = require 'define.DiagnosticDefaultSeverity' +local util = require 'utility' +local define = require 'proto.define' local m = {} m.version = 0 @@ -109,7 +109,7 @@ local ConfigTemplate = { globals = {{}, Str2Hash ';'}, disable = {{}, Str2Hash ';'}, severity = { - util.deepCopy(DiagnosticDefaultSeverity), + util.deepCopy(define.DiagnosticDefaultSeverity), Hash(String, String), }, }, diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua index a8c52cc5..5a18ccaf 100644 --- a/script-beta/core/completion.lua +++ b/script-beta/core/completion.lua @@ -1,4 +1,4 @@ -local ckind = require 'define.CompletionItemKind' +local define = require 'proto.define' local files = require 'files' local guide = require 'parser.guide' local matchKey = require 'core.matchKey' @@ -234,7 +234,7 @@ local function buildFunction(results, source, oop, data) end if snipType == 'Both' or snipType == 'Replace' then local snipData = util.deepCopy(data) - snipData.kind = ckind.Snippet + snipData.kind = define.CompletionItemKind.Snippet snipData.label = snipData.label .. '()' snipData.insertText = buildFunctionSnip(source, oop) snipData.insertTextFormat = 2 @@ -274,7 +274,7 @@ local function checkLocal(ast, word, offset, results) if vm.hasType(source, 'function') then buildFunction(results, source, false, { label = name, - kind = ckind.Function, + kind = define.CompletionItemKind.Function, id = stack(function () return { detail = buildDetail(source), @@ -285,7 +285,7 @@ local function checkLocal(ast, word, offset, results) else results[#results+1] = { label = name, - kind = ckind.Variable, + kind = define.CompletionItemKind.Variable, id = stack(function () return { detail = buildDetail(source), @@ -349,12 +349,12 @@ end local function checkFieldThen(name, src, word, start, offset, parent, oop, results) local value = guide.getObjectValue(src) or src - local kind = ckind.Field + local kind = define.CompletionItemKind.Field if value.type == 'function' then if oop then - kind = ckind.Method + kind = define.CompletionItemKind.Method else - kind = ckind.Function + kind = define.CompletionItemKind.Function end buildFunction(results, src, oop, { label = name, @@ -374,7 +374,7 @@ local function checkFieldThen(name, src, word, start, offset, parent, oop, resul end local literal = guide.getLiteral(value) if literal ~= nil then - kind = ckind.Enum + kind = define.CompletionItemKind.Enum end local textEdit, additionalTextEdits if parent.next and parent.next.index then @@ -462,7 +462,7 @@ local function checkTableField(ast, word, start, results) used[key] = true results[#results+1] = { label = key, - kind = ckind.Property, + kind = define.CompletionItemKind.Property, } end end) @@ -482,7 +482,7 @@ local function checkCommon(word, text, offset, results) if matchKey(word, str) then results[#results+1] = { label = str, - kind = ckind.Text, + kind = define.CompletionItemKind.Text, } end end @@ -527,7 +527,7 @@ local function checkKeyWord(ast, text, start, word, hasSpace, afterLocal, result if not hasSpace then local item = { label = key, - kind = ckind.Keyword, + kind = define.CompletionItemKind.Keyword, } if extra then table.insert(results, #results, item) @@ -566,7 +566,7 @@ local function checkProvideLocal(ast, word, start, results) used[source[1]] = true results[#results+1] = { label = source[1], - kind = ckind.Variable, + kind = define.CompletionItemKind.Variable, } end end) @@ -577,7 +577,7 @@ local function checkProvideLocal(ast, word, start, results) used[source[1]] = true results[#results+1] = { label = source[1], - kind = ckind.Variable, + kind = define.CompletionItemKind.Variable, } end end) @@ -674,7 +674,7 @@ local function checkUri(ast, text, offset, results) end results[#results+1] = { label = label, - kind = ckind.Reference, + kind = define.CompletionItemKind.Reference, description = table.concat(des, '\n'), textEdit = infos.textEdit, } @@ -704,7 +704,7 @@ local function checkLenPlusOne(ast, text, offset, results) end results[#results+1] = { label = label, - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, textEdit = { start = pos, finish = source.finish, @@ -717,7 +717,7 @@ local function checkLenPlusOne(ast, text, offset, results) local newText = label .. ']' results[#results+1] = { label = label, - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, textEdit = { start = pos, finish = source.finish, @@ -837,7 +837,7 @@ local function getCallEnums(source, index) enums[#enums+1] = { label = enum.enum, description = enum.description, - kind = ckind.EnumMember, + kind = define.CompletionItemKind.EnumMember, } end end @@ -870,7 +870,7 @@ local function mergeEnums(a, b, text, arg) mark[label] = true local result = { label = label, - kind = ckind.EnumMember, + kind = define.CompletionItemKind.EnumMember, description = enum.description, textEdit = arg and { start = arg.start, diff --git a/script-beta/core/document-symbol.lua b/script-beta/core/document-symbol.lua index dd58fe82..8cb8f25f 100644 --- a/script-beta/core/document-symbol.lua +++ b/script-beta/core/document-symbol.lua @@ -1,9 +1,9 @@ local await = require 'await' -local files = require 'files' -local guide = require 'parser.guide' -local skind = require 'define.SymbolKind' -local lname = require 'core.hover.name' -local util = require 'utility' +local files = require 'files' +local guide = require 'parser.guide' +local define = require 'proto.define' +local lname = require 'core.hover.name' +local util = require 'utility' local function buildFunctionParams(func) if not func.args then @@ -39,9 +39,9 @@ local function buildFunction(source, symbols) range = { func.start, func.finish } end if source.type == 'setmethod' then - kind = skind.Method + kind = define.SymbolKind.Method else - kind = skind.Function + kind = define.SymbolKind.Function end symbols[#symbols+1] = { name = name, @@ -76,23 +76,23 @@ local function buildValue(source, symbols) details[1] = 'param' range = { source.start, source.finish } sRange = { source.start, source.finish } - kind = skind.Constant + kind = define.SymbolKind.Constant else details[1] = 'local' range = { source.start, source.finish } sRange = { source.start, source.finish } - kind = skind.Variable + kind = define.SymbolKind.Variable end elseif source.type == 'setlocal' then details[1] = 'setlocal' range = { source.start, source.finish } sRange = { source.start, source.finish } - kind = skind.Variable + kind = define.SymbolKind.Variable elseif source.type == 'setglobal' then details[1] = 'global' range = { source.start, source.finish } sRange = { source.start, source.finish } - kind = skind.Class + kind = define.SymbolKind.Class elseif source.type == 'tablefield' then if not source.field then return @@ -100,7 +100,7 @@ local function buildValue(source, symbols) details[1] = 'field' range = { source.field.start, source.field.finish } sRange = { source.field.start, source.field.finish } - kind = skind.Property + kind = define.SymbolKind.Property elseif source.type == 'setfield' then if not source.field then return @@ -108,7 +108,7 @@ local function buildValue(source, symbols) details[1] = 'field' range = { source.field.start, source.field.finish } sRange = { source.field.start, source.field.finish } - kind = skind.Field + kind = define.SymbolKind.Field else return end @@ -172,7 +172,7 @@ local function buildAnonymousFunction(source, used, symbols) symbols[#symbols+1] = { name = '', detail = 'function ()', - kind = skind.Function, + kind = define.SymbolKind.Function, range = { source.start, source.finish }, selectionRange = { source.start, source.start }, valueRange = { source.start, source.finish }, diff --git a/script-beta/core/keyword.lua b/script-beta/core/keyword.lua index 24a7dfa5..1cbeb78d 100644 --- a/script-beta/core/keyword.lua +++ b/script-beta/core/keyword.lua @@ -1,4 +1,4 @@ -local ckind = require 'define.CompletionItemKind' +local define = require 'proto.define' local guide = require 'parser.guide' local keyWordMap = { @@ -6,14 +6,14 @@ local keyWordMap = { if hasSpace then results[#results+1] = { label = 'do .. end', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[$0 end]], } else results[#results+1] = { label = 'do .. end', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ do @@ -42,14 +42,14 @@ end]], if hasSpace then results[#results+1] = { label = 'elseif .. then', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[$1 then]], } else results[#results+1] = { label = 'elseif .. then', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[elseif $1 then]], } @@ -62,7 +62,7 @@ end]], if hasSpace then results[#results+1] = { label = 'for .. in', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ ${1:key, value} in ${2:pairs(${3:t})} do @@ -71,7 +71,7 @@ end]] } results[#results+1] = { label = 'for i = ..', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ ${1:i} = ${2:1}, ${3:10, 1} do @@ -81,7 +81,7 @@ end]] else results[#results+1] = { label = 'for .. in', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ for ${1:key, value} in ${2:pairs(${3:t})} do @@ -90,7 +90,7 @@ end]] } results[#results+1] = { label = 'for i = ..', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ for ${1:i} = ${2:1}, ${3:10, 1} do @@ -104,7 +104,7 @@ end]] if hasSpace then results[#results+1] = { label = 'function ()', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ $1($2) @@ -114,7 +114,7 @@ end]] else results[#results+1] = { label = 'function ()', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ function $1($2) @@ -129,7 +129,7 @@ end]] if hasSpace then results[#results+1] = { label = 'if .. then', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ $1 then @@ -139,7 +139,7 @@ end]] else results[#results+1] = { label = 'if .. then', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ if $1 then @@ -153,7 +153,7 @@ end]] if hasSpace then results[#results+1] = { label = 'in ..', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ ${1:pairs(${2:t})} do @@ -163,7 +163,7 @@ end]] else results[#results+1] = { label = 'in ..', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ in ${1:pairs(${2:t})} do @@ -177,7 +177,7 @@ end]] if hasSpace then results[#results+1] = { label = 'local function', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ function $1($2) @@ -187,7 +187,7 @@ end]] else results[#results+1] = { label = 'local function', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ local function $1($2) @@ -204,14 +204,14 @@ end]] if hasSpace then results[#results+1] = { label = 'repeat .. until', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[$0 until $1]] } else results[#results+1] = { label = 'repeat .. until', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ repeat @@ -225,7 +225,7 @@ until $1]] if not hasSpace then results[#results+1] = { label = 'do return end', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[do return $1end]] } @@ -239,7 +239,7 @@ until $1]] if hasSpace then results[#results+1] = { label = 'while .. do', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ ${1:true} do @@ -249,7 +249,7 @@ end]] else results[#results+1] = { label = 'while .. do', - kind = ckind.Snippet, + kind = define.CompletionItemKind.Snippet, insertTextFormat = 2, insertText = [[ while ${1:true} do diff --git a/script-beta/core/semantic-tokens.lua b/script-beta/core/semantic-tokens.lua index 996ebb98..5c6fa1b5 100644 --- a/script-beta/core/semantic-tokens.lua +++ b/script-beta/core/semantic-tokens.lua @@ -1,8 +1,7 @@ local files = require 'files' local guide = require 'parser.guide' local await = require 'await' -local TokenTypes = require 'define.TokenTypes' -local TokenModifiers = require 'define.TokenModifiers' +local define = require 'proto.define' local vm = require 'vm' local util = require 'utility' @@ -11,8 +10,8 @@ Care['setglobal'] = function (source, results) results[#results+1] = { start = source.start, finish = source.finish, - type = TokenTypes.namespace, - modifieres = TokenModifiers.deprecated, + type = define.TokenTypes.namespace, + modifieres = define.TokenTypes.deprecated, } end Care['getglobal'] = function (source, results) @@ -24,16 +23,16 @@ Care['getglobal'] = function (source, results) results[#results+1] = { start = source.start, finish = source.finish, - type = TokenTypes.namespace, - modifieres = TokenModifiers.static, + type = define.TokenTypes.namespace, + modifieres = define.TokenTypes.static, } end else results[#results+1] = { start = source.start, finish = source.finish, - type = TokenTypes.namespace, - modifieres = TokenModifiers.deprecated, + type = define.TokenTypes.namespace, + modifieres = define.TokenTypes.deprecated, } end end @@ -45,8 +44,8 @@ Care['tablefield'] = function (source, results) results[#results+1] = { start = field.start, finish = field.finish, - type = TokenTypes.property, - modifieres = TokenModifiers.declaration, + type = define.TokenTypes.property, + modifieres = define.TokenTypes.declaration, } end Care['getlocal'] = function (source, results) @@ -56,8 +55,8 @@ Care['getlocal'] = function (source, results) results[#results+1] = { start = source.start, finish = source.finish, - type = TokenTypes.parameter, - modifieres = TokenModifiers.declaration, + type = define.TokenTypes.parameter, + modifieres = define.TokenTypes.declaration, } return end @@ -79,8 +78,8 @@ Care['getlocal'] = function (source, results) results[#results+1] = { start = source.start, finish = source.finish, - type = TokenTypes.interface, - modifieres = TokenModifiers.declaration, + type = define.TokenTypes.interface, + modifieres = define.TokenTypes.declaration, } return end @@ -88,7 +87,7 @@ Care['getlocal'] = function (source, results) results[#results+1] = { start = source.start, finish = source.finish, - type = TokenTypes.variable, + type = define.TokenTypes.variable, } end Care['setlocal'] = Care['getlocal'] diff --git a/script-beta/core/workspace-symbol.lua b/script-beta/core/workspace-symbol.lua index 5248f3c6..fb3dd88f 100644 --- a/script-beta/core/workspace-symbol.lua +++ b/script-beta/core/workspace-symbol.lua @@ -1,7 +1,7 @@ local files = require 'files' local guide = require 'parser.guide' local matchKey = require 'core.matchkey' -local skind = require 'define.SymbolKind' +local define = require 'proto.define' local function buildSource(uri, source, key, results) if source.type == 'local' @@ -11,7 +11,7 @@ local function buildSource(uri, source, key, results) if matchKey(key, name) then results[#results+1] = { name = name, - kind = skind.Variable, + kind = define.SymbolKind.Variable, uri = uri, range = { source.start, source.finish }, } @@ -23,7 +23,7 @@ local function buildSource(uri, source, key, results) if matchKey(key, name) then results[#results+1] = { name = name, - kind = skind.Field, + kind = define.SymbolKind.Field, uri = uri, range = { field.start, field.finish }, } @@ -34,7 +34,7 @@ local function buildSource(uri, source, key, results) if matchKey(key, name) then results[#results+1] = { name = name, - kind = skind.Method, + kind = define.SymbolKind.Method, uri = uri, range = { method.start, method.finish }, } diff --git a/script-beta/define/CompletionItemKind.lua b/script-beta/define/CompletionItemKind.lua deleted file mode 100644 index 45cee789..00000000 --- a/script-beta/define/CompletionItemKind.lua +++ /dev/null @@ -1,27 +0,0 @@ -return { - Text = 1, - Method = 2, - Function = 3, - Constructor = 4, - Field = 5, - Variable = 6, - Class = 7, - Interface = 8, - Module = 9, - Property = 10, - Unit = 11, - Value = 12, - Enum = 13, - Keyword = 14, - Snippet = 15, - Color = 16, - File = 17, - Reference = 18, - Folder = 19, - EnumMember = 20, - Constant = 21, - Struct = 22, - Event = 23, - Operator = 24, - TypeParameter = 25, -} diff --git a/script-beta/define/DiagnosticDefaultSeverity.lua b/script-beta/define/DiagnosticDefaultSeverity.lua deleted file mode 100644 index 75cf4a6b..00000000 --- a/script-beta/define/DiagnosticDefaultSeverity.lua +++ /dev/null @@ -1,22 +0,0 @@ -return { - ['unused-local'] = 'Hint', - ['unused-function'] = 'Hint', - ['undefined-global'] = 'Warning', - ['global-in-nil-env'] = 'Warning', - ['unused-label'] = 'Hint', - ['unused-vararg'] = 'Hint', - ['trailing-space'] = 'Hint', - ['redefined-local'] = 'Hint', - ['newline-call'] = 'Information', - ['newfield-call'] = 'Warning', - ['redundant-parameter'] = 'Hint', - ['ambiguity-1'] = 'Warning', - ['lowercase-global'] = 'Information', - ['undefined-env-child'] = 'Information', - ['duplicate-index'] = 'Warning', - ['empty-block'] = 'Hint', - ['redundant-value'] = 'Hint', - ['set-const'] = 'Error', - - ['duplicate-doc-class'] = 'Warning', -} diff --git a/script-beta/define/DiagnosticSeverity.lua b/script-beta/define/DiagnosticSeverity.lua deleted file mode 100644 index 05bd3659..00000000 --- a/script-beta/define/DiagnosticSeverity.lua +++ /dev/null @@ -1,6 +0,0 @@ -return { - Error = 1, - Warning = 2, - Information = 3, - Hint = 4, -} diff --git a/script-beta/define/ErrorCodes.lua b/script-beta/define/ErrorCodes.lua deleted file mode 100644 index befb5630..00000000 --- a/script-beta/define/ErrorCodes.lua +++ /dev/null @@ -1,16 +0,0 @@ - -return { - -- Defined by JSON RPC - ParseError = -32700, - InvalidRequest = -32600, - MethodNotFound = -32601, - InvalidParams = -32602, - InternalError = -32603, - serverErrorStart = -32099, - serverErrorEnd = -32000, - ServerNotInitialized = -32002, - UnknownErrorCode = -32001, - - -- Defined by the protocol. - RequestCancelled = -32800, -} diff --git a/script-beta/define/SymbolKind.lua b/script-beta/define/SymbolKind.lua deleted file mode 100644 index a28b3787..00000000 --- a/script-beta/define/SymbolKind.lua +++ /dev/null @@ -1,28 +0,0 @@ -return { - File = 1, - Module = 2, - Namespace = 3, - Package = 4, - Class = 5, - Method = 6, - Property = 7, - Field = 8, - Constructor = 9, - Enum = 10, - Interface = 11, - Function = 12, - Variable = 13, - Constant = 14, - String = 15, - Number = 16, - Boolean = 17, - Array = 18, - Object = 19, - Key = 20, - Null = 21, - EnumMember = 22, - Struct = 23, - Event = 24, - Operator = 25, - TypeParameter = 26, -} diff --git a/script-beta/define/TokenModifiers.lua b/script-beta/define/TokenModifiers.lua deleted file mode 100644 index b77fd386..00000000 --- a/script-beta/define/TokenModifiers.lua +++ /dev/null @@ -1,8 +0,0 @@ -return { - ["declaration"] = 1 << 0, - ["documentation"] = 1 << 1, - ["static"] = 1 << 2, - ["abstract"] = 1 << 3, - ["deprecated"] = 1 << 4, - ["readonly"] = 1 << 5, -} diff --git a/script-beta/define/TokenTypes.lua b/script-beta/define/TokenTypes.lua deleted file mode 100644 index 236a7805..00000000 --- a/script-beta/define/TokenTypes.lua +++ /dev/null @@ -1,21 +0,0 @@ -return { - ["comment"] = 0, - ["keyword"] = 1, - ["number"] = 2, - ["regexp"] = 3, - ["operator"] = 4, - ["namespace"] = 5, - ["type"] = 6, - ["struct"] = 7, - ["class"] = 8, - ["interface"] = 9, - ["enum"] = 10, - ["typeParameter"] = 11, - ["function"] = 12, - ["member"] = 13, - ["macro"] = 14, - ["variable"] = 15, - ["parameter"] = 16, - ["property"] = 17, - ["label"] = 18, -} diff --git a/script-beta/proto/define.lua b/script-beta/proto/define.lua index e43b73ef..5486733e 100644 --- a/script-beta/proto/define.lua +++ b/script-beta/proto/define.lua @@ -159,4 +159,116 @@ m.FileChangeType = { Deleted = 3, } +m.CompletionItemKind = { + Text = 1, + Method = 2, + Function = 3, + Constructor = 4, + Field = 5, + Variable = 6, + Class = 7, + Interface = 8, + Module = 9, + Property = 10, + Unit = 11, + Value = 12, + Enum = 13, + Keyword = 14, + Snippet = 15, + Color = 16, + File = 17, + Reference = 18, + Folder = 19, + EnumMember = 20, + Constant = 21, + Struct = 22, + Event = 23, + Operator = 24, + TypeParameter = 25, +} + +m.DiagnosticSeverity = { + Error = 1, + Warning = 2, + Information = 3, + Hint = 4, +} + +m.ErrorCodes = { + -- Defined by JSON RPC + ParseError = -32700, + InvalidRequest = -32600, + MethodNotFound = -32601, + InvalidParams = -32602, + InternalError = -32603, + serverErrorStart = -32099, + serverErrorEnd = -32000, + ServerNotInitialized = -32002, + UnknownErrorCode = -32001, + + -- Defined by the protocol. + RequestCancelled = -32800, +} + +m.SymbolKind = { + File = 1, + Module = 2, + Namespace = 3, + Package = 4, + Class = 5, + Method = 6, + Property = 7, + Field = 8, + Constructor = 9, + Enum = 10, + Interface = 11, + Function = 12, + Variable = 13, + Constant = 14, + String = 15, + Number = 16, + Boolean = 17, + Array = 18, + Object = 19, + Key = 20, + Null = 21, + EnumMember = 22, + Struct = 23, + Event = 24, + Operator = 25, + TypeParameter = 26, +} + +m.TokenModifiers = { + ["declaration"] = 1 << 0, + ["documentation"] = 1 << 1, + ["static"] = 1 << 2, + ["abstract"] = 1 << 3, + ["deprecated"] = 1 << 4, + ["readonly"] = 1 << 5, +} + +m.TokenTypes = { + ["comment"] = 0, + ["keyword"] = 1, + ["number"] = 2, + ["regexp"] = 3, + ["operator"] = 4, + ["namespace"] = 5, + ["type"] = 6, + ["struct"] = 7, + ["class"] = 8, + ["interface"] = 9, + ["enum"] = 10, + ["typeParameter"] = 11, + ["function"] = 12, + ["member"] = 13, + ["macro"] = 14, + ["variable"] = 15, + ["parameter"] = 16, + ["property"] = 17, + ["label"] = 18, +} + + return m diff --git a/script-beta/proto/proto.lua b/script-beta/proto/proto.lua index a4d86d2b..d8538d8f 100644 --- a/script-beta/proto/proto.lua +++ b/script-beta/proto/proto.lua @@ -3,7 +3,7 @@ local util = require 'utility' local await = require 'await' local pub = require 'pub' local jsonrpc = require 'jsonrpc' -local ErrorCodes = require 'define.ErrorCodes' +local define = require 'proto.define' local timer = require 'timer' local json = require 'json' @@ -89,7 +89,7 @@ function m.doMethod(proto) log.warn('Recieved unknown proto: ' .. method) end if proto.id then - m.responseErr(proto.id, ErrorCodes.MethodNotFound, method) + m.responseErr(proto.id, define.ErrorCodes.MethodNotFound, method) end return end @@ -114,7 +114,7 @@ function m.doMethod(proto) if ok then m.response(proto.id, res) else - m.responseErr(proto.id, ErrorCodes.InternalError, res) + m.responseErr(proto.id, define.ErrorCodes.InternalError, res) end end) ok, res = xpcall(abil, log.error, proto.params) diff --git a/script-beta/provider/semantic-tokens.lua b/script-beta/provider/semantic-tokens.lua index a8b1b23f..96db324e 100644 --- a/script-beta/provider/semantic-tokens.lua +++ b/script-beta/provider/semantic-tokens.lua @@ -1,6 +1,5 @@ local proto = require 'proto' -local tokenTypes = require 'define.TokenTypes' -local tokenModifiers = require 'define.TokenModifiers' +local define = require 'proto.define' local client = require 'provider.client' local isEnable = false @@ -32,8 +31,8 @@ local function enable() method = 'textDocument/semanticTokens/full', registerOptions = { legend = { - tokenTypes = toArray(tokenTypes), - tokenModifiers = toArray(tokenModifiers), + tokenTypes = toArray(define.TokenTypes), + tokenModifiers = toArray(define.TokenModifiers), }, range = true, full = false, diff --git a/test-beta/completion/init.lua b/test-beta/completion/init.lua index 7866ac11..63710e81 100644 --- a/test-beta/completion/init.lua +++ b/test-beta/completion/init.lua @@ -1,6 +1,6 @@ -local core = require 'core.completion' -local files = require 'files' -local CompletionItemKind = require 'define.CompletionItemKind' +local core = require 'core.completion' +local files = require 'files' +local define = require 'proto.define' local config = require 'config' local EXISTS = {'EXISTS'} @@ -80,7 +80,7 @@ za$ { { label = 'zabcde', - kind = CompletionItemKind.Variable, + kind = define.CompletionItemKind.Variable, } } @@ -92,11 +92,11 @@ zabcde$ { { label = 'zabcdefg', - kind = CompletionItemKind.Variable, + kind = define.CompletionItemKind.Variable, }, { label = 'zabcde', - kind = CompletionItemKind.Variable, + kind = define.CompletionItemKind.Variable, }, } @@ -108,11 +108,11 @@ local zabcde { { label = 'zabcdefg', - kind = CompletionItemKind.Variable, + kind = define.CompletionItemKind.Variable, }, { label = 'zabcde', - kind = CompletionItemKind.Text, + kind = define.CompletionItemKind.Text, }, } @@ -123,7 +123,7 @@ zace$ { { label = 'zabcde', - kind = CompletionItemKind.Variable, + kind = define.CompletionItemKind.Variable, } } @@ -135,11 +135,11 @@ zac$ { { label = 'zabc', - kind = CompletionItemKind.Variable, + kind = define.CompletionItemKind.Variable, }, { label = 'ZABC', - kind = CompletionItemKind.Field, + kind = define.CompletionItemKind.Field, }, } @@ -149,11 +149,11 @@ ass$ { { label = 'assert', - kind = CompletionItemKind.Function, + kind = define.CompletionItemKind.Function, }, { label = 'assert()', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, }, } @@ -165,11 +165,11 @@ ff$ { { label = 'ffff', - kind = CompletionItemKind.Function, + kind = define.CompletionItemKind.Function, }, { label = 'ffff()', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, } } @@ -180,7 +180,7 @@ z$ { { label = 'zabc', - kind = CompletionItemKind.Variable, + kind = define.CompletionItemKind.Variable, } } @@ -191,7 +191,7 @@ z$ { { label = 'zabc', - kind = CompletionItemKind.Variable, + kind = define.CompletionItemKind.Variable, } } @@ -204,7 +204,7 @@ t.ab$ { { label = 'abc', - kind = CompletionItemKind.Enum, + kind = define.CompletionItemKind.Enum, } } @@ -218,7 +218,7 @@ t.ab$ { { label = 'abc', - kind = CompletionItemKind.Enum, + kind = define.CompletionItemKind.Enum, } } @@ -233,15 +233,15 @@ mt:g$ { { label = 'get', - kind = CompletionItemKind.Method, + kind = define.CompletionItemKind.Method, }, { label = 'get()', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, }, { label = 'ggg', - kind = CompletionItemKind.Text, + kind = define.CompletionItemKind.Text, } } @@ -251,19 +251,19 @@ loc$ { { label = 'local', - kind = CompletionItemKind.Keyword, + kind = define.CompletionItemKind.Keyword, }, { label = 'local function', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, }, { label = 'collectgarbage', - kind = CompletionItemKind.Function, + kind = define.CompletionItemKind.Function, }, { label = 'collectgarbage()', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, }, } @@ -273,35 +273,35 @@ do$ { { label = 'do', - kind = CompletionItemKind.Keyword, + kind = define.CompletionItemKind.Keyword, }, { label = 'do .. end', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, }, { label = 'dofile', - kind = CompletionItemKind.Function, + kind = define.CompletionItemKind.Function, }, { label = 'dofile()', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, }, { label = 'load', - kind = CompletionItemKind.Function, + kind = define.CompletionItemKind.Function, }, { label = 'load()', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, }, { label = 'loadfile', - kind = CompletionItemKind.Function, + kind = define.CompletionItemKind.Function, }, { label = 'loadfile()', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, }, } @@ -311,11 +311,11 @@ while true d$ { { label = 'do', - kind = CompletionItemKind.Keyword, + kind = define.CompletionItemKind.Keyword, }, { label = 'do .. end', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, }, } @@ -345,7 +345,7 @@ end { { label = 'ast', - kind = CompletionItemKind.Variable, + kind = define.CompletionItemKind.Variable, } } @@ -357,11 +357,11 @@ t.$ { { label = 'a', - kind = CompletionItemKind.Field, + kind = define.CompletionItemKind.Field, }, { label = 'b', - kind = CompletionItemKind.Field, + kind = define.CompletionItemKind.Field, }, } @@ -373,11 +373,11 @@ t. $ { { label = 'a', - kind = CompletionItemKind.Field, + kind = define.CompletionItemKind.Field, }, { label = 'b', - kind = CompletionItemKind.Field, + kind = define.CompletionItemKind.Field, }, } @@ -390,11 +390,11 @@ t:$ { { label = 'b', - kind = CompletionItemKind.Method, + kind = define.CompletionItemKind.Method, }, { label = 'b()', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, }, } @@ -408,7 +408,7 @@ xxx() { { label = 'a', - kind = CompletionItemKind.Field, + kind = define.CompletionItemKind.Field, }, } @@ -435,31 +435,31 @@ local t = { { { label = 'xxxx', - kind = CompletionItemKind.Variable, + kind = define.CompletionItemKind.Variable, }, { label = 'xxyy', - kind = CompletionItemKind.Property, + kind = define.CompletionItemKind.Property, }, { label = 'xxzz', - kind = CompletionItemKind.Property, + kind = define.CompletionItemKind.Property, }, { label = 'next', - kind = CompletionItemKind.Function, + kind = define.CompletionItemKind.Function, }, { label = 'next()', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, }, { label = 'xpcall', - kind = CompletionItemKind.Function, + kind = define.CompletionItemKind.Function, }, { label = 'xpcall()', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, }, } @@ -472,23 +472,23 @@ print(fff) { { label = 'function', - kind = CompletionItemKind.Keyword, + kind = define.CompletionItemKind.Keyword, }, { label = 'function ()', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, }, { label = 'fff', - kind = CompletionItemKind.Variable, + kind = define.CompletionItemKind.Variable, }, { label = 'ff2', - kind = CompletionItemKind.Text, + kind = define.CompletionItemKind.Text, }, { label = 'faa', - kind = CompletionItemKind.Text, + kind = define.CompletionItemKind.Text, }, } @@ -500,7 +500,7 @@ end { { label = 'fff', - kind = CompletionItemKind.Variable, + kind = define.CompletionItemKind.Variable, }, } @@ -515,7 +515,7 @@ collectgarbage('$') { { label = "'collect'", - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, textEdit = { start = 16, finish = 17, @@ -524,7 +524,7 @@ collectgarbage('$') }, { label = "'stop'", - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, textEdit = { start = 16, finish = 17, @@ -533,7 +533,7 @@ collectgarbage('$') }, { label = "'restart'", - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, textEdit = { start = 16, finish = 17, @@ -542,7 +542,7 @@ collectgarbage('$') }, { label = "'count'", - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, textEdit = { start = 16, finish = 17, @@ -551,7 +551,7 @@ collectgarbage('$') }, { label = "'step'", - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, textEdit = { start = 16, finish = 17, @@ -560,7 +560,7 @@ collectgarbage('$') }, { label = "'incremental'", - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, textEdit = { start = 16, finish = 17, @@ -569,7 +569,7 @@ collectgarbage('$') }, { label = "'generational'", - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, textEdit = { start = 16, finish = 17, @@ -578,7 +578,7 @@ collectgarbage('$') }, { label = "'isrunning'", - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, textEdit = { start = 16, finish = 17, @@ -593,19 +593,19 @@ io.read($) { { label = '"n"', - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, }, { label = '"a"', - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, }, { label = '"l"', - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, }, { label = '"L"', - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, }, } @@ -626,7 +626,7 @@ self.results.list[#$] { { label = '#self.results.list+1', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, textEdit = { start = 19, finish = 20, @@ -642,7 +642,7 @@ local n = 1 { { label = '#self.results.list+1', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, textEdit = { start = 19, finish = 20, @@ -657,7 +657,7 @@ self.results.list[#$] = 1 { { label = '#self.results.list+1', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, textEdit = { start = 19, finish = 20, @@ -672,7 +672,7 @@ self.results.list[#self.re$] { { label = '#self.results.list+1', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, textEdit = { start = 19, finish = 27, @@ -681,7 +681,7 @@ self.results.list[#self.re$] }, { label = 'results', - kind = CompletionItemKind.Field, + kind = define.CompletionItemKind.Field, }, } @@ -691,7 +691,7 @@ fff[#ff$] { { label = '#fff+1', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, textEdit = { start = 5, finish = 8, @@ -700,7 +700,7 @@ fff[#ff$] }, { label = 'fff', - kind = CompletionItemKind.Field, + kind = define.CompletionItemKind.Field, } } @@ -710,7 +710,7 @@ local _ = fff.kkk[#$] { { label = '#fff.kkk', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, textEdit = { start = 19, finish = 20, @@ -725,7 +725,7 @@ fff.kkk[#$].yy { { label = '#fff.kkk', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, textEdit = { start = 9, finish = 10, @@ -777,7 +777,7 @@ xxxx$ { { label = 'xxxx', - kind = CompletionItemKind.Variable, + kind = define.CompletionItemKind.Variable, }, } @@ -789,11 +789,11 @@ xxxx$ { { label = 'xxxx', - kind = CompletionItemKind.Variable, + kind = define.CompletionItemKind.Variable, }, { label = 'XXXX', - kind = CompletionItemKind.Variable, + kind = define.CompletionItemKind.Variable, }, } @@ -806,7 +806,7 @@ xx$ { { label = 'xxxxx', - kind = CompletionItemKind.Text, + kind = define.CompletionItemKind.Text, }, } @@ -817,7 +817,7 @@ tbl[ind$] { { label = 'index', - kind = CompletionItemKind.Variable, + kind = define.CompletionItemKind.Variable, }, } @@ -833,11 +833,11 @@ end { { label = 'a', - kind = CompletionItemKind.Field, + kind = define.CompletionItemKind.Field, }, { label = 'b', - kind = CompletionItemKind.Field, + kind = define.CompletionItemKind.Field, }, } @@ -858,7 +858,7 @@ end { { label = 'add', - kind = CompletionItemKind.Variable, + kind = define.CompletionItemKind.Variable, }, } @@ -886,11 +886,11 @@ require 'config' .config.runtime.version = 'Lua 5.4' --{ -- { -- label = '<toclose>', --- kind = CompletionItemKind.Keyword, +-- kind = define.CompletionItemKind.Keyword, -- }, -- { -- label = '<const>', --- kind = CompletionItemKind.Keyword, +-- kind = define.CompletionItemKind.Keyword, -- }, --} -- @@ -900,7 +900,7 @@ require 'config' .config.runtime.version = 'Lua 5.4' --{ -- { -- label = '<toclose>', --- kind = CompletionItemKind.Keyword, +-- kind = define.CompletionItemKind.Keyword, -- } --} @@ -914,7 +914,7 @@ t.$ { { label = '__index', - kind = CompletionItemKind.Field, + kind = define.CompletionItemKind.Field, } } @@ -927,39 +927,39 @@ else$ { { label = 'else', - kind = CompletionItemKind.Keyword, + kind = define.CompletionItemKind.Keyword, }, { label = 'elseif', - kind = CompletionItemKind.Keyword, + kind = define.CompletionItemKind.Keyword, }, { label = 'elseif .. then', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, }, { label = 'elseaaa', - kind = CompletionItemKind.Variable, + kind = define.CompletionItemKind.Variable, }, { label = 'ELSE', - kind = CompletionItemKind.Enum, + kind = define.CompletionItemKind.Enum, }, { label = 'select', - kind = CompletionItemKind.Function, + kind = define.CompletionItemKind.Function, }, { label = 'select()', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, }, { label = 'setmetatable', - kind = CompletionItemKind.Function, + kind = define.CompletionItemKind.Function, }, { label = 'setmetatable()', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, }, } @@ -971,15 +971,15 @@ xpcal$ { { label = 'xpcal', - kind = CompletionItemKind.Variable, + kind = define.CompletionItemKind.Variable, }, { label = 'xpcall', - kind = CompletionItemKind.Function, + kind = define.CompletionItemKind.Function, }, { label = 'xpcall()', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, insertText = EXISTS, }, } @@ -993,11 +993,11 @@ mt:f$ { { label = 'f', - kind = CompletionItemKind.Method, + kind = define.CompletionItemKind.Method, }, { label = 'f()', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, insertText = 'f(${1:a: any}, ${2:b: any}, ${3:c: any})', }, } @@ -1012,31 +1012,31 @@ end { { label = 'else', - kind = CompletionItemKind.Keyword, + kind = define.CompletionItemKind.Keyword, }, { label = 'elseif', - kind = CompletionItemKind.Keyword, + kind = define.CompletionItemKind.Keyword, }, { label = 'elseif .. then', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, }, { label = 'select', - kind = CompletionItemKind.Function, + kind = define.CompletionItemKind.Function, }, { label = 'select()', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, }, { label = 'setmetatable', - kind = CompletionItemKind.Function, + kind = define.CompletionItemKind.Function, }, { label = 'setmetatable()', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, }, } @@ -1050,7 +1050,7 @@ t.$ { { label = 'a.b.c', - kind = CompletionItemKind.Field, + kind = define.CompletionItemKind.Field, textEdit = { start = 37, finish = 36, @@ -1076,7 +1076,7 @@ t. $ { { label = 'a.b.c', - kind = CompletionItemKind.Field, + kind = define.CompletionItemKind.Field, textEdit = { start = 40, finish = 39, @@ -1102,7 +1102,7 @@ t['$'] { { label = 'a.b.c', - kind = CompletionItemKind.Field, + kind = define.CompletionItemKind.Field, textEdit = { start = 38, finish = 37, @@ -1119,7 +1119,7 @@ z$ { { label = 'z.b.c', - kind = CompletionItemKind.Field, + kind = define.CompletionItemKind.Field, textEdit = { start = 21, finish = 21, @@ -1128,7 +1128,7 @@ z$ }, { label = 'z', - kind = CompletionItemKind.Text, + kind = define.CompletionItemKind.Text, } } @@ -1148,12 +1148,12 @@ debug.setcsta$ { { label = 'setcstacklimit', - kind = CompletionItemKind.Function, + kind = define.CompletionItemKind.Function, deprecated = true, }, { label = 'setcstacklimit()', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, deprecated = true, }, } @@ -1170,7 +1170,7 @@ TEST [[ { { label = 'class', - kind = CompletionItemKind.Keyword + kind = define.CompletionItemKind.Keyword } } @@ -1181,11 +1181,11 @@ TEST [[ { { label = 'ZABC', - kind = CompletionItemKind.Class, + kind = define.CompletionItemKind.Class, }, { label = 'ZBBC', - kind = CompletionItemKind.Class, + kind = define.CompletionItemKind.Class, }, } @@ -1197,7 +1197,7 @@ local abcd { { label = 'zabc', - kind = CompletionItemKind.Class, + kind = define.CompletionItemKind.Class, }, } @@ -1216,7 +1216,7 @@ local abcd { { label = 'zabc', - kind = CompletionItemKind.Class, + kind = define.CompletionItemKind.Class, } } @@ -1227,7 +1227,7 @@ TEST [[ { { label = 'zabc', - kind = CompletionItemKind.Class, + kind = define.CompletionItemKind.Class, }, } @@ -1238,11 +1238,11 @@ TEST [[ { { label = 'Class', - kind = CompletionItemKind.Class, + kind = define.CompletionItemKind.Class, }, { label = 'function', - kind = CompletionItemKind.Class, + kind = define.CompletionItemKind.Class, }, } @@ -1254,7 +1254,7 @@ end { { label = 'a, b, c', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, insertText = [[ a any ---@param b any @@ -1262,15 +1262,15 @@ a any }, { label = 'a', - kind = CompletionItemKind.Interface, + kind = define.CompletionItemKind.Interface, }, { label = 'b', - kind = CompletionItemKind.Interface, + kind = define.CompletionItemKind.Interface, }, { label = 'c', - kind = CompletionItemKind.Interface, + kind = define.CompletionItemKind.Interface, }, } @@ -1284,7 +1284,7 @@ end { { label = 'a, b, c', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, insertText = [[ a any ---@param b any @@ -1292,15 +1292,15 @@ a any }, { label = 'a', - kind = CompletionItemKind.Interface, + kind = define.CompletionItemKind.Interface, }, { label = 'b', - kind = CompletionItemKind.Interface, + kind = define.CompletionItemKind.Interface, }, { label = 'c', - kind = CompletionItemKind.Interface, + kind = define.CompletionItemKind.Interface, }, } @@ -1312,7 +1312,7 @@ end { { label = 'a, b, c', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, insertText = [[ a any ---@param b any @@ -1320,15 +1320,15 @@ a any }, { label = 'a', - kind = CompletionItemKind.Interface, + kind = define.CompletionItemKind.Interface, }, { label = 'b', - kind = CompletionItemKind.Interface, + kind = define.CompletionItemKind.Interface, }, { label = 'c', - kind = CompletionItemKind.Interface, + kind = define.CompletionItemKind.Interface, }, } @@ -1340,15 +1340,15 @@ function f(x$) { { label = 'xyz, xxx', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, }, { label = 'xyz', - kind = CompletionItemKind.Interface, + kind = define.CompletionItemKind.Interface, }, { label = 'xxx', - kind = CompletionItemKind.Interface, + kind = define.CompletionItemKind.Interface, }, } @@ -1360,15 +1360,15 @@ function f($ { { label = 'xyz, xxx', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, }, { label = 'xyz', - kind = CompletionItemKind.Interface, + kind = define.CompletionItemKind.Interface, }, { label = 'xxx', - kind = CompletionItemKind.Interface, + kind = define.CompletionItemKind.Interface, }, } @@ -1380,15 +1380,15 @@ function f($) { { label = 'xyz, xxx', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, }, { label = 'xyz', - kind = CompletionItemKind.Interface, + kind = define.CompletionItemKind.Interface, }, { label = 'xxx', - kind = CompletionItemKind.Interface, + kind = define.CompletionItemKind.Interface, }, } @@ -1400,11 +1400,11 @@ end { { label = 'type', - kind = CompletionItemKind.Keyword, + kind = define.CompletionItemKind.Keyword, }, { label = 'return', - kind = CompletionItemKind.Keyword, + kind = define.CompletionItemKind.Keyword, } } @@ -1418,12 +1418,12 @@ mt.$ { { label = 'id', - kind = CompletionItemKind.Field, + kind = define.CompletionItemKind.Field, detail = EXISTS, }, { label = 'name', - kind = CompletionItemKind.Field, + kind = define.CompletionItemKind.Field, detail = EXISTS, }, } @@ -1438,15 +1438,15 @@ f(1, $) { { label = "'AAA'", - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, }, { label = "'BBB'", - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, }, { label = "'CCC'", - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, } } @@ -1460,15 +1460,15 @@ f(1,$) { { label = "'AAA'", - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, }, { label = "'BBB'", - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, }, { label = "'CCC'", - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, } } @@ -1482,15 +1482,15 @@ f($) { { label = "'AAA'", - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, }, { label = "'BBB'", - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, }, { label = "'CCC'", - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, } } @@ -1505,15 +1505,15 @@ f($) { { label = "'AAA'", - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, }, { label = "'BBB'", - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, }, { label = "'CCC'", - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, } } @@ -1528,21 +1528,21 @@ f('$') { label = "AAA", filterText = 'AAA', - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, textEdit = EXISTS, additionalTextEdits = EXISTS, }, { label = "BBB", filterText = 'BBB', - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, textEdit = EXISTS, additionalTextEdits = EXISTS, }, { label = "CCC", filterText = 'CCC', - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, textEdit = EXISTS, additionalTextEdits = EXISTS, } @@ -1576,7 +1576,7 @@ zzz$ { { label = 'zzzzz', - kind = CompletionItemKind.Function, + kind = define.CompletionItemKind.Function, detail = '(function)(4 prototypes)', description = { kind = 'markdown', @@ -1595,7 +1595,7 @@ JustTest }, { label = 'zzzzz()', - kind = CompletionItemKind.Snippet, + kind = define.CompletionItemKind.Snippet, detail = '(function)(4 prototypes)', insertText = EXISTS, description = EXISTS, @@ -1610,7 +1610,7 @@ zz$ { { label = 'zzz', - kind = CompletionItemKind.Enum, + kind = define.CompletionItemKind.Enum, detail = '(number) = 1', description = { kind = 'markdown', @@ -1630,12 +1630,12 @@ f($) { { label = "'选项1'", - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, description = '注释1', }, { label = "'选项2'", - kind = CompletionItemKind.EnumMember, + kind = define.CompletionItemKind.EnumMember, description = '注释2', }, } diff --git a/test-beta/document_symbol/init.lua b/test-beta/document_symbol/init.lua index a1b4f6fc..26928145 100644 --- a/test-beta/document_symbol/init.lua +++ b/test-beta/document_symbol/init.lua @@ -1,6 +1,6 @@ -local core = require 'core.document-symbol' -local files = require 'files' -local SymbolKind = require 'define.SymbolKind' +local core = require 'core.document-symbol' +local files = require 'files' +local define = require 'proto.define' rawset(_G, 'TEST', true) @@ -62,7 +62,7 @@ A = 1 [1] = { name = 'A', detail = 'global number = 1', - kind = SymbolKind.Class, + kind = define.SymbolKind.Class, range = {1, 5}, selectionRange = {1, 1}, } @@ -76,7 +76,7 @@ end [1] = { name = 'f', detail = 'function ()', - kind = SymbolKind.Function, + kind = define.SymbolKind.Function, range = {1, 22}, selectionRange = {16, 16}, valueRange = {1, 22}, @@ -91,7 +91,7 @@ end [1] = { name = 'f', detail = 'function ()', - kind = SymbolKind.Function, + kind = define.SymbolKind.Function, range = {1, 16}, selectionRange = {10, 10}, valueRange = {1, 16}, @@ -106,7 +106,7 @@ end [1] = { name = '', detail = 'function ()', - kind = SymbolKind.Function, + kind = define.SymbolKind.Function, range = {8, 22}, selectionRange = {8, 8}, valueRange = {8, 22}, @@ -121,7 +121,7 @@ end [1] = { name = 'f', detail = 'function ()', - kind = SymbolKind.Function, + kind = define.SymbolKind.Function, range = {1, 19}, selectionRange = {1, 1}, valueRange = {5, 19}, @@ -136,7 +136,7 @@ end [1] = { name = 'f', detail = 'function ()', - kind = SymbolKind.Function, + kind = define.SymbolKind.Function, range = {7, 25}, selectionRange = {7, 7}, valueRange = {11, 25}, @@ -151,7 +151,7 @@ end [1] = { name = 'mt:add', detail = 'function ()', - kind = SymbolKind.Method, + kind = define.SymbolKind.Method, range = {1, 21}, selectionRange = {10, 15}, valueRange = {1, 21}, @@ -172,7 +172,7 @@ end [1] = { name = 'A', detail = 'function ()', - kind = SymbolKind.Function, + kind = define.SymbolKind.Function, range = {1, 68}, selectionRange = {10, 10}, valueRange = {1, 68}, @@ -180,7 +180,7 @@ end [1] = { name = 'A1', detail = 'function ()', - kind = SymbolKind.Function, + kind = define.SymbolKind.Function, range = {18, 38}, selectionRange = {27, 28}, valueRange = {18, 38}, @@ -188,7 +188,7 @@ end [2] = { name = 'A2', detail = 'function ()', - kind = SymbolKind.Function, + kind = define.SymbolKind.Function, range = {44, 64}, selectionRange = {53, 54}, valueRange = {44, 64}, @@ -198,7 +198,7 @@ end [2] = { name = 'B', detail = 'function ()', - kind = SymbolKind.Function, + kind = define.SymbolKind.Function, range = {70, 85}, selectionRange = {79, 79}, valueRange = {70, 85}, @@ -219,14 +219,14 @@ local z [1] = { name = 'x', detail = 'local number = 1', - kind = SymbolKind.Variable, + kind = define.SymbolKind.Variable, range = {7, 11}, selectionRange = {7, 7}, }, [2] = { name = 'f', detail = 'function ()', - kind = SymbolKind.Function, + kind = define.SymbolKind.Function, range = {13, 79}, selectionRange = {28, 28}, valueRange = {13, 79}, @@ -234,14 +234,14 @@ local z [1] = { name = 'x', detail = 'local string = "x"', - kind = SymbolKind.Variable, + kind = define.SymbolKind.Variable, range = {42, 48}, selectionRange = {42, 42}, }, [2] = { name = 'y', detail = 'local {}', - kind = SymbolKind.Variable, + kind = define.SymbolKind.Variable, range = {60, 65}, selectionRange = {60, 60}, valueRange = {64, 65}, @@ -249,7 +249,7 @@ local z --[3] = { -- name = 'z', -- detail = 'global z: number = 1', - -- kind = SymbolKind.Object, + -- kind = define.SymbolKind.Object, -- range = {71, 71}, -- selectionRange = {71, 71}, -- valueRange = {75, 75}, @@ -259,14 +259,14 @@ local z [3] = { name = 'y', detail = 'local boolean = true', - kind = SymbolKind.Variable, + kind = define.SymbolKind.Variable, range = {87, 94}, selectionRange = {87, 87}, }, [4] = { name = 'z', detail = 'local', - kind = SymbolKind.Variable, + kind = define.SymbolKind.Variable, range = {102, 102}, selectionRange = {102, 102}, }, @@ -283,7 +283,7 @@ local t = { [1] = { name = 't', detail = 'local {a, b, c}', - kind = SymbolKind.Variable, + kind = define.SymbolKind.Variable, range = {7, 46}, selectionRange = {7, 7}, valueRange = {11, 46}, @@ -291,21 +291,21 @@ local t = { [1] = { name = 'a', detail = 'field number = 1', - kind = SymbolKind.Property, + kind = define.SymbolKind.Property, range = {17, 21}, selectionRange = {17, 17}, }, [2] = { name = 'b', detail = 'field number = 2', - kind = SymbolKind.Property, + kind = define.SymbolKind.Property, range = {28, 32}, selectionRange = {28, 28}, }, [3] = { name = 'c', detail = 'field number = 3', - kind = SymbolKind.Property, + kind = define.SymbolKind.Property, range = {39, 43}, selectionRange = {39, 39}, }, @@ -324,7 +324,7 @@ local t = { [1] = { name = 't', detail = 'local {a}', - kind = SymbolKind.Variable, + kind = define.SymbolKind.Variable, range = {7, 44}, selectionRange = {7, 7}, valueRange = {11, 44}, @@ -332,7 +332,7 @@ local t = { [1] = { name = 'a', detail = 'field {b}', - kind = SymbolKind.Property, + kind = define.SymbolKind.Property, range = {17, 42}, selectionRange = {17, 17}, valueRange = {21, 42}, @@ -340,7 +340,7 @@ local t = { [1] = { name = 'b', detail = EXISTS, - kind = SymbolKind.Property, + kind = define.SymbolKind.Property, range = {31, 35}, selectionRange = {31, 31}, } @@ -359,7 +359,7 @@ g = 1 [1] = { name = 'g', detail = 'function ()', - kind = SymbolKind.Function, + kind = define.SymbolKind.Function, range = {1, 22}, selectionRange = {16, 16}, valueRange = {1, 22}, @@ -367,7 +367,7 @@ g = 1 [2] = { name = 'g', detail = 'setlocal number = 1', - kind = SymbolKind.Variable, + kind = define.SymbolKind.Variable, range = {25, 29}, selectionRange = {25, 25}, } @@ -382,7 +382,7 @@ end [1] = { name = 'f', detail = 'function (a, b, ...)', - kind = SymbolKind.Function, + kind = define.SymbolKind.Function, range = {1, 58}, selectionRange = {10, 10}, valueRange = {1, 58}, @@ -390,21 +390,21 @@ end [1] = { name = 'a', detail = 'param', - kind = SymbolKind.Constant, + kind = define.SymbolKind.Constant, range = {12, 12}, selectionRange = {12, 12}, }, [2] = { name = 'b', detail = 'param', - kind = SymbolKind.Constant, + kind = define.SymbolKind.Constant, range = {15, 15}, selectionRange = {15, 15}, }, [3] = { name = 'x', detail = 'local', - kind = SymbolKind.Variable, + kind = define.SymbolKind.Variable, range = {33, 39}, selectionRange = {33, 33}, } @@ -423,7 +423,7 @@ local v = t [1] = { name = 't', detail = 'local {a, b}', - kind = SymbolKind.Variable, + kind = define.SymbolKind.Variable, range = {7, 35}, selectionRange = {7, 7}, valueRange = {11, 35}, @@ -432,7 +432,7 @@ local v = t [2] = { name = 'v', detail = 'local', - kind = SymbolKind.Variable, + kind = define.SymbolKind.Variable, range = {44, 48}, selectionRange = {44, 44}, }, @@ -445,7 +445,7 @@ local function [1] = { name = 'x', detail = 'local', - kind = SymbolKind.Variable, + kind = define.SymbolKind.Variable, range = {7, 7}, selectionRange = {7, 7}, }, @@ -466,7 +466,7 @@ local a, b = { [1] = { name = 'a', detail = 'local {x, y, z}', - kind = SymbolKind.Variable, + kind = define.SymbolKind.Variable, range = {7, 49}, selectionRange = {7, 7}, valueRange = {14, 49}, @@ -475,7 +475,7 @@ local a, b = { [2] = { name = 'b', detail = 'local {x, y, z}', - kind = SymbolKind.Variable, + kind = define.SymbolKind.Variable, range = {10, 87}, selectionRange = {10, 10}, valueRange = {52, 87}, @@ -495,7 +495,7 @@ end [1] = { name = 'x', detail = 'function ()', - kind = SymbolKind.Function, + kind = define.SymbolKind.Function, range = {1, 22}, selectionRange = {16, 16}, valueRange = {1, 22}, @@ -503,7 +503,7 @@ end [2] = { name = 'f', detail = 'function ()', - kind = SymbolKind.Function, + kind = define.SymbolKind.Function, range = {25, 58}, selectionRange = {40, 40}, valueRange = {25, 58}, @@ -511,7 +511,7 @@ end [1] = { name = 'c', detail = 'local', - kind = SymbolKind.Variable, + kind = define.SymbolKind.Variable, range = {54, 54}, selectionRange = {54, 54}, }, @@ -528,7 +528,7 @@ local t = f({ [1] = { name = 't', detail = 'local', - kind = SymbolKind.Variable, + kind = define.SymbolKind.Variable, range = {7, 26}, selectionRange = {7, 7}, valueRange = {11, 26}, @@ -536,7 +536,7 @@ local t = f({ [1] = { name = 'k', detail = 'field number = 1', - kind = SymbolKind.Property, + kind = define.SymbolKind.Property, range = {19, 23}, selectionRange = {19, 19}, } @@ -554,7 +554,7 @@ end [1] = { name = 't', detail = 'local {}', - kind = SymbolKind.Variable, + kind = define.SymbolKind.Variable, range = {7, 12}, selectionRange = {7, 7}, valueRange = {11, 12}, @@ -562,7 +562,7 @@ end [2] = { name = 'f', detail = 'function (a, b)', - kind = SymbolKind.Function, + kind = define.SymbolKind.Function, range = {15, 40}, selectionRange = {30, 30}, valueRange = {15, 40}, @@ -570,14 +570,14 @@ end [1] = { name = 'a', detail = 'param', - kind = SymbolKind.Constant, + kind = define.SymbolKind.Constant, range = {32, 32}, selectionRange = {32, 32}, }, [2] = { name = 'b', detail = 'param', - kind = SymbolKind.Constant, + kind = define.SymbolKind.Constant, range = {35, 35}, selectionRange = {35, 35}, } @@ -595,7 +595,7 @@ local a = f { [1] = { name = 'a', detail = 'local', - kind = SymbolKind.Variable, + kind = define.SymbolKind.Variable, range = {7, 43}, selectionRange = {7, 7}, valueRange = {11, 43}, @@ -603,7 +603,7 @@ local a = f { [1] = { name = 'x', detail = 'function ()', - kind = SymbolKind.Function, + kind = define.SymbolKind.Function, range = {19, 41}, selectionRange = {19, 19}, valueRange = {23, 41}, |