├── .gitignore ├── CONTRIBUTING.markdown ├── README.markdown ├── autoload ├── fireplace.vim └── fireplace │ ├── session.vim │ └── transport.vim ├── doc └── fireplace.txt ├── plugin └── fireplace.vim └── pythonx └── fireplace.py /.gitignore: -------------------------------------------------------------------------------- 1 | /doc/tags 2 | *.pyc 3 | -------------------------------------------------------------------------------- /CONTRIBUTING.markdown: -------------------------------------------------------------------------------- 1 | ## Contributing 2 | 3 | Open [GitHub issues][] for bug reports and feature requests. 4 | 5 | I'm a stickler for [commit messages][], so if you send me a pull 6 | request with so much as superfluous period in the subject line, I will 7 | reject it, then TP your house. 8 | 9 | [GitHub issues]: http://github.com/tpope/vim-fireplace/issues 10 | [commit messages]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html 11 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | # fireplace.vim 2 | 3 | There's a REPL in Fireplace, but you probably wouldn't have noticed if I hadn't 4 | told you. Such is the way with fireplace.vim. By the way, this plugin is for 5 | Clojure. 6 | 7 | ## Installation 8 | 9 | First, set up [cider-nrepl][]. (If you skip this step, only a subset of 10 | functionality will be available.) 11 | 12 | Install Fireplace using your favorite package manager, or use Vim's built-in 13 | package support: 14 | 15 | mkdir -p ~/.vim/pack/tpope/start 16 | cd ~/.vim/pack/tpope/start 17 | git clone https://tpope.io/vim/fireplace.git 18 | vim -u NONE -c "helptags fireplace/doc" -c q 19 | 20 | You might also want [salve.vim][] for assorted static project support. 21 | 22 | ## Features 23 | 24 | This list isn't exhaustive; see the `:help` for details. 25 | 26 | ### Transparent setup 27 | 28 | Fireplace talks to nREPL. With Leiningen and Boot, it connects automatically 29 | using the `.nrepl-port` file created when you run `lein repl` or `boot repl`. 30 | If you are starting nREPL some other way, run `:FireplaceConnect host:port`. 31 | You can connect to multiple instances of nREPL for different projects, and it 32 | will use the right one automatically. ClojureScript support is just as 33 | seamless with [Piggieback][]. 34 | 35 | If you're using the new [Clojure CLI][], you can follow the instructions for 36 | [running cider-nrepl with `clj`][cider-nrepl-via-clj]. 37 | Briefly, `clj -Sdeps '{:deps {cider/cider-nrepl {:mvn/version "0.21.1"} }}' 38 | -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"` should do the trick. 39 | The [cider-nrepl][cider-nrepl-via-clj] docs also show you how you can add an alias to 40 | your user's `~/.clojure/deps.edn` file, letting you more simply run `clj -A:cider-clj`. 41 | 42 | Oh, and if you don't have an nREPL connection, installing [salve.vim][] 43 | lets it fall back to using `java clojure.main` for some of the basics, using a 44 | class path based on your Leiningen or Boot config. It's a bit slow, but a 45 | two-second delay is vastly preferable to being forced out of my flow for a 46 | single command, in my book. 47 | 48 | [cider-nrepl]: https://docs.cider.mx/cider-nrepl/usage.html 49 | [cider-nrepl-via-clj]: https://docs.cider.mx/cider-nrepl/usage.html#via-clj 50 | [Piggieback]: https://github.com/nrepl/piggieback 51 | [Clojure CLI]: https://clojure.org/guides/deps_and_cli 52 | [classpath.vim]: https://github.com/tpope/vim-classpath 53 | [salve.vim]: https://github.com/tpope/vim-salve 54 | 55 | ### Not quite a REPL 56 | 57 | You know that one plugin that provides a REPL in a split window and works 58 | absolutely flawlessly, never breaking just because you did something innocuous 59 | like backspace through part of the prompt? No? Such a shame, you really 60 | would have liked it. 61 | 62 | I've taken a different approach in Fireplace. `cq` (Think "Clojure 63 | Quasi-REPL") is the prefix for a set of commands that bring up a *command-line 64 | window* — the same thing you get when you hit `q:` — but set up for Clojure 65 | code. 66 | 67 | `cqq` prepopulates the command-line window with the expression under the 68 | cursor. `cqc` gives you a blank line in insert mode. 69 | 70 | ### Evaluating from the buffer 71 | 72 | Standard stuff here. `:Eval` evaluates a range (`:%Eval` gets the whole 73 | file), `:Require` requires a namespace with `:reload` (`:Require!` does 74 | `:reload-all`), either the current buffer or a given argument. `:RunTests` 75 | kicks off `(clojure.test/run-tests)` and loads the results into the quickfix 76 | list. 77 | 78 | There's a `cp` operator that evaluates a given motion (`cpp` for the 79 | innermost form under the cursor). `cm` and `c1m` are similar, but they only 80 | run `clojure.walk/macroexpand-all` and `macroexpand-1` instead of evaluating 81 | the form entirely. 82 | 83 | Any failed evaluation loads the stack trace into the location list, which 84 | can be easily accessed with `:lopen`. 85 | 86 | ### Navigating and Comprehending 87 | 88 | I was brand new to Clojure when I started this plugin, so stuff that helped me 89 | understand code was a top priority. 90 | 91 | * `:Source`, `:Doc`, and `:FindDoc`, which map to the underlying 92 | `clojure.repl` macro (with tab complete, of course). 93 | 94 | * `K` is mapped to look up the symbol under the cursor with `doc`. 95 | 96 | * `]D` is mapped to look up the symbol under the cursor with `source`. 97 | 98 | * `]` jumps to the definition of a symbol (even if it's inside a jar 99 | file). `` does the same and uses the tag stack. 100 | 101 | * `gf`, everybody's favorite "go to file" command, works on namespaces. 102 | 103 | Where possible, I favor enhancing built-ins over inventing a bunch of 104 | `` maps. 105 | 106 | ### Omnicomplete 107 | 108 | Because why not? It works in the quasi-REPL too. 109 | 110 | ## FAQ 111 | 112 | > Why does it take so long for Vim to start up? 113 | 114 | That's either [classpath.vim][] or [salve.vim][]. 115 | 116 | ## Self-Promotion 117 | 118 | Like fireplace.vim? Follow the repository on 119 | [GitHub](https://github.com/tpope/vim-fireplace) and vote for it on 120 | [vim.org](http://www.vim.org/scripts/script.php?script_id=4978). And if 121 | you're feeling especially charitable, follow [tpope](http://tpo.pe/) on 122 | [Twitter](http://twitter.com/tpope) and 123 | [GitHub](https://github.com/tpope). 124 | 125 | ## License 126 | 127 | Copyright © Tim Pope. Distributed under the same terms as Vim itself. 128 | See `:help license`. 129 | -------------------------------------------------------------------------------- /autoload/fireplace.vim: -------------------------------------------------------------------------------- 1 | " Location: autoload/fireplace.vim 2 | " Author: Tim Pope 3 | 4 | if exists('g:autoloaded_fireplace') 5 | finish 6 | endif 7 | let g:autoloaded_fireplace = 1 8 | 9 | " Section: Utilities 10 | 11 | function! s:map(mode, lhs, rhs, ...) abort 12 | if get(g:, 'fireplace_no_maps') 13 | return 14 | endif 15 | let flags = (a:0 ? a:1 : '') . (a:rhs =~# '^' ? '' : '