Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save finalfantasia/292b8432dc0072b2397ea4d694aab930 to your computer and use it in GitHub Desktop.

Select an option

Save finalfantasia/292b8432dc0072b2397ea4d694aab930 to your computer and use it in GitHub Desktop.
Shadow-CLJS and Fireplace.vim Integration
  1. Create an app following the official Shadow-CLJS Quick Start instructions.
  2. Modify shadow-cljs.edn
;; shadow-cljs configuration
{:source-paths
 ["src/dev"
  "src/main"
  "src/test"]

 ;; ADD - CIDER middleware for nREPL (required by fireplace.vim)
 :dependencies
 [[cider/cider-nrepl "0.22.4"]]

 ;; ADD - a port for nREPL to which fireplace.vim connects
 :nrepl
 {:port 3333}

 ;; ADD - a port for the developmemt-time HTTP server that serves the app
 :dev-http
 {8080 "public"}

 :builds
 {:frontend  ; NOTE - This is the build ID referenced at various places below.
  {:target :browser
   :modules {:main {:init-fn acme.frontend.app/init}}}}}
  1. Start the app (note the build ID,frontend)
npx shadow-cljs watch frontend
  1. Open the app in a browser at http://localhost:8080/. Without this step, you would get the following error:
No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.
  1. Open a ClojureScript source file in Vim/Neovim
~/code/clojurescript/acme-app $ vi src/main/acme/frontend/app.cljs
  1. Connect fireplace.vim to nREPL (which is Clojure REPL) at port 3333
:Connect 3333
=>
Connected to nrepl://localhost:3333/                                                              
Scope connection to: ~/code/clojurescript/acme-app (ENTER)
  1. Add ClojureScript support to the Clojure nREPL session (note the build ID, frontend)
:CljEval (shadow/repl :frontend)
=>
To quit, type: :cljs/quit                                                                      
[:selected :frontend]
Press ENTER or type command to continue
  1. You should be able to use regular fireplace.vim commands to do REPL-driven development now.
@mrsipan
Copy link
Copy Markdown

mrsipan commented Dec 6, 2021

Thanks! works very well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment