.luarc.json file doesn't apply the nameStyle.config
How are you using the lua-language-server?
Visual Studio Code Extension (sumneko.lua)
Which OS are you using?
Windows
What is the issue affecting?
Diagnostics/Syntax Checking, Formatting
Expected Behaviour
When I start VS code the nameStyle.config should be the one configured in the .luarc.json file.
Actual Behaviour
The nameStyle.config seems to revert internally to the default values. In order for the nameStyle to be applied I have to change the .luarc.json file once more so that VS code re-run some sort of update.
Reproduction steps
- Create a lua file in your workspace with this content:
toNumberOr = function (amount, defaultValue)
-- do something
end
- Create a
.luarc.jsonfile with at list this configuration:
"nameStyle": {
"config": {
"local_name_style": "camel_case",
"function_param_name_style": "camel_case",
"function_name_style": "camel_case",
"local_function_name_style": "camel_case",
"table_field_name_style": "camel_case",
"global_variable_name_style": "pascal_case",
"module_name_style": "pascal_case",
"require_module_name_style": "pascal_case",
"class_name_style": "pascal_case",
"const_variable_name_style": "pascal_case"
}
}
- Start VS code
- Look at the lua file. It will complain about the name style not being correct
- Open and Modify the
.luarc.jsonfile - Re-run the check on the workspace
- Now the issue is gone
Additional Notes
I'm using .editorconfig as well. I'm not sure if they are interfering with each other.
Log File
No response
I am also having this issue; the same reproduction steps apply.
The first load of vscode does not have name style applied, but if the file is edited then it starts working.
This is also present when using --check on the command line.
.\luals\bin\lua-language-server.exe --check . (on version 3.13.0)
--[[ ./main.lua ]]
local TEST_VAR = "foo"
print(TEST_VAR)
{
"$filepath": "./.luarc.json",
"diagnostics.groupFileStatus": {
"codestyle": "Opened"
},
"nameStyle.config": {
"module_local_name_style": "upper_snake_case"
}
}
{
"$filepath": "./luals/log/check.json",
"file:///.../main.lua": [
{
"code": "name-style-check",
"message": "Name 'TEST_VAR' does not match rule 'ModuleLocalVariableName', which require 'snake-case'",
"range": {
"end": {
"character": 14,
"line": 1
},
"start": {
"character": 6,
"line": 1
}
},
"severity": 2,
"source": "Lua Diagnostics."
}
]
}
I'm facing the same issue when using Zed's Lua extension (https://github.com/zed-extensions/lua): after starting Zed, the nameStyle.config settings seems to fall back to the internal default values instead of what I set in .luarc.json, and I have to do some edit to nameStyle.config then save .luarc.json for my configuration to be applied.
same here; nameStyle is accepted though when set in the settings of the lua_ls in the client editor. (However, since I assume every repo will use a different name style, it isn't helpful to set it there, luarc is kinda needed for this one.)