lua-language-server
lua-language-server copied to clipboard
[FEATURE REQUEST] Invoke code formatting from CLI
I have a project with 3K+ Lua files I need to format. The problem is if I use something like this it takes forever. I disabled diagnostics like this:
"Lua.diagnostics.enable": false,
"Lua.diagnostics.workspaceDelay": 10000,
"Lua.diagnostics.workspaceRate": 1,
"Lua.diagnostics.disableScheme": ["git", "."]
Yet for some reason lua-language-server triggers diagnostics all the time and it slows down the process.

So, it would be great to trigger code formatting from CLI without doing any diagnostics.
I tried this tool but it has different styling by default so it was not really helpful, but it's blazing fast.
3K+ files don't need such a high occupation. There should be a bug. Can you provide a log?
Where's it located?
see https://github.com/sumneko/lua-language-server/wiki/Default-log-path
Please set Lua.semantic.enable to false , check whether the occupancy returns to normal?
Is this project open source? If I can debug directly, I can solve the problem faster.
EDIT I can see a lot of strange behavior from your log.
- Clients requests
semanticTokensfor many files after server startup, but it should only request for opened files. - Clients send some requests for
*.eventsand*.ship, are these files really lua, or are these files very large?
Please add --loglevel=trace in command line and provide the new log (If you are using VSCode, add it in Lua.misc.parameters)
code format has standlone cli tool
Please set
Lua.semantic.enabletofalse, check whether the occupancy returns to normal?
Yes this helped, things go lot faster now.
Is this project open source? If I can debug directly, I can solve the problem faster.
EDIT I can see a lot of strange behavior from your log.
Please add
--loglevel=tracein command line and provide the new log (If you are using VSCode, add it inLua.misc.parameters)
I'll create a repo for this so you can see all the stuff yourself.
1. Clients requests `semanticTokens` for many files after server startup, but it should only request for opened files.
I've set it to diagnose entire workspace, because I needed to see all available errors in workspace without opening each and every file.
2. Clients send some requests for `*.events` and `*.ship`, are these files really lua, or are these files very large?
Yes they're, they simply have this weird extension :D
code format has standlone cli tool
Yes, I've used it, but as I said it has some different default styling. So when I open file formatted with it and save in VSCode formatting may change. I spent some time trying to match formatting for both tools but failed miserably.
this repo's formatting algorithm is come from EmmyluaCodeStyle. you can get cli tool from release
this repo's formatting algorithm is come from EmmyluaCodeStyle. you can get cli tool from release
Oh, wait, this is different format tool, sweet will try it too, thanks!
this repo's formatting algorithm is come from EmmyluaCodeStyle. you can get cli tool from release
Works like a charm, thank you!
Is this project open source? If I can debug directly, I can solve the problem faster.
https://github.com/Real-Gecko/hw2-complex
This is the code, beware that's huge:
It contains a lot of legacy stuff that needs to be removed.
.vscode/settings.json for the project contains everything needed for project to work except one thing: library files.
globals.zip
Unpack this globals.zip anywhere on your drive and adjust Lua.workspace.library accordingly.
Thanks for your project, I have found a performance issue!
You can install this version to check if the performance issue resolved: https://github.com/sumneko/lua-language-server/actions/runs/2569280528
Yes, f9b3b65 is much better. Not only file formatting happens faster even with "Lua.semantic.enable": true, it also was able to detect some issues with the current code which 3.3.1 was unable to detect for some reason. https://github.com/CppCXY/EmmyLuaCodeStyle also works like a charm from CLI. If you make code formatting from CLI available with lua-language-server binary it's up to you.