venantius / vim-cljfmt

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

Can't format cljs, clj works. Works when run manually, not when run from vim. #42

Closed Jakedavies closed 6 years ago

Jakedavies commented 6 years ago

I am getting up and running with a new backend/frontend clojure project based on https://github.com/Day8/re-frame-template

The repl is being started with lein repl. I am having issues with my .cljs files not formatting, despite my .clj files working fine. I am able to format the .cljs files by manually running lein cljfmt too. When I run :cljfmt in vim from a .cljs file, there is a long pause and then I get the following error:

Error detected while processing function cljfmt#Format[1]..<SNR>54_RequireCljfmt[3]..fireplace#session_eval:

And here is my project.clj

(defproject beer "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.8.0"]
                 [org.clojure/clojurescript "1.10.238"]
                 [ragtime "0.7.2"]
                 [reagent "0.7.0"]
                 [org.clojure/java.jdbc  "0.7.7"]
                 [re-frame "0.10.5"]
                 [compojure "1.5.0"]
                 [cljfmt "0.6.0"]
                 [yogthos/config "0.8"]
                 [clj-postgresql "0.7.0"]
                 [org.postgresql/postgresql "9.4-1201-jdbc41"]
                 [day8.re-frame/http-fx "0.1.6"]
                 [ring "1.4.0"]]

  :plugins [[lein-cljfmt "0.6.0"]
            [lein-cljsbuild "1.1.7"]]

  :aliases {"migrate"  ["run" "-m" "beer.db/migrate"]
          "rollback" ["run" "-m" "beer.db/rollback"]}

  :min-lein-version "2.5.3"

  :source-paths ["src/clj" "src/cljs"]

  :clean-targets ^{:protect false} ["resources/public/js/compiled" "target"
                                    "test/js"]

  :figwheel {:css-dirs ["resources/public/css"]
             :ring-handler beer.handler/dev-handler}

  :repl-options {:nrepl-middleware [cider.piggieback/wrap-cljs-repl]}

  :profiles
  {:dev
   {:dependencies [[binaryage/devtools "0.9.10"]
                   [figwheel-sidecar "0.5.16"]
                   [cider/piggieback "0.3.5"]]

    :plugins      [[lein-figwheel "0.5.16"]
                   [lein-doo "0.1.8"]]}
   :prod { }}

  :cljsbuild
  {:builds
   [{:id           "dev"
     :source-paths ["src/cljs"]
     :figwheel     {:on-jsload "beer.core/mount-root"}
     :compiler     {:main                 beer.core
                    :output-to            "resources/public/js/compiled/app.js"
                    :output-dir           "resources/public/js/compiled/out"
                    :asset-path           "js/compiled/out"
                    :source-map-timestamp true
                    :preloads             [devtools.preload]
                    :external-config      {:devtools/config {:features-to-install :all}}
                    }}

    {:id           "min"
     :source-paths ["src/cljs"]
     :jar true
     :compiler     {:main            beer.core
                    :output-to       "resources/public/js/compiled/app.js"
                    :optimizations   :advanced
                    :closure-defines {goog.DEBUG false}
                    :pretty-print    false}}

    {:id           "test"
     :source-paths ["src/cljs" "test/cljs"]
     :compiler     {:main          beer.runner
                    :output-to     "resources/public/js/compiled/test.js"
                    :output-dir    "resources/public/js/compiled/test/out"
                    :optimizations :none}}
    ]}

  :main beer.server

  :aot [beer.server]

  :uberjar-name "beer.jar"

  :prep-tasks [["cljsbuild" "once" "min"] "compile"]
  )
venantius commented 6 years ago

Do you have an active fireplace REPL at the time you call :cljfmt?

Jakedavies commented 6 years ago

I looked a bit deeper, I think you are right this seems to be an issue that goes a bit deeper than I thought. I am going to do some further investigation, I don't think this is an issue with vim-cljfmt :+1: