Proposal: Idiomatic Code Refactoring using Pipeline Symbol in LSP #2573
katsmil
started this conversation in
Ideas & suggestions
Replies: 1 comment 1 reply
-
That's an interesting refactor! I'd go for the code action approach for sure, sometimes people might want to give names to intermediate steps and seeing the squiggly line would be distracting |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have been working on a potential improvement for the Gleam project, focusing on extending the Language Server Protocol (LSP) implementation to provide additional refactoring hints. Specifically, this extension introduces idiomatic code refactoring using the pipeline symbol (|>), aimed at helping users write more idiomatic code.
Visual Representation
To make the proposed language refactor more concrete, I've created a GIF showcasing how the suggested refactor can be executed by the editor. In this example, the CodeAction interface of the Language Server Protocol is utilized. That means only the lightbulb indicates a hint, there are no squiggly lines.
In this demo, all parts are converted into a single piped expression. However, it might be important for users to choose which refactor to execute. This could include:
Diagnostic vs. Code Action:
Now, if we agree on integrating this addition into the LSP for Gleam, how should we present the suggestion? There are two potential approaches:
I would love to hear your thoughts and preferences on this matter.
Beta Was this translation helpful? Give feedback.
All reactions