liquidz / vim-iced

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

:IcedCleanNs doesn't add a newline after :require #453

Closed noahmoss closed 1 year ago

noahmoss commented 1 year ago

Hey @liquidz! I've noticed that :IcedCleanNs won't add a newline after the :require form if the namespace is otherwise correct. However, it will if there's anything that needs to be cleaned. Is this the intended behavior? If so is there any other command that can be used to add the newline to the ns form?

For example, in this namespace:

(ns test
  (:require [clojure.string :as str]))

(str/replace "foo" "o" "a")

running :IcedCleanNs will not make any changes. However, in this ns:

(ns test
  (:require [clojure.string :as str]
            [clojure.java.io :as io]))

(str/replace "foo" "o" "a")

running :IcedCleanNs will result in

(ns test
  (:require
   [clojure.string :as str]))

(str/replace "foo" "o" "a")
liquidz commented 1 year ago

@noahmoss Thanks for your reporting!

The behavior inserting new line after :require is due to the following option. (This option is a refactor-nrepl's option) https://liquidz.github.io/vim-iced/vim-iced.html#g%3Aiced%23refactor%23insert_newline_after_require

And when refactor-nrepl responses that there are no changes, vim-iced does not update ns form, so the newline is not added.

If so is there any other command that can be used to add the newline to the ns form?

No commands for now, but the behavior is not unified, so I'll find some solution.

noahmoss commented 1 year ago

@liquidz That makes sense. In my case I am trying to update a large number of existing namespaces to use the formatting with the newline, so having the behavior be consistent would be great if possible. Thanks for taking a look!

liquidz commented 1 year ago

@noahmoss I tried to fix the behavior. Could you try next_release branch?

noahmoss commented 1 year ago

Seems to work, thanks!

liquidz commented 1 year ago

Thanks for your confirmation! Just released v3.14.3196