liquidz / vim-iced

Clojure Interactive Development Environment for Vim8/Neovim
https://liquidz.github.io/vim-iced/
MIT License
518 stars 35 forks source link

Inconsistent behaviour: :IcedFormat vs. :IcedFormatAll #418

Closed sheluchin closed 2 years ago

sheluchin commented 2 years ago

Using Tonsky's formatting rule with Parinfer disabled:

:ParinferOff
:let g:iced#format#rule = {'#"^\w"': '[[:inner 0]]'}
(ns foo)

(-> {:x 1}
  |:x
  prn)

:IcedFormat:

(ns foo)

(-> {:x 1}
    :x
    prn)

:IcedFormatAll

(ns foo)

(-> {:x 1}
  :x
  prn)

And I notice that if comment out the ns form at the top, the behaviour becomes consistent: :IcedFormatAll

; (ns foo)

(-> {:x 1}
    :x
    prn)
liquidz commented 2 years ago

@sheluchin Thanks for your reporting!

Interesting. I could reproduce.

liquidz commented 2 years ago

@sheluchin It seems a cljfmt side bug.

$ cat foo.clj
(ns foo)

(-> {:x 1}
  :x
  prn)

$ cat indentation.clj
{#"^\w" [[:inner 0]]}

$ clojure -Sdeps '{:deps {cljfmt/cljfmt {:mvn/version "0.8.0"}}}' -M -m cljfmt.main check foo.clj
foo.clj has incorrect formatting
--- a/private/tmp/bar/foo.clj
+++ b/private/tmp/bar/foo.clj
@@ -1,5 +1,5 @@
 (ns foo)

 (-> {:x 1}
-  :x
-  prn)
+    :x
+    prn)
1 file(s) formatted incorrectly

$ clojure -Sdeps '{:deps {cljfmt/cljfmt {:mvn/version "0.8.0"}}}' -M -m cljfmt.main check --indents indentation.clj foo.clj
All source files formatted correctly

$ cat bar.clj
;(ns foo)

(-> {:x 1}
  :x
  prn)

$ clojure -Sdeps '{:deps {cljfmt/cljfmt {:mvn/version "0.8.0"}}}' -M -m cljfmt.main check --indents indentation.clj bar.clj
bar.clj has incorrect formatting
--- a/private/tmp/bar/bar.clj
+++ b/private/tmp/bar/bar.clj
@@ -1,5 +1,5 @@
 ;(ns foo)

 (-> {:x 1}
-  :x
-  prn)
+    :x
+    prn)
1 file(s) formatted incorrectly
sheluchin commented 2 years ago

@liquidz I opened that :point_up: issue in the cljfmt issue tracker. I hope I summarized it well enough to capture the point. I'll close this vim-iced issue as it's not really a vim-iced concern, as far as I understand. Thank you for investigating!