LuaLS / LuaLS/lua-language-server
Wrong language when initialize server
还没有人认领这个 Issue。
- 主要语言
- Lua
- 星标
- 4.4k
- 派生
- 442
- PR 合并指标
- 30 天内没有已合并 PR
描述
How are you using the lua-language-server?
NeoVim
Which OS are you using?
MacOS
What is the issue affecting?
Diagnostics/Syntax Checking
Expected Behaviour
Correct language zh-tw
Actual Behaviour
Wrong language zh-cn
Reproduction steps
- Install
coc-luaandlua-language-server - Open lua file using neovim
- Got warning and suggestion by language server in
zh-cnlanguage
Additional Notes
I found in the log below that the language is set to locale = zh_TW, and it's being matched using only the first two characters against the supportLanguage list (['zh-cn', 'zh-tw', 'pt-br', 'en-us']) with the following code in language.lua:
for _, lang in ipairs(support) do
if lang:sub(1, 2) == id:sub(1, 2) then
return lang
end
end
As a result, the lang will become zh-cn. Is this because my locale should be correctly set to lowercase (zh-tw), or should we check both uppercase locale (zh_TW) and lowercase locale(zh-tw)?"
If this issue is a result of my misconfiguration, kindly inform me of the steps needed to rectify the locale settings.
Log File
log/service.log
[15:59:22.012][info] [#0:/Users/iver/.config/coc/extensions/coc-lua-data/lua-language-server/main.lua:66]: Lua Lsp startup, root: /Users/iver/.config/coc/extensions/coc-lua-data/lua-language-server
[15:59:22.012][info] [#0:/Users/iver/.config/coc/extensions/coc-lua-data/lua-language-server/main.lua:67]: ROOT: /Users/iver/.config/coc/extensions/coc-lua-data/lua-language-server
[15:59:22.012][info] [#0:/Users/iver/.config/coc/extensions/coc-lua-data/lua-language-server/main.lua:68]: LOGPATH: /Users/iver/.config/coc/extensions/coc-lua-data/lua-language-server/log
[15:59:22.012][info] [#0:/Users/iver/.config/coc/extensions/coc-lua-data/lua-language-server/main.lua:69]: METAPATH: /Users/iver/.config/coc/extensions/coc-lua-data/lua-language-server/meta
[15:59:22.013][info] [#0:/Users/iver/.config/coc/extensions/coc-lua-data/lua-language-server/main.lua:70]: VERSION: 3.7.0
[15:59:22.028][info] [#0:script/pub/pub.lua:81]: Push task to braves: "loadProtoByStdio" => 1
[15:59:22.028][info] [#0:script/pub/pub.lua:82]: nil
[15:59:22.028][info] [#0:script/service/service.lua:144]:
========= Medical Examination Report =========
--------------- Memory ---------------
Total: 2.141 MB
# 00 : 2.141 MB
# 01 : 0.000 MB
# 02 : 0.000 MB
# 03 : 0.000 MB
# 04 : 0.000 MB
--------------- Coroutine ---------------
Total: 0
Running: 0
Suspended: 0
Normal: 0
Dead: 0
--------------- Cache ---------------
Total: 1
Dead: 0
--------------- RPC ---------------
Holdon: 0
Waiting: 0
==============================================
[15:59:22.028][info] [#0:script/pub/pub.lua:81]: Push task to braves: "removeCaches" => 2
[15:59:22.028][info] [#0:script/pub/pub.lua:82]: /Users/iver/.config/coc/extensions/coc-lua-data/lua-language-server/log/cache
[15:59:22.030][info] [#0:script/pub/pub.lua:81]: Push task to braves: "timer" => 3
[15:59:22.030][info] [#0:script/pub/pub.lua:82]: 1
[15:59:22.030][info] [#0:script/pub/pub.lua:114]: Brave pushed report: # 1 => "mem"
[15:59:22.030][info] [#0:script/pub/pub.lua:115]: 52.1845703125
[15:59:22.030][info] [#0:script/pub/pub.lua:114]: Brave pushed report: # 3 => "mem"
[15:59:22.030][info] [#0:script/pub/pub.lua:115]: 52.1845703125
[15:59:22.030][info] [#0:script/pub/pub.lua:114]: Brave pushed report: # 2 => "mem"
[15:59:22.030][info] [#0:script/pub/pub.lua:115]: 52.1845703125
[15:59:22.030][info] [#0:script/pub/pub.lua:114]: Brave pushed report: # 4 => "mem"
[15:59:22.030][info] [#0:script/pub/pub.lua:115]: 52.1845703125
[15:59:22.030][info] [#0:script/pub/pub.lua:97]: Brave pushed task: # 3 => 2
[15:59:22.030][info] [#0:script/pub/pub.lua:114]: Brave pushed report: # 3 => "mem"
[15:59:22.030][info] [#0:script/pub/pub.lua:115]: 82.0244140625
[15:59:22.030][info] [#0:script/pub/pub.lua:114]: Brave pushed report: # 1 => "proto"
[15:59:22.031][info] [#0:script/pub/pub.lua:115]: {
id = 0,
jsonrpc = "2.0",
method = "initialize",
params = {
capabilities = {
general = {
markdown = {
parser = "marked",
version = "4.0.10"
},
positionEncodings = { "utf-16" },
regularExpressions = {
engine = "ECMAScript",
version = "ES2020"
},
staleRequestSupport = {
cancel = true,
retryOnContentModified = { "textDocument/inlayHint", "textDocument/semanticTokens/full", "textDocument/semanticTokens/range", "textDocument/semanticTokens/full/delta" }
}
},
textDocument = {
callHierarchy = {
dynamicRegistration = true
},
codeAction = {
codeActionLiteralSupport = {
codeActionKind = {
valueSet = { "", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" }
}
},
dataSupport = true,
disabledSupport = true,
dynamicRegistration = true,
honorsChangeAnnotations = false,
isPreferredSupport = true,
resolveSupport = {
properties = { "edit" }
}
},
codeLens = {
dynamicRegistration = true
},
colorProvider = {
dynamicRegistration = true
},
completion = {
completionItem = {
commitCharactersSupport = true,
deprecatedSupport = true,
documentationFormat = { "markdown", "plaintext" },
insertReplaceSupport = true,
insertTextModeSupport = {
valueSet = { 1, 2 }
},
labelDetailsSupport = true,
preselectSupport = true,
resolveSupport = {
properties = { "documentation", "detail", "additionalTextEdits" }
},
snippetSupport = true,
tagSupport = {
valueSet = { 1 }
}
},
completionItemKind = {
valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 }
},
completionList = {
itemDefaults = { "commitCharacters", "editRange", "insertTextFormat", "insertTextMode" }
},
contextSupport = true,
dynamicRegistration = true,
insertTextMode = 2
},
declaration = {
dynamicRegistration = true,
linkSupport = true
},
definition = {
dynamicRegistration = true,
linkSupport = true
},
diagnostic = {
dynamicRegistration = true,
relatedDocumentSupport = true
},
documentHighlight = {
dynamicRegistration = true
},
documentLink = {
dynamicRegistration = true,
tooltipSupport = true
},
documentSymbol = {
dynamicRegistration = true,
hierarchicalDocumentSymbolSupport = true,
labelSupport = true,
symbolKind = {
valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }
},
tagSupport = {
valueSet = { 1 }
}
},
foldingRange = {
dynamicRegistration = true,
foldingRange = {
collapsedText = false
},
foldingRangeKind = {
valueSet = { "comment", "imports", "region" }
},
lineFoldingOnly = true,
rangeLimit = 5000
},
formatting = {
dynamicRegistration = true
},
hover = {
contentFormat = { "markdown", "plaintext" },
dynamicRegistration = true
},
implementation = {
dynamicRegistration = true,
linkSupport = true
},
inlayHint = {
dynamicRegistration = true,
resolveSupport = {
properties = { "tooltip", "textEdits", "label.tooltip", "label.location", "label.command" }
}
},
inlineValue = {
dynamicRegistration = true
},
linkedEditingRange = {
dynamicRegistration = true
},
onTypeFormatting = {
dynamicRegistration = true
},
publishDiagnostics = {
codeDescriptionSupport = true,
dataSupport = true,
relatedInformation = true,
tagSupport = {
valueSet = { 1, 2 }
},
versionSupport = true
},
rangeFormatting = {
dynamicRegistration = true
},
references = {
dynamicRegistration = true
},
rename = {
dynamicRegistration = true,
honorsChangeAnnotations = true,
prepareSupport = true,
prepareSupportDefaultBehavior = 1
},
selectionRange = {
dynamicRegistration = true
},
semanticTokens = {
augmentsSyntaxTokens = true,
dynamicRegistration = true,
formats = { "relative" },
multilineTokenSupport = false,
overlappingTokenSupport = false,
requests = {
full = {
delta = true
},
range = true
},
serverCancelSupport = true,
tokenModifiers = { "declaration", "definition", "readonly", "static", "deprecated", "abstract", "async", "modification", "documentation", "defaultLibrary" },
tokenTypes = { "namespace", "type", "class", "enum", "interface", "struct", "typeParameter", "parameter", "variable", "property", "enumMember", "event", "function", "method", "macro", "keyword", "modifier", "comment", "string", "number", "regexp", "decorator", "operator" }
},
signatureHelp = {
contextSupport = true,
dynamicRegistration = true,
signatureInformation = {
activeParameterSupport = true,
documentationFormat = { "markdown", "plaintext" },
parameterInformation = {
labelOffsetSupport = true
}
}
},
synchronization = {
didSave = true,
dynamicRegistration = true,
willSave = true,
willSaveWaitUntil = true
},
typeDefinition = {
dynamicRegistration = true,
linkSupport = true
},
typeHierarchy = {
dynamicRegistration = true
}
},
window = {
showDocument = {
support = true
},
showMessage = {
messageActionItem = {
additionalPropertiesSupport = true
}
},
workDoneProgress = true
},
workspace = {
applyEdit = true,
codeLens = {
refreshSupport = true
},
configuration = true,
diagnostics = {
refreshSupport = true
},
didChangeConfiguration = {
dynamicRegistration = true
},
didChangeWatchedFiles = {
dynamicRegistration = true,
relativePatternSupport = true
},
executeCommand = {
dynamicRegistration = true
},
fileOperations = {
didCreate = true,
didDelete = true,
didRename = true,
dynamicRegistration = true,
willCreate = true,
willDelete = true,
willRename = true
},
inlayHint = {
refreshSupport = true
},
inlineValue = {
refreshSupport = true
},
semanticTokens = {
refreshSupport = true
},
symbol = {
dynamicRegistration = true,
resolveSupport = {
properties = { "location.range" }
},
symbolKind = {
valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }
},
tagSupport = {
valueSet = { 1 }
}
},
workspaceEdit = {
changeAnnotationSupport = {
groupsOnLabel = false
},
documentChanges = true,
failureHandling = "undo",
normalizesLineEndings = true,
resourceOperations = { "create", "rename", "delete" }
},
workspaceFolders = true
}
},
clientInfo = {
name = "coc.nvim",
version = "0.0.82"
},
initializationOptions = {
changeConfiguration = true
},
locale = "zh_TW",
processId = 91771,
rootPath = "/Users/iver/.config/coc/extensions/coc-lua-data/lua-language-server",
rootUri = "file:///Users/iver/.config/coc/extensions/coc-lua-data/lua-language-server",
trace = "off",
workDoneToken = "3766df03-cd95-471b-95f6-7fe7e70cf5ab",
workspaceFolders = { {
name = "lua-language-server",
uri = "file:///Users/iver/.config/coc/extensions/coc-lua-data/lua-language-server"
} }
}
}
[15:59:22.031][info] [#0:script/client.lua:657]: Client init {
capabilities = {
general = {
markdown = {
parser = "marked",
version = "4.0.10"
},
positionEncodings = { "utf-16" },
regularExpressions = {
engine = "ECMAScript",
version = "ES2020"
},
staleRequestSupport = {
cancel = true,
retryOnContentModified = { "textDocument/inlayHint", "textDocument/semanticTokens/full", "textDocument/semanticTokens/range", "textDocument/semanticTokens/full/delta" }
}
},
textDocument = {
callHierarchy = {
dynamicRegistration = true
},
codeAction = {
codeActionLiteralSupport = {
codeActionKind = {
valueSet = { "", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" }
}
},
dataSupport = true,
disabledSupport = true,
dynamicRegistration = true,
honorsChangeAnnotations = false,
isPreferredSupport = true,
resolveSupport = {
properties = { "edit" }
}
},
codeLens = {
dynamicRegistration = true
},
colorProvider = {
dynamicRegistration = true
},
completion = {
completionItem = {
commitCharactersSupport = true,
deprecatedSupport = true,
documentationFormat = { "markdown", "plaintext" },
insertReplaceSupport = true,
insertTextModeSupport = {
valueSet = { 1, 2 }
},
labelDetailsSupport = true,
preselectSupport = true,
resolveSupport = {
properties = { "documentation", "detail", "additionalTextEdits" }
},
snippetSupport = true,
tagSupport = {
valueSet = { 1 }
}
},
completionItemKind = {
valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 }
},
completionList = {
itemDefaults = { "commitCharacters", "editRange", "insertTextFormat", "insertTextMode" }
},
contextSupport = true,
dynamicRegistration = true,
insertTextMode = 2
},
declaration = {
dynamicRegistration = true,
linkSupport = true
},
definition = {
dynamicRegistration = true,
linkSupport = true
},
diagnostic = {
dynamicRegistration = true,
relatedDocumentSupport = true
},
documentHighlight = {
dynamicRegistration = true
},
documentLink = {
dynamicRegistration = true,
tooltipSupport = true
},
documentSymbol = {
dynamicRegistration = true,
hierarchicalDocumentSymbolSupport = true,
labelSupport = true,
symbolKind = {
valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }
},
tagSupport = {
valueSet = { 1 }
}
},
foldingRange = {
dynamicRegistration = true,
foldingRange = {
collapsedText = false
},
foldingRangeKind = {
valueSet = { "comment", "imports", "region" }
},
lineFoldingOnly = true,
rangeLimit = 5000
},
formatting = {
dynamicRegistration = true
},
hover = {
contentFormat = { "markdown", "plaintext" },
dynamicRegistration = true
},
implementation = {
dynamicRegistration = true,
linkSupport = true
},
inlayHint = {
dynamicRegistration = true,
resolveSupport = {
properties = { "tooltip", "textEdits", "label.tooltip", "label.location", "label.command" }
}
},
inlineValue = {
dynamicRegistration = true
},
linkedEditingRange = {
dynamicRegistration = true
},
onTypeFormatting = {
dynamicRegistration = true
},
publishDiagnostics = {
codeDescriptionSupport = true,
dataSupport = true,
relatedInformation = true,
tagSupport = {
valueSet = { 1, 2 }
},
versionSupport = true
},
rangeFormatting = {
dynamicRegistration = true
},
references = {
dynamicRegistration = true
},
rename = {
dynamicRegistration = true,
honorsChangeAnnotations = true,
prepareSupport = true,
prepareSupportDefaultBehavior = 1
},
selectionRange = {
dynamicRegistration = true
},
semanticTokens = {
augmentsSyntaxTokens = true,
dynamicRegistration = true,
formats = { "relative" },
multilineTokenSupport = false,
overlappingTokenSupport = false,
requests = {
full = {
delta = true
},
range = true
},
serverCancelSupport = true,
tokenModifiers = { "declaration", "definition", "readonly", "static", "deprecated", "abstract", "async", "modification", "documentation", "defaultLibrary" },
tokenTypes = { "namespace", "type", "class", "enum", "interface", "struct", "typeParameter", "parameter", "variable", "property", "enumMember", "event", "function", "method", "macro", "keyword", "modifier", "comment", "string", "number", "regexp", "decorator", "operator" }
},
signatureHelp = {
contextSupport = true,
dynamicRegistration = true,
signatureInformation = {
activeParameterSupport = true,
documentationFormat = { "markdown", "plaintext" },
parameterInformation = {
labelOffsetSupport = true
}
}
},
synchronization = {
didSave = true,
dynamicRegistration = true,
willSave = true,
willSaveWaitUntil = true
},
typeDefinition = {
dynamicRegistration = true,
linkSupport = true
},
typeHierarchy = {
dynamicRegistration = true
}
},
window = {
showDocument = {
support = true
},
showMessage = {
messageActionItem = {
additionalPropertiesSupport = true
}
},
workDoneProgress = true
},
workspace = {
applyEdit = true,
codeLens = {
refreshSupport = true
},
configuration = true,
diagnostics = {
refreshSupport = true
},
didChangeConfiguration = {
dynamicRegistration = true
},
didChangeWatchedFiles = {
dynamicRegistration = true,
relativePatternSupport = true
},
executeCommand = {
dynamicRegistration = true
},
fileOperations = {
didCreate = true,
didDelete = true,
didRename = true,
dynamicRegistration = true,
willCreate = true,
willDelete = true,
willRename = true
},
inlayHint = {
refreshSupport = true
},
inlineValue = {
refreshSupport = true
},
semanticTokens = {
refreshSupport = true
},
symbol = {
dynamicRegistration = true,
resolveSupport = {
properties = { "location.range" }
},
symbolKind = {
valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }
},
tagSupport = {
valueSet = { 1 }
}
},
workspaceEdit = {
changeAnnotationSupport = {
groupsOnLabel = false
},
documentChanges = true,
failureHandling = "undo",
normalizesLineEndings = true,
resourceOperations = { "create", "rename", "delete" }
},
workspaceFolders = true
}
},
clientInfo = {
name = "coc.nvim",
version = "0.0.82"
},
initializationOptions = {
changeConfiguration = true
},
locale = "zh_TW",
processId = 91771,
rootPath = "/Users/iver/.config/coc/extensions/coc-lua-data/lua-language-server",
rootUri = "file:///Users/iver/.config/coc/extensions/coc-lua-data/lua-language-server",
trace = "off",
workDoneToken = "3766df03-cd95-471b-95f6-7fe7e70cf5ab",
workspaceFolders = { {
name = "lua-language-server",
uri = "file:///Users/iver/.config/coc/extensions/coc-lua-data/lua-language-server"
} }
}
[15:59:22.031][info] [#0:script/language.lua:137]: VSC language: zh_TW
[15:59:22.031][info] [#0:script/language.lua:138]: LS language: zh-cn
[15:59:22.031][info] [#0:script/workspace/workspace.lua:38]: Workspace init root: file:///Users/iver/.config/coc/extensions/coc-lua-data/lua-language-server
[15:59:22.031][info] [#0:script/workspace/workspace.lua:42]: Log path: /Users/iver/.config/coc/extensions/coc-lua-data/lua-language-server/log/file_Users_iver_.config_coc_extensions_coc-lua-data_lua-language-server.log
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 language.lua 开始,检查 locale 匹配代码以及 issue 中列出的 supportLanguage 值。使用 locale zh_TW 重现 Neovim 设置,然后验证解析出的语言是 zh-tw 而不是 zh-cn,并确认现有的受支持 locale 仍能正确解析。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- lua
- 领域
- localization
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100