-
-
Notifications
You must be signed in to change notification settings - Fork 149
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
Parinfer in smart/indent modes messes with refactors #1750
Comments
@vlnn clojure-lsp has nothing related with the paren package you use in the client side, could you elaborate what is "messing with the code"? is that only related to wrong format (spaces)? |
Yes it seems to be related to wrong format (extra spaces) — but it becomes structural problem, you may see how new function on first gif gets |
when lsp-mode apply code actions it doesn't call any format IIRC, but you can confirm disabling rangeFormatting feature via |
Also, you can check the Log - client <-> server to know if clojure-lsp is really returning something wrong which I doubt |
I have |
log-client <-> server
In |
I think the issue here is that Parinfer expects that any new text will be correctly indented and adjusts the parentheses to reflect that. Parinfer relies on the author to verify that the indentation is correct, and I don't know if clojure-lsp can make reasonably certain that a given block of code will be correctly indented when moving it from a nested position to a top-level position. Maybe clojure-lsp can call into |
Both smart and indent modes of parinfer depend on indentation (in the sense they auto-slurp or auto-barf the current sexp depending on how many extra-spaces prepend it). So my proposal is either to format the code correctly from the beginning (but what is correctly? this will add dependency to something external) or provide the option to skip all the extra spaces leaving bare minimum. This could be an option for dumb terminals as well as for terminals that are too clever. |
Maybe clojure-lsp could look at the column of the initial position, and then cut that amount of whitespace from each line, so that the resulting lines are in the same position relative to each other when moved to the new location. |
Initial position of what? I dont think that extract function should depend on initial position of sexp being extracted, as well as initial position of defn sexp seems to be correct (i.e. without prepending spaces) |
yeah, I don't think manually fixing the space in clojure-lsp will be a good idea, we could call format-range using cljfmt but there are some performance issues with that cljfmt feature |
Describe the bug
When parinfer mode is indent or smart, lsp code actions are messing with the code.
To Reproduce
Steps to reproduce the behavior:
Wrong function with changed structure is moved out let when parinfer in indent or smart mode
Expected behavior
I expect the code action is not changing the code structure/behaviour. When parinfer is in parens mode, code actions work as expected:
Log - client <-> server
Log - clojure-lsp
User details (please complete the following information):
The text was updated successfully, but these errors were encountered: