-
-
Notifications
You must be signed in to change notification settings - Fork 384
Description
Version 2.6.6 integrates formatter.
The formatter is still in development and looking forward to your feedback!
How to enable
The formatter can be enabled by adding the parameter --preview
to the command line parameters.
For VSCode, add this parameter in the Lua.misc.parameters
setting.
how to use
The formatter provides two functions: "format document" and "format selected range".
For VSCode users, you can find thease features in the right-click menu.
In addition, VSCode can also enable Format On Paste
and Format On Save
in the settings.
Note that the Format On Type
feature is currently provided by this language server, not by the formatter.
The formatter also provides the Code style check
feature, but it is disabled by default. To enable it, please set:
"Lua.diagnostics.neededFileStatus": {
"codestyle-check": "Any"
}
How to configure
Please read the wiki https://github.com/sumneko/lua-language-server/wiki/Code-Reformat
How to give feedback
If you have any suggestions or bug reports about the formatter, please open issues in https://github.com/CppCXY/EmmyLuaCodeStyle/issues
Other
In fact, I didn't plan to add the formatting feature before.
- I've always formatted manually because I feel like I can get some rest and force myself to review the code. So I have no motivation to develop formatter.
- I think the formatter is very different from the other features of the language server, the language server is dedicated to intellisense, and all features are based on understanding the semantics of your code. But code formatting only needs to check the current file, or even a code snippet. The extensive settings required for formatting is also very different from the language server itself.
- There are already many independent formatters on the market, and users can choose freely.
- This language server supports
Lua5.1
toLua5.4
(andLuaJIT
) and can run on multiple platforms. These issues also need to be addressed if integrating third-party formatters, especially cross-platform compilation issues.
Fortunately, this PR took the initiative to help me solve 1
and 4
, so I decided to integrate it in the new version.
I've raised dozens of issues after trying out this formatting tool, so if you have any suggestions or report, please feel free to feedback.