Top Related Projects
Interactive evaluation for Neovim (Clojure, Fennel, Janet, Racket, Hy, MIT Scheme, Guile, Python and more!)
Quick Overview
Vim-fireplace is a Vim plugin that provides Clojure REPL (Read-Eval-Print Loop) integration for Vim. It allows developers to interact with a Clojure REPL directly from within Vim, enabling seamless evaluation of Clojure code, documentation lookup, and other REPL-based operations without leaving the editor.
Pros
- Seamless integration with Vim, allowing for a smooth workflow between editing and REPL interaction
- Supports various Clojure tools and build systems, including Leiningen, Boot, and Gradle
- Provides powerful features like code evaluation, documentation lookup, and jump-to-definition
- Enhances productivity for Clojure developers who prefer Vim as their editor
Cons
- Steep learning curve for users new to Vim or Clojure
- May require additional setup and configuration for optimal performance
- Limited compared to full-featured Clojure IDEs in terms of advanced features
- Occasional compatibility issues with certain Clojure projects or setups
Code Examples
- Evaluating Clojure code in Vim:
:Eval (+ 1 2 3)
This command evaluates the Clojure expression (+ 1 2 3)
in the REPL and displays the result.
- Looking up documentation:
:Doc map
This command displays the documentation for the Clojure map
function.
- Jumping to definition:
:FindDef some-function-name
This command jumps to the definition of some-function-name
in your Clojure project.
Getting Started
- Install vim-fireplace using your preferred Vim plugin manager. For example, with vim-plug:
Plug 'tpope/vim-fireplace'
-
Ensure you have a Clojure project set up with a supported build tool (e.g., Leiningen, Boot, or Gradle).
-
Open a Clojure file in Vim and start a REPL for your project.
-
Use vim-fireplace commands like
:Eval
,:Doc
, and:FindDef
to interact with your Clojure code.
For more detailed instructions and advanced usage, refer to the plugin's documentation by running :help fireplace
in Vim.
Competitor Comparisons
Interactive evaluation for Neovim (Clojure, Fennel, Janet, Racket, Hy, MIT Scheme, Guile, Python and more!)
Pros of Conjure
- More extensive language support, including Clojure, ClojureScript, Fennel, and others
- Asynchronous evaluation, providing a smoother experience in large projects
- More active development and community support
Cons of Conjure
- Steeper learning curve due to more features and configuration options
- May be overkill for users who only need Clojure support
- Requires Neovim, limiting compatibility with older Vim versions
Code Comparison
vim-fireplace:
:Require
:Eval (+ 1 2 3)
:Doc map
Conjure:
:ConjureEval (+ 1 2 3)
:ConjureDocWord map
:ConjureShadowSelect app
Summary
Both vim-fireplace and Conjure are excellent plugins for Clojure development in Vim/Neovim. vim-fireplace is more focused on Clojure and has a simpler setup, while Conjure offers broader language support and more advanced features. The choice between them depends on your specific needs, preferred editor (Vim vs Neovim), and desired level of customization.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
fireplace.vim
There's a REPL in Fireplace, but you probably wouldn't have noticed if I hadn't told you. Such is the way with fireplace.vim. By the way, this plugin is for Clojure.
Installation
First, set up cider-nrepl. (If you skip this step, only a subset of functionality will be available.)
Install Fireplace using your favorite package manager, or use Vim's built-in package support:
mkdir -p ~/.vim/pack/tpope/start
cd ~/.vim/pack/tpope/start
git clone https://tpope.io/vim/fireplace.git
vim -u NONE -c "helptags fireplace/doc" -c q
You might also want salve.vim for assorted static project support.
Features
This list isn't exhaustive; see the :help
for details.
Transparent setup
Fireplace talks to nREPL. With Leiningen and Boot, it connects automatically
using the .nrepl-port
file created when you run lein repl
or boot repl
.
If you are starting nREPL some other way, run :FireplaceConnect host:port
.
You can connect to multiple instances of nREPL for different projects, and it
will use the right one automatically. ClojureScript support is just as
seamless with Piggieback.
If you're using the new Clojure CLI, you can follow the instructions for
running cider-nrepl with clj
.
Briefly, clj -Sdeps '{:deps {cider/cider-nrepl {:mvn/version "0.21.1"} }}' -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"
should do the trick.
The cider-nrepl docs also show you how you can add an alias to
your user's ~/.clojure/deps.edn
file, letting you more simply run clj -A:cider-clj
.
Oh, and if you don't have an nREPL connection, installing salve.vim
lets it fall back to using java clojure.main
for some of the basics, using a
class path based on your Leiningen or Boot config. It's a bit slow, but a
two-second delay is vastly preferable to being forced out of my flow for a
single command, in my book.
Not quite a REPL
You know that one plugin that provides a REPL in a split window and works absolutely flawlessly, never breaking just because you did something innocuous like backspace through part of the prompt? No? Such a shame, you really would have liked it.
I've taken a different approach in Fireplace. cq
(Think "Clojure
Quasi-REPL") is the prefix for a set of commands that bring up a command-line
window â the same thing you get when you hit q:
â but set up for Clojure
code.
cqq
prepopulates the command-line window with the expression under the
cursor. cqc
gives you a blank line in insert mode.
Evaluating from the buffer
Standard stuff here. :Eval
evaluates a range (:%Eval
gets the whole
file), :Require
requires a namespace with :reload
(:Require!
does
:reload-all
), either the current buffer or a given argument. :RunTests
kicks off (clojure.test/run-tests)
and loads the results into the quickfix
list.
There's a cp
operator that evaluates a given motion (cpp
for the
innermost form under the cursor). cm
and c1m
are similar, but they only
run clojure.walk/macroexpand-all
and macroexpand-1
instead of evaluating
the form entirely.
Any failed evaluation loads the stack trace into the location list, which
can be easily accessed with :lopen
.
Navigating and Comprehending
I was brand new to Clojure when I started this plugin, so stuff that helped me understand code was a top priority.
-
:Source
,:Doc
, and:FindDoc
, which map to the underlyingclojure.repl
macro (with tab complete, of course). -
K
is mapped to look up the symbol under the cursor withdoc
. -
]D
is mapped to look up the symbol under the cursor withsource
. -
]<C-D>
jumps to the definition of a symbol (even if it's inside a jar file).<C-]>
does the same and uses the tag stack. -
gf
, everybody's favorite "go to file" command, works on namespaces.
Where possible, I favor enhancing built-ins over inventing a bunch of
<Leader>
maps.
Omnicomplete
Because why not? It works in the quasi-REPL too.
FAQ
Why does it take so long for Vim to start up?
That's either classpath.vim or salve.vim.
Self-Promotion
Like fireplace.vim? Follow the repository on GitHub and vote for it on vim.org. And if you're feeling especially charitable, follow tpope on Twitter and GitHub.
License
Copyright © Tim Pope. Distributed under the same terms as Vim itself.
See :help license
.
Top Related Projects
Interactive evaluation for Neovim (Clojure, Fennel, Janet, Racket, Hy, MIT Scheme, Guile, Python and more!)
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot