vim

For discussion on all things (neo)vim.
nezaj 2020-10-30T05:39:54.098400Z

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

dominicm 2020-10-30T08:56:10.098600Z

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

nezaj 2020-10-30T18:32:57.110200Z

@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 {}})

dominicm 2020-10-30T18:49:34.110400Z

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

dominicm 2020-10-30T18:49:44.110600Z

Add it to source-paths

nezaj 2020-10-30T19:09:37.110800Z

@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

dominicm 2020-10-30T20:22:07.111Z

You only need the call to repl-env

dominicm 2020-10-30T20:22:33.111200Z

Figwheel handles the nodejs bit itself

nezaj 2020-10-30T20:35:00.111400Z

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

dominicm 2020-10-30T20:35:33.111700Z

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

dominicm 2020-10-30T20:36:29.111900Z

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

dominicm 2020-10-30T20:36:55.112100Z

You don't have target node, for example.

nezaj 2020-10-30T21:08:30.113800Z

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

nezaj 2020-10-30T21:10:45.114Z

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

nezaj 2020-10-30T21:13:24.114200Z

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

dominicm 2020-10-30T22:46:07.116800Z

Ah, ok

dominicm 2020-10-30T22:46:24.117Z

In that case you need to call the figwheel function

dominicm 2020-10-30T22:46:55.117200Z

Or you could try weasel again :)

nezaj 2020-10-30T22:49:25.117400Z

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

2020-10-30T12:25:50.100500Z

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

dave 2020-10-30T12:32:45.101100Z

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

dave 2020-10-30T12:33:01.101300Z

i do that quite a bit

2020-10-30T12:43:13.101600Z

sweet , ill try that . thanks!

kelveden 2020-10-30T12:45:42.102800Z

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/)

👌 1
dominicm 2020-10-30T13:06:41.103400Z

Replant has a command for that

dharrigan 2020-10-30T13:15:05.104Z

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

dharrigan 2020-10-30T13:15:25.104200Z

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

dharrigan 2020-10-30T13:15:36.104500Z

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

🔥 3
2020-10-30T13:38:16.105200Z

will check em out , thanks fellas .

practicalli-john 2020-10-30T14:02:37.109700Z

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.

dave 2020-10-30T14:24:43.110100Z

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

👍 1
walterl 2020-10-30T21:02:59.112300Z

That's much better than mine 😅 https://github.com/walterl/dotfiles/blob/master/_config/nvim/ftplugin/clojure/clj-clean-ns.vim

walterl 2020-10-30T21:05:38.113700Z

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.

💯 1
Jivago Alves 2020-10-31T09:10:33.118700Z

TIL I follow the python convention.

dave 2020-10-30T21:20:04.114800Z

I think gofmt does a similar thing in the Go world

2020-10-30T21:52:20.116500Z

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

walterl 2020-10-30T22:23:26.116600Z

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

2020-10-30T23:14:49.117600Z

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

2020-10-30T23:15:19.117800Z

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

walterl 2020-10-30T23:23:44.118Z

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.