liquidz / vim-iced

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

IcedAddNs errors #396

Closed noahmoss closed 2 years ago

noahmoss commented 2 years ago

Hi @liquidz!

When I run IcedAddNs I get the following errors:

Fetching existing ns aliases...
Error detected while processing function <lambda>363[1]..23[8]..<SNR>112_dispatcher[86]..<lambda>627[1]..<SNR>212___all_ns_aliases[7]..<SNR>212_parse_aliases_value:
line    5:
E688: More targets than List items
Error detected while processing function <lambda>363[1]..23[8]..<SNR>112_dispatcher[86]..<lambda>627[1]..<lambda>626[1]..<SNR>166___find_existing_alias:
line    1:
E896: Argument of get() must be a List, Dictionary or Blob

It then prompts me to enter an alias for the namespace but the default value is -1. If I enter an alias and continue hitting enter, it eventually adds the namespace to the file, but with no indentation, so it's not actually in the require form.

liquidz commented 2 years ago

@noahmoss Thanks for your reporting! Hmm, it may be the cause that nREPL returned unexpected values.

Cound you execute the following command to enable debug mode, and reproduce the same errors?

:let g:iced#debug = v:true

With debug mode, requests and responses are outputted to :message, so please tell me the result of :message result if you can.

noahmoss commented 2 years ago

@liquidz Just did that, the results are here: https://gist.github.com/noahmoss/7ecbcf8a427ec11150085d23fd4b062a

Maybe this has something to do with ns-list returning a large number of namespaces? I'm running into this while working in the Metabase codebase which is a very large project.

liquidz commented 2 years ago

@noahmoss Thanks! I'll try to find the cause.

liquidz commented 2 years ago

@noahmoss The response form from refactor-nrepl seems to be unexpected. I've fix the problem in dev branch, so could you try?

noahmoss commented 2 years ago

@liquidz That fixed it, thank you!

I have another somewhat related issue, though I'm not sure if you would consider it a bug or not. When I run IcedCleanNs it totally reformats the ns form.

For example if I start with this:

(ns metabase.setup
  (:require [environ.core :as env]
            [metabase.models.setting :as setting :refer [defsetting Setting]]
            [metabase.models.user :refer [User]]
            [toucan.db :as db])
  (:import java.util.UUID))

After running IcedCleanNs it changes it to this:

(ns metabase.setup
  (:require
   [environ.core :as env]
   [metabase.models.setting :as setting :refer [defsetting Setting]]
   [metabase.models.user :refer [User]]
   [toucan.db :as db])
  (:import
   (java.util UUID)))

I don't think it did this in the past, so maybe there was a recent change that affected this? My expectation is that "cleaning" the namespace would mean sorting them and removing unused namespaces, but not touching the formatting.

liquidz commented 2 years ago

@noahmoss Thanks for your confirmation!

I have another somewhat related issue, though I'm not sure if you would consider it a bug or not. When I run IcedCleanNs it totally reformats the ns form. I don't think it did this in the past, so maybe there was a recent change that affected this?

refactor-nrepl seems to return reformatted ns form since v3.0.0

and vim-iced start to use refactor-nrepl v3.1.0 since v3.7.3

So it should be able to configure :insert-newline-after-require from vim-iced options.

liquidz commented 2 years ago

@noahmoss I added g:iced#refactor#insert_newline_after_require option for trial.

Could you try the following setting in the latest dev branch?

let g:iced#refactor#insert_newline_after_require = v:false
noahmoss commented 2 years ago

@liquidz Nice, that solved it, thanks! 👍

liquidz commented 2 years ago

@noahmoss Just released v3.8.5 #400