Fork me on GitHub
#vim
<
2020-10-30
>
nezaj05:10:54

(posted this in #clojurescript but figured would be appropriate here as well)

dominicm08:10:10

Sounds like your problem is perhaps that guestbook isn't on the classpath?

nezaj18:10:57

@U09LZR36F I was wondering about this but from the configuration it looks right to me... I'm using lein , here's my project.clj

(defproject guestbook "0.1.0-SNAPSHOT"

  :description "FIXME: write description"
  :url ""

  :dependencies [[ch.qos.logback/logback-classic "1.2.3"]
                 [cljs-ajax "0.8.0"]
                 [reagent "0.10.0"]
                 [cheshire "5.9.0"]
                 [clojure.java-time "0.3.2"]
                 [com.h2database/h2 "1.4.200"]
                 [conman "0.8.4"]
                 [cprop "0.1.15"]
                 [expound "0.8.3"]
                 [funcool/struct "1.4.0"]
                 [luminus-http-kit "0.1.6"]
                 [luminus-migrations "0.6.6"]
                 [luminus-transit "0.1.2"]
                 [luminus/ring-ttl-session "0.3.3"]
                 [markdown-clj "1.10.1"]
                 [metosin/muuntaja "0.6.6"]
                 [metosin/reitit "0.3.10"]
                 [metosin/ring-http-response "0.9.1"]
                 [mount "0.1.16"]
                 [nrepl "0.6.0"]
                 [org.clojure/tools.cli "0.4.2"]
                 [org.clojure/tools.logging "0.5.0"]
                 [org.clojure/clojure "1.10.1"]
                 [org.clojure/clojurescript "1.10.520" :scope "provided"]
                 [org.webjars.npm/bulma "0.8.0"]
                 [org.webjars.npm/material-icons "0.3.1"]
                 [org.webjars/webjars-locator "0.38"]
                 [ring-webjars "0.2.0"]
                 [ring/ring-core "1.8.0"]
                 [ring/ring-defaults "0.3.2"]
                 [selmer "1.12.18"]
                 [cider/piggieback "0.5.1"]]

  :min-lein-version "2.0.0"

  :source-paths ["src/clj" "src/cljc"]
  :test-paths ["test/clj"]
  :resource-paths ["resources", "target/cljsbuild"]
  :target-path "target/%s/"
  :main ^:skip-aot guestbook.core

  :plugins [[lein-cljfmt "0.7.0"] [lein-cljsbuild "1.1.7"]]
  :repl-options {:nrepl-middleware [cider.piggieback/wrap-cljs-repl]}

  :cljsbuild
  {:builds
   {:app {:source-paths ["src/cljs" "src/cljc"]
          :compiler {:output-to "target/cljsbuild/public/js/app.js"
                     :output-dir "target/cljsbuild/public/js/out"
                     :main "guestbook.core"
                     :asset-path "/js/out"
                     :optimizations :none
                     :source-map true
                     :pretty-print true}}}}

  :clean-targets
  ^{:protect false}
  [:target-path
   [:cljsbuild :builds :app :compiler :output-dir]
   [:cljsbuild :builds :app :compiler :output-to]]

  :profiles
  {:uberjar {:omit-source true
             :aot :all
             :uberjar-name "guestbook.jar"
             :source-paths ["env/prod/clj"]
             :resource-paths ["env/prod/resources"]}

   :dev           [:project/dev :profiles/dev]
   :test          [:project/dev :project/test :profiles/test]

   :project/dev  {:jvm-opts ["-Dconf=dev-config.edn"]
                  :dependencies [[pjstadig/humane-test-output "0.10.0"]
                                 [prone "2019-07-08"]
                                 [ring/ring-devel "1.8.0"]
                                 [ring/ring-mock "0.4.0"]
                                 [weasel "0.7.1"]]
                  :plugins      [[com.jakemccrary/lein-test-refresh "0.24.1"]
                                 [jonase/eastwood "0.3.5"]]

                  :source-paths ["env/dev/clj"]
                  :resource-paths ["env/dev/resources"]
                  :repl-options {:init-ns user}
                  :injections [(require 'pjstadig.humane-test-output)
                               (pjstadig.humane-test-output/activate!)]}
   :project/test {:jvm-opts ["-Dconf=test-config.edn"]
                  :resource-paths ["env/test/resources"]}
   :profiles/dev {}
   :profiles/test {}})

dominicm18:10:34

Doesn't look like src/cljs is on the classpath?

dominicm18:10:44

Add it to source-paths

nezaj19:10:37

@U09LZR36F some progress! Now after running :Piggieback (cider.piggieback/cljs-repl (cljs.repl.node/repl-env)) executing a form gives me the following message/error

Execution error (NullPointerException) at cljs.repl.node/node-eval (node.clj:66).
null
Press ENTER or type command to continue

dominicm20:10:07

You only need the call to repl-env

dominicm20:10:33

Figwheel handles the nodejs bit itself

nezaj20:10:00

Tried running :Piggieback (cljs.repl.node/repl-env) but still same error on form executiion 😞

Execution error (NullPointerException) at cljs.repl.node/node-eval (node.clj:66).
null
Press ENTER or type command to continue
FWIW my project isn't figwheel atm

dominicm20:10:33

I'd restart if you haven't, just in case

dominicm20:10:29

Your project doesn't seem to be node, so I don't think that's the right thing to use?

dominicm20:10:55

You don't have target node, for example.

nezaj21:10:30

Makes sense, and if I add :target :nodejs to cljsbuild my js won't load on navigating to index page after lein cljsbuild auto because using nodejs to compile will introduce require statements which the browser doesnt understand

nezaj21:10:45

it seems like if no target is specified default target is the browser, so not node as you mention

nezaj21:10:24

Sounds like the thing I may want is to get piggieback to connect to the browser repl (although I don't know how)

dominicm22:10:24

In that case you need to call the figwheel function

dominicm22:10:55

Or you could try weasel again :)

nezaj22:10:25

Heh for sure, I'll dig deeper and report back on progress -- really appreciate the help 🙂

zyxmn12:10:50

hey folks , how do you usually sort deps in a namespace. Looking for something like clojure sort ns in emacs clojure mode.

dave12:10:45

the naiive method works pretty well. go into visual mode, highlight all of the require lines, and run :sort

dave12:10:01

i do that quite a bit

zyxmn12:10:13

sweet , ill try that . thanks!

kelveden12:10:42

Not vim-specific but we've had success using https://github.com/immoh/lein-nsorg for this purpose. (There's also a separate lib behind it that could be used: https://github.com/immoh/nsorg/)

👌 3
dominicm13:10:41

Replant has a command for that

dharrigan13:10:05

I use :sort but also, since I use CoC, there is a clojure-lsp binding to sort namespaces too

dharrigan13:10:25

nnoremap <silent> crcn :call CocRequest('clojure-lsp', 'workspace/executeCommand', {'command': 'clean-ns', 'arguments': [Expand('%:p'), line('.') - 1, col('.') - 1]})<CR>

dharrigan13:10:36

it'll also remove any namespaces that are not in use.

🔥 9
zyxmn13:10:16

will check em out , thanks fellas .

practicalli-johnny14:10:37

Alternatively, avoid arranging deps as one big sorted collection, instead group them by what they are used for. This I find much easier in the long run.

dave14:10:43

^i agree, assuming you're talking about deps in a deps.edn / project.clj / build.boot

👍 3
walterl21:10:38

I really like Python's import grouping (from PEP8): > Imports should be grouped in the following order: > > 1. Standard library imports. > 2. Related third party imports. > 3. Local application/library specific imports. > > You should put a blank line between each group of imports.

💯 3
Jivago Alves09:10:33

TIL I follow the python convention.

dave21:10:04

I think gofmt does a similar thing in the Go world

noisesmith21:10:20

@clojurians-slack100 due to namespace conventions, alphabetical ordering automatically achieves 1,3

walterl22:10:26

Which conventions are you referring to? I've seen that clean-ns puts clojure.* first, but that's it.

noisesmith23:10:49

I mean that all "standard library" will start with clojure. and be together alphabetically

noisesmith23:10:19

and anything from your own project / library should similarly all start with the same prefix

walterl23:10:44

Ah. I understand. The usefulness in the above quote that I perhaps didn't highlight sufficiently, is the grouping of the contexts, at a glance: you know all your project-local ns's are in the last "block", so your eye can really quickly and easily jump to the last block and look for the line you need.