(posted this in #clojurescript but figured would be appropriate here as well)
Sounds like your problem is perhaps that guestbook isn't on the classpath?
@dominicm 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 "<http://example.com/FIXME>"
: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 {}})
Doesn't look like src/cljs is on the classpath?
Add it to source-paths
@dominicm 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
You only need the call to repl-env
Figwheel handles the nodejs bit itself
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 atmI'd restart if you haven't, just in case
Your project doesn't seem to be node, so I don't think that's the right thing to use?
You don't have target node, for example.
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
it seems like if no target is specified default target is the browser, so not node as you mention
Sounds like the thing I may want is to get piggieback to connect to the browser repl (although I don't know how)
Ah, ok
In that case you need to call the figwheel function
Or you could try weasel again :)
Heh for sure, I'll dig deeper and report back on progress -- really appreciate the help 🙂
hey folks , how do you usually sort deps in a namespace. Looking for something like clojure sort ns in emacs clojure mode.
the naiive method works pretty well. go into visual mode, highlight all of the require lines, and run :sort
i do that quite a bit
sweet , ill try that . thanks!
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/)
Replant has a command for that
I use :sort
but also, since I use CoC, there is a clojure-lsp
binding to sort namespaces too
nnoremap <silent> crcn :call CocRequest('clojure-lsp', 'workspace/executeCommand', {'command': 'clean-ns', 'arguments': [Expand('%:p'), line('.') - 1, col('.') - 1]})<CR>
it'll also remove any namespaces that are not in use.
will check em out , thanks fellas .
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.
^i agree, assuming you're talking about deps in a deps.edn / project.clj / build.boot
That's much better than mine 😅 https://github.com/walterl/dotfiles/blob/master/_config/nvim/ftplugin/clojure/clj-clean-ns.vim
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.
TIL I follow the python convention.
I think gofmt does a similar thing in the Go world
@clojurians-slack100 due to namespace conventions, alphabetical ordering automatically achieves 1,3
Which conventions are you referring to? I've seen that clean-ns
puts clojure.*
first, but that's it.
I mean that all "standard library" will start with clojure.
and be together alphabetically
and anything from your own project / library should similarly all start with the same prefix
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.