LuaLS / LuaLS/lua-language-server
Wrong language when initialize server
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 4.4k
- Forks
- 442
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in language.lua and inspect the locale matching code and the supportLanguage values listed in the issue. Reproduce the Neovim setup with locale zh_TW, then verify that the resolved language is zh-tw rather than zh-cn and that the existing supported locales still resolve correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- localization
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100