Skip to content
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

max-line-length not respected when sorting large refer forms #1729

Closed
lassemaatta opened this issue Nov 29, 2023 · 0 comments · Fixed by #1730
Closed

max-line-length not respected when sorting large refer forms #1729

lassemaatta opened this issue Nov 29, 2023 · 0 comments · Fixed by #1730
Labels
bug Something isn't working editor Related to clojure-lsp on a text editor
Projects

Comments

@lassemaatta
Copy link
Contributor

Describe the bug

I can specify the maximum line length for sorting :refer [...] forms in the config (:max-line-length). However, if there are a lot of referred symbols, it seems like this limit only applies to the first few lines of code.

To Reproduce

Sample file:

(ns mock
  (:require [clojure.core :refer [abs accessor aclone add-classpath add-tap add-watch agent agent-error aget alength alias all-ns alter alter-meta! alter-var-root amap ancestors and any? apply areduce array-map as-> aset aset-boolean aset-byte aset-long aset-short assert assoc assoc! assoc-in associative? atom await await-for await1 bases bean bigdec bigint biginteger]]))

(def my-functions
  "refer to vars so that cleanup won't remove them"
  [abs accessor aclone add-classpath add-tap
   add-watch agent agent-error aget alength alias
   all-ns alter alter-meta! alter-var-root amap ancestors and any? apply areduce
   array-map as-> aset aset-boolean aset-byte aset-long aset-short assert assoc
   assoc! assoc-in associative? atom await await-for await1 bases bean bigdec bigint biginteger])

With :max-line-length 50 I get the following (| represents the limit), where the first two lines respect the line limit.

(ns mock
  (:require [clojure.core :refer [abs accessor    |
                                  aclone          |
                                  add-classpath add-tap add-watch agent agent-error aget
                                  alength alias all-ns alter alter-meta! alter-var-root
                                  amap ancestors and any? apply areduce array-map
                                  as-> aset aset-boolean aset-byte aset-long
                                  aset-short assert assoc assoc! assoc-in associative? atom
                                  await await-for await1 bases bean bigdec bigint
                                  biginteger]]))  |

With :max-line-length 80 we get similar results, only the first two rows respect the limit:

(ns mock
  (:require [clojure.core :refer [abs accessor aclone add-classpath add-tap     |
                                  add-watch agent agent-error aget alength alias| 
                                  all-ns alter alter-meta! alter-var-root amap ancestors and any? apply areduce
                                  array-map as-> aset aset-boolean aset-byte aset-long aset-short assert assoc
                                  assoc! assoc-in associative? atom await await-for await1 bases bean bigdec bigint
                                  biginteger]]))                                |

And finally with 120 limit:

(ns mock
  (:require [clojure.core :refer [abs accessor aclone add-classpath add-tap add-watch agent agent-error aget alength    |
                                  alias all-ns alter alter-meta! alter-var-root amap ancestors and any? apply areduce   |
                                  array-map as-> aset aset-boolean aset-byte aset-long aset-short assert assoc assoc! assoc-in associative? atom await
                                  await-for await1 bases bean bigdec bigint biginteger]]))                              |

Expected behavior

The :max-line-length limit should be applied to all lines.

User details (please complete the following information):

  • OS: MacOs
  • Editor: Emacs
  • Version: clojure-lsp 2023.10.30-21.15.51-nightly clj-kondo 2023.10.21-SNAPSHOT
@lassemaatta lassemaatta added bug Something isn't working editor Related to clojure-lsp on a text editor labels Nov 29, 2023
lassemaatta added a commit to lassemaatta/clojure-lsp that referenced this issue Dec 2, 2023
@ericdallo ericdallo added this to Low priority in clojure-lsp via automation Dec 3, 2023
clojure-lsp automation moved this from Low priority to Next release Dec 3, 2023
ericdallo pushed a commit that referenced this issue Dec 3, 2023
…1730)

* Add test case for long :refer expressions (#1729)

* Respect :max-line-length wrt. :refer when there are a lot of symbols (#1729)
@ericdallo ericdallo moved this from Next release to Done in clojure-lsp Jan 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working editor Related to clojure-lsp on a text editor
Projects
Development

Successfully merging a pull request may close this issue.

1 participant