venantius / vim-cljfmt

A Vim plugin for cljfmt, the Clojure formatting tool.
152 stars 22 forks source link

Fails for new project #27

Closed seanhess closed 8 years ago

seanhess commented 8 years ago

Hi, I'm pretty new to Clojure projects. I've carefully followed the installation and configuration instructions, but I'm getting the following error when I run :Cljfmt

Error detected while processing function cljfmt#Format..<SNR>85_RequireCljfmt..fireplace
#session_eval..<SNR>81_eval..363..365..<SNR>81_conn_try..<SNR>140_nrepl_eval..<SNR>140_e
xtract_last_stacktrace:
line   17:
E605: Exception not caught: {'status': ['eval-error', 'done'], 'ex': 'class clojure.lang
.ExceptionInfo', 'root-ex': 'class clojure.lang.ExceptionInfo', 'id': 'fireplace-singula
rity.local-1460566632-39', 'session': ['c3e3ea53-c2e3-4c99-8c33-5f71704baab2'], 'err': '
org.mozilla.javascript.EvaluatorException: Java class "[Ljava.lang.StackTraceElement;" h
as no public instance field or method named "cljs$lang$protocol_mask$partition0$". (rhin
o.clj#41)^@'}
Error detected while processing function cljfmt#Format:
line    2:
E171: Missing :endif
Press ENTER or type command to continue

Note that lein cljfmt check works fine from the command-line, so I have that working. I have fireplace installed, and an nREPL running.

This is a re-natal project, unchanged from the generated sample app.

seanhess commented 8 years ago

I just tested that lein cljfmt fix also works from the command-line

venantius commented 8 years ago

I am pretty certain that this is an nREPL middleware issue with Piggieback.

venantius commented 8 years ago

Wait, sorry, I totally lied. Your problem, I would bet, is that you're using a version of cljfmt that doesn't yet have ClojureScript support. Try upgrading your cljfmt dependency to 0.5.1. I'll update the vim-cljfmt README.

venantius commented 8 years ago

I'm going to mark this as resolved since I'm pretty certain that upgrading your cljfmt dep should fix the problem. I've also updated the plugin to support auto-formatting of .cljc and .cljs files.

seanhess commented 8 years ago

I'm sorry to say that didn't help. My dependency was already 0.5.1. https://gist.github.com/seanhess/64ec179a4e4bcaf0aa277e1ccd2d7666

Anything else I can check on?

venantius commented 8 years ago

Can you show me your project.cj and your ~/.lein/profiles.clj?

seanhess commented 8 years ago

I get the issue using this template: https://github.com/drapanjanas/re-natal/tree/master/resources/cljs-reagent, with the only change being adding [lein-cljfmt "0.5.1"] to my project.clj

The gist contains my project.clj. I don't have a ~/.lein/profiles.clj (sorry if I'm missing something, I'm new to clojure)

.lein $ pwd
/Users/seanhess/.lein
.lein $ ls
repl-history  self-installs

Here's my .vimrc: https://github.com/seanhess/dotfiles/blob/master/.vimrc, if that matters.

Thank you for your help!

venantius commented 8 years ago

So, just so I can reproduce it, you created the project with re-natal init FutureApp -i reagent6 or just re-natal init FutureApp?

seanhess commented 8 years ago

The latter. re-natal init FutureApp

On Mon, Apr 18, 2016 at 11:50 AM Ursa americanus kermodei < notifications@github.com> wrote:

So, just so I can reproduce it, you created the project with re-natal init FutureApp -i reagent6 or just re-natal init FutureApp?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/venantius/vim-cljfmt/issues/27#issuecomment-211499429

venantius commented 8 years ago

I'm going to describe the steps I'm taking. All of this works for me:

re-natal init FutureApp
cd future-app
lein repl

Here is what I have in ~/.lein/profiles.clj when I do this:

{:user {:dependencies [
                       [cljfmt "0.5.1"]

                       ]
        :plugins [
                   ; [venantius/ultra "0.4.1"]
                   ; [lein-pprint "1.1.1"]
                   ; [lein-cljfmt "0.4.1"]

                  ]
        }}

I then use vim to open db.cljs and call :Cljfmt. There's a (long-ish) pause, but then it works. I can verify this by adjusting the alignment of something and calling :Cljfmt again.

Are you able to follow these exact steps and have things not work?

seanhess commented 8 years ago

I followed your steps exactly and got the error.

It must be a vim config thing then? You got the link to my .vimrc, right? I don't think I did anything out of the ordinary. https://github.com/seanhess/dotfiles/blob/master/.vimrc. But I am new to clojure and only set up my clojure vim plugins last week. So maybe I'm missing some required dependency or something? I tried to follow the instructions carefully.

On Tue, Apr 19, 2016 at 3:03 PM Ursa americanus kermodei < notifications@github.com> wrote:

I'm going to describe the steps I'm taking. All of this works for me:

re-natal init FutureApp cd future-app lein repl

Here is what I have in ~/.lein/profiles.clj when I do this:

{:user {:dependencies [ [cljfmt "0.5.1"]

                   ]
    :plugins [
               ; [venantius/ultra "0.4.1"]
               ; [lein-pprint "1.1.1"]
               ; [lein-cljfmt "0.4.1"]

              ]
    }}

I then use vim to open db.cljs and call :Cljfmt. There's a (long-ish) pause, but then it works. I can verify this by adjusting the alignment of something and calling :Cljfmt again.

Are you able to follow these exact steps and have things not work?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/venantius/vim-cljfmt/issues/27#issuecomment-212128967

seanhess commented 8 years ago

Wait! It's working now. I must have done the steps in the wrong order or something.

Thank you! So the main difference between my setup and yours was I put the cljfmt dependency in my project.clj, instead of .profiles.clj. Was that a mistake?

I'll play around some more and make sure this keeps working, but so far so good. Thanks!

On Tue, Apr 19, 2016 at 4:59 PM Sean Clark Hess seanhess@gmail.com wrote:

I followed your steps exactly and got the error.

It must be a vim config thing then? You got the link to my .vimrc, right? I don't think I did anything out of the ordinary. https://github.com/seanhess/dotfiles/blob/master/.vimrc. But I am new to clojure and only set up my clojure vim plugins last week. So maybe I'm missing some required dependency or something? I tried to follow the instructions carefully.

On Tue, Apr 19, 2016 at 3:03 PM Ursa americanus kermodei < notifications@github.com> wrote:

I'm going to describe the steps I'm taking. All of this works for me:

re-natal init FutureApp cd future-app lein repl

Here is what I have in ~/.lein/profiles.clj when I do this:

{:user {:dependencies [ [cljfmt "0.5.1"]

                   ]
    :plugins [
               ; [venantius/ultra "0.4.1"]
               ; [lein-pprint "1.1.1"]
               ; [lein-cljfmt "0.4.1"]

              ]
    }}

I then use vim to open db.cljs and call :Cljfmt. There's a (long-ish) pause, but then it works. I can verify this by adjusting the alignment of something and calling :Cljfmt again.

Are you able to follow these exact steps and have things not work?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/venantius/vim-cljfmt/issues/27#issuecomment-212128967

venantius commented 8 years ago

Could you try again using the project.clj instead of your profiles.clj? There should be no difference. If it doesn't work could you paste the exact project.clj into this issue so I can try it myself?

seanhess commented 8 years ago

Ok, I figured out what I was doing wrong. When I read your installation instructions, adding cljfmt to your dependencies seemed options

:dependencies [[cljfmt "0.5.1"]]

I did see that I needed to install cljfmt as a dependency, and followed the link you sent. Their installation instructions say to do this instead:

:plugins [[lein-cljfmt "0.5.2"]]

That's what causes the error: when you have that lein-cljfmt plugin installed, but not cljfmt as a dependency, cljfmt will work from the command line, but will throw that error in vim.

Sorry for the confusion, and thanks for your help!

On Tue, Apr 19, 2016 at 5:27 PM Ursa americanus kermodei < notifications@github.com> wrote:

Could you try again using the project.clj instead of your profiles.clj? There should be no difference. If it doesn't work could you paste the exact project.clj into this issue so I can try it myself?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/venantius/vim-cljfmt/issues/27#issuecomment-212170160