-
-
Notifications
You must be signed in to change notification settings - Fork 390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use code formatter tool directly #1009
Labels
conclusion: resolved
Issue was resolved
criticality: medium
Of moderate impact
topic: code
Related to content of the project itself
topic: language server
Related to the Arduino Language Server
type: enhancement
Proposed improvement
Comments
per1234
added
criticality: medium
Of moderate impact
topic: code
Related to content of the project itself
type: enhancement
Proposed improvement
labels
May 27, 2022
The ClangFormat configuration is here in the https://github.com/arduino/arduino-language-server/blob/main/ls/ls_formatter.go |
kittaakos
pushed a commit
to kittaakos/arduino-ide
that referenced
this issue
Jun 2, 2022
Closes arduino#1009 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
kittaakos
pushed a commit
to kittaakos/arduino-ide
that referenced
this issue
Jun 2, 2022
- Bumped `clangd` to `14.0.0`, - Can use `.clang-format` from: - current sketch folder, - `~/.arduinoIDE/.clang-format`, - `directories#data/.clang-format`, or - falls back to default formatter styles. Closes arduino#1009 Closes arduino#566 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
4 tasks
PR: #1019. Please review. Thank you! |
LGTM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
conclusion: resolved
Issue was resolved
criticality: medium
Of moderate impact
topic: code
Related to content of the project itself
topic: language server
Related to the Arduino Language Server
type: enhancement
Proposed improvement
Describe the request
Use the code formatting tool directly for the IDE's "Auto Format" capability.
🙂 This will ensure the fastest possible response when the user triggers a code formatting operation.
Describe the current behavior
The Arduino IDE provides a sketch code formatter (e.g., Tools > Auto Format).
Formatting is currently done via the "Arduino Language Server", which also provides the code aware features such as autocompletion, problem detection, "Go to definition". This approach is convenient because a high quality code formatting capability is already available is the "clangd" C++ language server used by Arduino Language Server.
The language server features require the complete program to be known, which includes far more than the code in the sketch itself (i.e., toolchain, core, libraries). The amount of processing involved is significant, which means that there will always be some latency in the language server results.
Code formatting is different in that it only requires passing the text of the current sketch editor tab through the formatter tool, with no program processing needed.
🙁 The auto format process is unnecessarily subject to program processing latency, which causes significant delays between the user triggering an "Auto Format" operation and getting the result.
Arduino IDE version
2.0.0-rc6-snapshot-522a5c6
Operating system
Windows, Linux, macOS
Operating system version
Any
Additional context
Build infrastructure for the standalone ClangFormat code formatter tool is already in place at https://github.com/arduino/clang-static-binaries
Please let's start with a PoC and see how tricky this is
Unfortunately the main limitation is that clang-format will not accept stdin as input but requires a file, so when formatting a Tab's content we'll need to use a temp file and run it as follows
This proposal is equivalent to the approach taken by Arduino IDE 1.x
Related:
Issue checklist
The text was updated successfully, but these errors were encountered: