Compare commits

..

151 Commits

Author SHA1 Message Date
Tim Pope 2bab337396 Merge pull request #259 from rm-hull/bugfix/handle-nREPL-stacktrace
Handle new/old nREPL stacktraces - fixes #258
2016-01-29 16:03:38 -05:00
Richard Hull 0814dd0d2d Handle new/old nREPL stacktraces - fixes #258
At some point there was an upstream change to the message format that
cider-nrepl returned. This resulted in in a crash when trying to eval
an expression that threw an exception, resulting in the exception
being obscured by a Vim error, and no stacktrace being produced.
This patch inspects the returned payload and optionally extracts
any embedded stacktrace before processing.
2016-01-29 20:45:57 +00:00
Tim Pope b550ac6680 Merge pull request #254 from smy20011/master
Use CRLF on windows when parsing test result
2015-12-29 00:46:03 -05:00
Siyuan Ma fd18e8481d Use "\r\\=\n" indicate line break. 2015-12-28 22:17:03 -06:00
Tim Pope fd94f70fff Merge pull request #251 from SevereOverfl0w/patch-1
Replace leiningen.vim with salve.vim
2015-12-07 21:03:48 -05:00
Dominic Monroe 2d5177abef Replace leiningen.vim with salve.vim 2015-12-07 20:52:52 +00:00
Tim Pope 1c75b56ceb Sort bencode keys
Closes https://github.com/tpope/vim-fireplace/issues/248
2015-11-30 19:31:27 -05:00
Daniel Silva f57537135a Add FireplaceEvalPost autocommand
Closes #232.
2015-11-13 18:29:41 -05:00
Tim Pope 8579a41a18 Merge pull request #239 from siphiuel/master
Change :Piggieback behavior for empty/port parameters
2015-10-02 12:12:42 -04:00
Vitaliy Vlasov 3474bd5d72 Change :Piggieback behavior for empty/port parameters
- Explicitly specify Rhino REPL when :Piggieback has no parameters

- Use Weasel REPL when port parameter is provided to :Piggieback

- Improve leading space handling for :Piggieback params

- Fall back to cljs.repl.browser if Weasel in not in classpath

- Use has_key() when checking for Weasel repl availability
2015-10-02 11:07:28 +03:00
Tim Pope 3ffdb062c6 Allow for empty lists in ns declaration 2015-09-30 12:52:10 -04:00
Tim Pope b1725f68a1 Determine aliases by statically parsing ns declaration 2015-09-30 12:22:01 -04:00
Tim Pope 7d500028e6 Rearrange 2015-09-28 18:02:10 -04:00
Juho Teperi df563ed15f Fix alias edge case detection in cfile 2015-09-28 15:00:06 -04:00
Tim Pope 04a7f542f5 Improve error on piggieback failure
References #167.
2015-09-22 14:29:07 -04:00
Tim Pope 3d9b9a59cd Merge pull request #236 from janko-m/runtests-error
Fix a runtime error in :RunTests
2015-08-24 14:23:19 -04:00
Janko Marohnić 9a770d3716 Fix a runtime error in :RunTests 2015-08-24 11:54:05 +02:00
Tim Pope b3b54b8715 Merge pull request #231 from nberger/use-test-vars-on-single-var
Run (single) test under cursor with fixtures applied
2015-07-31 14:39:19 -04:00
Nicolas Berger b50e74f342 Run test under cursor with fixtures applied
Use `test-vars` instead of `test-var` so the test runs with the fixtures
applied. That's the expected behavior when running a test. It's also
what's being done when multiple tests are matched.
2015-07-31 14:53:12 -03:00
Tim Pope 9f7b1844cf Merge pull request #229 from kul/master
Remove superfluous padding from expression
2015-07-18 12:51:18 -04:00
kul 74d392339c Remove superfluous padding from expression 2015-07-18 12:23:31 +05:30
Tim Pope a1571cd258 fireplace.vim 1.1
* Support cider completion, including context aware completion.
* Updates for latest cider-nrepl and piggieback.
* Use :.RunTests or 1cpr to run test under cursor.
* Add CTRL-R CTRL-F and CTRL-R CTRL-P command line maps.
* Add support for boot's fake class path.
* Fix handling of CTRL-C interrupt while evaling.
* Numerous minor bug fixes.
2015-06-30 18:34:36 -04:00
Tim Pope f456f04b65 Work around bug on ancient Vim
Closes #226.
2015-06-29 17:46:45 -04:00
Tim Pope 09c80c6794 Allow 1cpr to run test under cursor 2015-06-26 09:36:14 -04:00
Tim Pope 459904381b Use :.RunTests to run test under cursor
Closes #223.
2015-06-25 15:34:45 -04:00
Tim Pope 69bf9ef519 Make :0RunTests equivalent to RunAllTests 2015-06-25 15:04:12 -04:00
Tim Pope 1f478e401a Tweak <cfile> 2015-06-25 10:17:58 -04:00
Tim Pope cb3c270c99 Add cljc extension support to connection process 2015-06-23 15:56:50 -04:00
Tim Pope 7b2ae78bd7 Add <C-R> command line maps 2015-06-21 15:12:39 -04:00
Tim Pope b0a540c68d Add .cljc extension 2015-06-21 15:08:30 -04:00
Tim Pope 09eedd05af Use jar command if available to query zip files 2015-06-21 15:08:29 -04:00
Tim Pope 89aee9c00c Merge pull request #214 from Deraen/completion-context
Completion context
2015-05-17 11:01:43 -04:00
Juho Teperi c22e61c69b Add support for context aware completion
If complete operation is given context property containing the
current toplevel form Compliment library can give better completion
results in some contexts:

- Local vars for let and defn
- Resources in classpath for io/resource calls
- Vars in specific ns for :require :refer
- Better Java class name completion for :import

The context string should contain symbol __prefix__ in place of the word
being completed. To achieve this location of cursor inside the toplevel
form is calculated so that the placeholder symbol can be placed in the
proper place.
2015-05-17 17:54:06 +03:00
Roger Gilliar 13a21bff0f Fix count of test errors and failures
Closes #208.
2015-05-17 10:06:21 -04:00
Tim Pope 1646a01b0b Merge pull request #211 from Deraen/all-candidate-types
Add all candidate types to short_types map
2015-05-16 16:17:59 -04:00
Juho Teperi aede23c46a Add all candidate types to short_types map 2015-05-16 23:01:23 +03:00
Tim Pope 819438bdf4 Merge pull request #210 from Deraen/cider-nrepl-0.9.0
Cider nrepl 0.9.0 completion support
2015-05-15 16:19:55 -04:00
Juho Teperi 9ccaea1f2b Request extra-metadata for completion candidates
In cider-nrepl 0.9.0 there is new extra-metadata option for complete op
[1]. It can be used to enrich the candiate results with additional
properties like arglists and docstring.

This commit adds extra-metadata option to complete call and changes the
candidate function to set fields in omnicomplete result so that arglists
are shown on omnicomplete menu and docstring is shown in preview window.

[1]: https://github.com/clojure-emacs/cider-nrepl/pull/195/files
2015-05-15 22:54:08 +03:00
Juho Teperi 44e766d5a5 Add support for Cider-nrepl 0.9.0 complete op
Response from complete operation now returns list of maps containing
e.g. namespace and type of the completion candidate.
This change adds a new type check to check if complete returned list of
maps and converts those maps to format required by omnicomplete.
In addition to candidate name its type is now shown. The type is
shortned to one character.
2015-05-15 22:31:54 +03:00
Tim Pope 49153a39fc Merge pull request #201 from kul/master
Remove `:repl-env` for latest piggieback compatibility.
2015-04-13 16:27:49 -04:00
kul 0aabcdd798 Remove `:repl-env` for latest piggieback compatibility. 2015-03-31 20:52:10 +05:30
Joshua Davey 5866d0017a Add support for boot 2.0 and up
Boot's built-in repl task adds a fake.class.path System property which
refers back to the original user files (as opposed to the temporary
files it uses to actually do builds). We should prefer that to anything
else when the property is set.

Fixes #194.
2015-02-15 13:45:21 -05:00
Robert Pitts 7cebf6847e Document `cqq` 2015-02-10 15:27:43 -05:00
Tim Pope 71e44af208 Fix c1mm 2015-02-10 11:11:53 -05:00
Tim Pope b999b09cd9 Fix project directory path for autoconnection
Closes #189.
2014-12-20 01:27:23 -05:00
Tim Pope 506cf288bd Skip regexp when selecting form for cpp
Closes #188.
2014-12-11 11:31:23 -05:00
Tim Pope 0ecd9ec587 Fix duplicate namespaces in completion 2014-11-30 00:53:32 -05:00
Tim Pope 874505e9f2 Support new return value of completions operator 2014-11-30 00:46:33 -05:00
Tim Pope 04ce1b64af Support new return value of classpath operator 2014-11-30 00:36:33 -05:00
Tim Pope db2e70ee3f Cider info op no longer embeds in value attribute
Closes #186.
2014-11-19 00:49:58 -05:00
Tim Pope 8f7a07cffd Allow forcing default ns 2014-10-23 15:52:50 -04:00
Tim Pope 97758acc16 Fix sending interrupt commands after SIGINT
Via @benmoss.  Closes #182.
2014-10-21 15:29:31 -04:00
Tim Pope eeccb69a2f Fix typo 2014-10-21 15:14:38 -04:00
Tim Pope c0e574387d Fix completion in aliased namespaces 2014-10-10 02:40:10 -04:00
Tim Pope fccb149148 Recognize nested classes in K
Closes #176.
2014-09-05 13:10:21 -04:00
Tim Pope c1416c89ba Don't choke on missing API version
Closes #175.
2014-09-02 12:26:13 -04:00
Tim Pope b256399f3f Merge pull request #169 from oahner/fix-portfile-issue
Register port file after connecting to port
2014-07-31 10:34:32 -04:00
Jonathan Henry 142fab4e0f Register port file after connecting to port 2014-07-31 00:57:15 -04:00
Tim Pope 06f6bc5de6 Evaluate single expression when running tests
This eliminates an extra "nil" value in the response.
2014-07-12 23:17:30 -04:00
Tim Pope d6b3e1c67c Silence all callback errors
If this is to be made asynchronous, there's not really a good way to
display the exception.
2014-07-10 22:58:35 -04:00
Tim Pope ebb2933f4c Pass additional .message arguments to callback 2014-07-10 22:43:03 -04:00
Tim Pope 3e978e4cd4 Add better name for fireplace#evalparse() 2014-07-04 17:14:10 -04:00
Tim Pope a39092ebe3 Add script id 2014-07-04 17:00:21 -04:00
Tim Pope 835fdedf5f fireplace.vim 1.0 2014-07-04 16:50:18 -04:00
Tim Pope e107b2ae17 Drop reference to old name 2014-07-04 16:32:52 -04:00
Tim Pope 1dc5129c0e Tweak description 2014-07-04 16:24:46 -04:00
Tim Pope 712205e66a Normalize headers 2014-07-04 16:06:43 -04:00
Tim Pope ffc41e86f3 Remove obsolete Maven reference 2014-07-04 15:38:00 -04:00
Tim Pope 37e3a474c5 Clarify plugin/fireplace/zip.vim 2014-07-04 15:04:44 -04:00
Tim Pope 1f36136346 Zip hack unnecessary on Vim 7.4 2014-07-03 14:49:18 -04:00
Tim Pope ea15c81773 Remove extracted compiler plugin 2014-07-03 14:45:11 -04:00
Tim Pope 25e18b5f82 Support gf on relative (load) paths
This doesn't do a file existence check because that's tricky with jar
files in the mix.  Instead, it's limited to strings, so a gf on a random
symbol doesn't send us flying.
2014-07-03 12:30:32 -04:00
Tim Pope a14328c1dc Allow disabling all maps 2014-07-03 12:28:23 -04:00
Tim Pope eae17cfb42 Drop 'includeexpr' entirely 2014-07-03 10:22:55 -04:00
Tim Pope 845b362a17 Find absolute path in 'includeexpr'
The gf map is still necessary because Vim doesn't accept zipfile paths
as valid.
2014-07-03 10:02:34 -04:00
Tim Pope a1eef3dda1 Rearrange 2014-07-03 09:52:28 -04:00
Tim Pope 0e42998a27 Provide :RunAllTests
Don't waste :RunTests! on this cleverness.
2014-07-02 19:20:11 -04:00
Tim Pope 9c78e32f4b Add plugin maps for go to file 2014-07-02 18:44:20 -04:00
Tim Pope fb6975bfdf Extract autocmd repetition to functions 2014-07-02 18:38:49 -04:00
Tim Pope 8defd6b17e Fix grammar: setup -> set_up 2014-07-02 18:33:23 -04:00
Tim Pope 26e467c2e7 Fix list of available protocols
Closes #165.
2014-07-01 09:19:32 -04:00
Tim Pope 6dbf627022 Make connect commands buffer local 2014-06-29 19:03:49 -04:00
Tim Pope 5ff2eeae1c Default to nrepl protocol 2014-06-29 18:54:07 -04:00
Tim Pope 94ff1464a4 Fix manual connection 2014-06-29 18:53:41 -04:00
Tim Pope f2b6a2101f Ignore errors on autorequire if namespace created
Closes #161.
2014-06-27 13:30:12 -04:00
Tim Pope b10259bcca Fix naming inconsistency 2014-06-27 11:17:13 -04:00
Tim Pope bfdd052fc7 Section header style change 2014-06-27 09:46:21 -04:00
Tim Pope c657faaf4e Remove transitional support 2014-06-27 09:45:00 -04:00
Tim Pope e4b975eaec Don't clobber K map
Closes #163.
2014-06-25 14:52:01 -04:00
Tim Pope 2cbaacf0d0 Fix bdecode of negative number
Closes #162.
2014-06-17 22:35:45 -04:00
Tim Pope 83a317c10b Merge pull request #160 from jgdavey/docs
Update documentation: keyword -> symbol
2014-06-11 15:09:02 -04:00
Joshua Davey e6c4b5547a Update documentation: keyword -> symbol 2014-06-11 10:41:10 -05:00
Tim Pope 049005dec7 Merge pull request #152 from jgdavey/brepl
Browser piggieback connection convenience
2014-06-10 17:56:43 -04:00
Bohr Shaw 88648b2578 Feed &cedit as a key properly - fix #62 2014-05-20 19:52:24 -04:00
Tim Pope 67078e0c34 Clarify projectionist requirement
Closes #153.
2014-05-19 19:26:13 -04:00
Joshua Davey 99d93ceba1 Browser piggieback connection convenience
When you provide a port number, you are implicitly saying you're
listening for a browser connection.
2014-05-14 08:57:31 -05:00
Tim Pope 29af4adc46 Kill :Apropos
This is broken for anything namespaced.  REPL-y's find-name is better,
but nonstandard.
2014-05-05 15:24:26 -04:00
Tim Pope ac88f17bb4 Move window logic into test capture 2014-05-05 01:31:36 -04:00
Tim Pope af14811869 Capture test run errors 2014-05-05 01:23:30 -04:00
Tim Pope 0b17709b56 Don't blow up on unrecognized session 2014-05-05 01:16:00 -04:00
Tim Pope fa7a19140b Allow sending custom id on eval 2014-05-05 00:59:35 -04:00
Tim Pope 6cea463c97 Set title on test quickfix window 2014-05-04 22:42:58 -04:00
Tim Pope fff348ccd0 Respect 'autowrite' in :Require and :RunTests 2014-05-04 18:09:56 -04:00
Tim Pope 020a10d06c Use info op for :Doc
This should enable ClojureScript support.
2014-05-01 22:26:53 -04:00
Tim Pope afb036203e Drop Leiningen and alternate support 2014-04-29 21:28:28 -04:00
Tim Pope 58896e23fa Fix cpp documentation
Closes #148.
2014-04-29 20:47:00 -04:00
Tim Pope 57c18b778a Promote leiningen.vim over classpath.vim
Classpath.vim as a clearinghouse for classpath detection is officially
deprecated, though the plugin may take on other responsibilities such as
stacktrace parsing.
2014-04-29 17:34:09 -04:00
Tim Pope 0bc928f0fc Automatic require :reload on :RunTests
Really, I just want an atomic way to perform these two operations.
:Require|RunTests seems like it would work, but it obliviously runs the
tests even if the require fails, plus copes poorly with the one-off
runner.
2014-04-28 23:06:21 -04:00
Tim Pope 062256b9fd Fix link 2014-04-28 15:58:35 -04:00
Tim Pope a2278afbdd Document soft dependency on cider-nrepl 2014-04-24 23:31:04 -04:00
Tim Pope 9eb5099ba1 Clarify ClojureScript support
Closes #147.
2014-04-24 02:13:00 -04:00
Tim Pope 12386dc0c2 Fix newlines in c!
Closes #146.
2014-04-23 23:16:02 -04:00
Tim Pope 05cbc742a1 Use classpath op if available
References #131.
2014-04-23 14:52:08 -04:00
Tim Pope e484ad6996 Use info op to drive jump to definition 2014-04-20 18:55:37 -04:00
Tim Pope e974dd4766 Prepare for extraction of leiningen support 2014-04-20 18:53:01 -04:00
Tim Pope 2d1f3088b2 Fix :RunTests with no argument 2014-04-14 01:55:16 -04:00
Tim Pope f25003deef Decouple quickfix massaging from lein support 2014-04-14 00:22:43 -04:00
Tim Pope c0a4901181 Fix support for Python 3
Closes #144.
2014-04-13 17:07:47 -04:00
Tim Pope 7b19c1b2f6 Require if_pyth on Windows
References #97, #139.
2014-04-12 22:18:26 -04:00
Tim Pope 672d3b5c82 Use stacktrace nrepl op if available 2014-04-12 22:03:14 -04:00
Tim Pope 0936b3cb4f Use correct session to retrieve stacktrace 2014-04-12 21:57:01 -04:00
Tim Pope 05206aa2e9 Drop obsolete warning 2014-04-12 21:55:28 -04:00
Tim Pope 5f1cee19c0 Never throw exception in fireplace#op_available 2014-04-12 21:49:45 -04:00
Tim Pope c6e0d55143 Use nrepl complete op if available
Closes #65.
2014-04-12 21:20:15 -04:00
Tim Pope 89acd66d6d Drop qualification of macroexpand-1
Who would shadow this?
2014-04-12 21:18:18 -04:00
Tim Pope feb8ebc976 Happy path for lookup macros 2014-04-12 21:18:18 -04:00
Tim Pope f5ded81baf Drop unnecessary clojure.core
We're in a clean user ns so the qualification is unnecessary here.
2014-04-12 21:18:18 -04:00
Tim Pope 238b526cf2 Use user ns to avoid qualification 2014-04-12 21:18:18 -04:00
Tim Pope 9e826faff4 Allow omitting ns from fireplace#message 2014-04-12 20:31:18 -04:00
Tim Pope 79c2a718da Allow checking for nREPL op 2014-04-12 20:31:18 -04:00
Tim Pope c48adc045b Fix jump location for :RunTests error 2014-04-12 20:28:34 -04:00
Tim Pope bc8f3af299 Cleaner classpath retrieval 2014-04-12 18:15:22 -04:00
Tim Pope 2dec3b49b2 Expose fireplace#register_port_file
References #121.
2014-04-10 23:25:59 -04:00
Tim Pope ea1012e1be Don't use session for :Source/:Doc 2014-04-09 13:23:19 -04:00
Tim Pope 916fc04ecb Don't depend on classpath.vim
Other plugins should be able to set up the path as well without
classpath.vim serving as a clearinghouse.
2014-04-09 13:20:13 -04:00
Tim Pope ead617d9c3 Centralize use of classpath.vim 2014-04-09 12:45:54 -04:00
Tim Pope f43fa99703 Fix check for haslocaldir() 2014-04-05 19:27:41 -04:00
Tim Pope 6130d01b33 Give up on autostart with "headless" handler 2014-04-04 02:15:25 -04:00
Tim Pope b0f9fad9ec Autostart lein repl with dispatch.vim
Great idea?  Or greatest idea?
2014-04-04 01:57:43 -04:00
Tim Pope 4425618825 Add run-tests to cpr
Clobbering the quickfix is probably a deal breaker but hey let's try it
anyways.

References #59.
2014-04-04 00:58:52 -04:00
Tim Pope 092ab0f70e Provide :RunTests
:RunTests! currently calls (run-all-tests), but if we find a more useful
semantic for ! that might change.

Closes #59.
2014-04-04 00:58:21 -04:00
Tim Pope 73f9a3adf4 Not a noob anymore 2014-04-03 23:53:12 -04:00
Tim Pope 6c13396262 Remove dead code 2014-04-03 21:16:42 -04:00
Tim Pope 9a689480ef Better rooting with findfile()
I think this is more portable.
2014-04-03 21:09:00 -04:00
Tim Pope ab5eee34d8 Support .nrepl-port outside of Leiningen 2014-04-03 21:03:26 -04:00
Tim Pope 1bfb5aadcf Update name of preferred port file in README 2014-04-03 19:46:29 -04:00
Tim Pope ab6d9db216 Tentatively drop support for session eval without REPL
I'm not 100% committed to this, but lets see if anyone even misses it
(including me).  My main use case for the one-off runner is jump to
source.
2014-04-03 19:37:47 -04:00
Tim Pope 095ee57d12 Revert "Steal Windows shell escaping from dispatch.vim"
This reverts commit 15450eff27.
2014-04-03 18:57:18 -04:00
Tim Pope da3f5857b5 Respect jump list on ]<C-D> within same file
Closes #70.
2014-04-03 18:23:24 -04:00
Tim Pope d65eaa5068 Fix c!! with selection=inclusive
References #110.
2014-04-03 16:23:13 -04:00
Tim Pope 90b909b9f4 Use innermost form with cpp et al
Closes #119.
2014-03-29 20:52:31 -04:00
8 changed files with 922 additions and 532 deletions

View File

@ -4,14 +4,14 @@ 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.
Fireplace.vim used to be called foreplay.vim, but it was renamed so Java
developers wouldn't have to speak in hushed tones.
## Installation
Fireplace.vim doesn't provide indenting or syntax highlighting, so you'll want
[a set of Clojure runtime files](https://github.com/guns/vim-clojure-static).
You might also want [classpath.vim][] to run code when no REPL is available.
First, set up [cider-nrepl][]. (If you skip this step, fireplace.vim will
make do with eval, which mostly works.) Next, fireplace.vim doesn't provide
indenting or syntax highlighting, so you'll want [a set of Clojure runtime
files](https://github.com/guns/vim-clojure-static) if you're on a version of
Vim earlier than 7.4. You might also want [salve.vim][] for assorted
static project support.
If you don't have a preferred installation method, I recommend
installing [pathogen.vim](https://github.com/tpope/vim-pathogen), and
@ -19,8 +19,6 @@ then simply copy and paste:
cd ~/.vim/bundle
git clone git://github.com/tpope/vim-fireplace.git
git clone git://github.com/tpope/vim-classpath.git
git clone git://github.com/guns/vim-clojure-static.git
Once help tags have been generated, you can view the manual with
`:help fireplace`.
@ -32,22 +30,24 @@ This list isn't exhaustive; see the `:help` for details.
### Transparent setup
Fireplace.vim talks to nREPL. With Leiningen, it connects automatically based
on `target/repl-port`, otherwise it's just a `:Connect` away. 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
on `.nrepl-port`, otherwise it's just a `:Connect` away. 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][].
The only external dependency is that you have either a Vim with Python support
compiled in, or `python` in your path.
Oh, and if you don't have an nREPL connection, installing [classpath.vim][]
lets it fall back to using `java clojure.main`, using a class path based on
your Leiningen or Maven 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.
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 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.
[cider-nrepl]: https://github.com/clojure-emacs/cider-nrepl
[Piggieback]: https://github.com/cemerick/piggieback
[classpath.vim]: https://github.com/tpope/vim-classpath
[salve.vim]: https://github.com/tpope/vim-salve
### Not quite a REPL
@ -68,20 +68,24 @@ cursor. `cqc` gives you a blank line in insert mode.
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. There's a `cp`
operator that evaluates a given motion (`cpp` for the outermost 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.
`: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'm new to Clojure, so stuff that helps me understand code is a top priority.
I was brand new to Clojure when I started this plugin, so stuff that helped me
understand code was a top priority.
* `:Source`, `:Doc`, `:FindDoc`, and `:Apropos`, which map to the underlying
* `:Source`, `:Doc`, and `:FindDoc`, which map to the underlying
`clojure.repl` macro (with tab complete, of course).
* `K` is mapped to look up the symbol under the cursor with `doc`.
@ -104,15 +108,13 @@ Because why not? It works in the quasi-REPL too.
> Why does it take so long for Vim to startup?
See the [classpath.vim FAQ][]. You can uninstall classpath.vim if you only
care about nREPL support.
[classpath.vim FAQ]: https://github.com/tpope/vim-classpath#FAQ
That's either [classpath.vim][] or [salve.vim][].
## Self-Promotion
Like fireplace.vim? Follow the repository on
[GitHub](https://github.com/tpope/vim-fireplace). And if
[GitHub](https://github.com/tpope/vim-fireplace) and vote for it on
[vim.org](http://www.vim.org/scripts/script.php?script_id=4978). And if
you're feeling especially charitable, follow [tpope](http://tpo.pe/) on
[Twitter](http://twitter.com/tpope) and
[GitHub](https://github.com/tpope).

View File

@ -1,4 +1,4 @@
" Fireplace nREPL session
" Location: autoload/nrepl/fireplace.vim
if exists("g:autoloaded_fireplace_nrepl")
finish
@ -33,14 +33,33 @@ function! fireplace#nrepl#for(transport) abort
let client = copy(s:nrepl)
let client.transport = a:transport
let client.session = client.process({'op': 'clone', 'session': 0})['new-session']
let response = client.process({'op': 'eval', 'code':
\ '(do (println "success") (symbol (str (System/getProperty "path.separator") (System/getProperty "java.class.path"))))'})
let client._path = response.value[-1]
if has_key(response, 'out')
let g:fireplace_nrepl_sessions[client.session] = client
else
unlet client.session
let client.describe = client.process({'op': 'describe', 'verbose?': 1})
if get(client.describe.versions.nrepl, 'major', -1) == 0 &&
\ client.describe.versions.nrepl.minor < 2
throw 'nREPL: 0.2.0 or higher required'
endif
" Handle boot, which sets a fake.class.path entry
let response = client.process({'op': 'eval', 'code':
\ '[(System/getProperty "path.separator") (System/getProperty "fake.class.path")]', 'session': ''})
let cpath = response.value[-1][5:-2]
if cpath !=# 'nil'
let cpath = eval(cpath)
if !empty(cpath)
let client._path = split(cpath, response.value[-1][2])
endif
endif
if !has_key(client, '_path') && client.has_op('classpath')
let response = client.message({'op': 'classpath'})[0]
if type(get(response, 'classpath')) == type([])
let client._path = response.classpath
endif
endif
if !has_key(client, '_path')
let response = client.process({'op': 'eval', 'code':
\ '[(System/getProperty "path.separator") (System/getProperty "java.class.path")]', 'session': ''})
let client._path = split(eval(response.value[-1][5:-2]), response.value[-1][2])
endif
let g:fireplace_nrepl_sessions[client.session] = client
return client
endfunction
@ -68,7 +87,7 @@ function! s:nrepl_clone() dict abort
endfunction
function! s:nrepl_path() dict abort
return split(self._path[1:-1], self._path[0])
return self._path
endfunction
function! fireplace#nrepl#combine(responses)
@ -119,7 +138,11 @@ function! s:nrepl_eval(expr, ...) dict abort
if has_key(options, 'session')
let msg.session = options.session
endif
if has_key(options, 'id')
let msg.id = options.id
else
let msg.id = fireplace#nrepl#next_id()
endif
if has_key(options, 'file_path')
let msg.op = 'load-file'
let msg['file-path'] = options.file_path
@ -134,18 +157,21 @@ function! s:nrepl_eval(expr, ...) dict abort
endif
try
let response = self.process(msg)
catch /^Vim:Interrupt$/
if has_key(msg, 'session')
call self.message({'op': 'interrupt', 'session': msg.session, 'interrupt-id': msg.id}, 'ignore')
finally
if !exists('response')
let session = get(msg, 'session', self.session)
if !empty(session)
call self.message({'op': 'interrupt', 'session': session, 'interrupt-id': msg.id}, 'ignore')
endif
throw 'Clojure: Interrupt'
endif
endtry
if has_key(response, 'ns') && !has_key(options, 'ns')
if has_key(response, 'ns') && empty(get(options, 'ns'))
let self.ns = response.ns
endif
if has_key(response, 'ex') && !empty(get(msg, 'session', 1))
let response.stacktrace = s:extract_last_stacktrace(self)
let response.stacktrace = s:extract_last_stacktrace(self, get(msg, 'session', self.session))
endif
if has_key(response, 'value')
@ -154,12 +180,28 @@ function! s:nrepl_eval(expr, ...) dict abort
return response
endfunction
function! s:extract_last_stacktrace(nrepl) abort
let format_st = '(clojure.core/symbol (clojure.core/str "\n\b" (clojure.core/apply clojure.core/str (clojure.core/interleave (clojure.core/repeat "\n") (clojure.core/map clojure.core/str (.getStackTrace *e)))) "\n\b\n"))'
let stacktrace = split(get(split(a:nrepl.process({'op': 'eval', 'code': '['.format_st.' *3 *2 *1]', 'session': a:nrepl.session}).value[0], "\n\b\n"), 1, ""), "\n")
call a:nrepl.message({'op': 'eval', 'code': '(nth *1 1)', 'session': a:nrepl.session})
call a:nrepl.message({'op': 'eval', 'code': '(nth *2 2)', 'session': a:nrepl.session})
call a:nrepl.message({'op': 'eval', 'code': '(nth *3 3)', 'session': a:nrepl.session})
function! s:extract_last_stacktrace(nrepl, session) abort
if a:nrepl.has_op('stacktrace')
let stacktrace = a:nrepl.message({'op': 'stacktrace', 'session': a:session})
if len(stacktrace) > 0 && has_key(stacktrace[0], 'stacktrace')
let stacktrace = stacktrace[0].stacktrace
endif
call filter(stacktrace, 'has_key(v:val, "file")')
if !empty(stacktrace)
return map(stacktrace, 'v:val.class.".".v:val.method."(".v:val.file.":".v:val.line.")"')
endif
endif
let format_st = '(symbol (str "\n\b" (apply str (interleave (repeat "\n") (map str (.getStackTrace *e)))) "\n\b\n"))'
let response = a:nrepl.process({'op': 'eval', 'code': '['.format_st.' *3 *2 *1]', 'ns': 'user', 'session': a:session})
try
let stacktrace = split(get(split(response.value[0], "\n\b\n"), 1, ""), "\n")
catch
throw string(response)
endtry
call a:nrepl.message({'op': 'eval', 'code': '(*1 1)', 'ns': 'user', 'session': a:session})
call a:nrepl.message({'op': 'eval', 'code': '(*2 2)', 'ns': 'user', 'session': a:session})
call a:nrepl.message({'op': 'eval', 'code': '(*3 3)', 'ns': 'user', 'session': a:session})
return stacktrace
endfunction
@ -171,27 +213,26 @@ function! s:nrepl_prepare(msg) dict abort
if !has_key(msg, 'id')
let msg.id = fireplace#nrepl#next_id()
endif
if empty(get(msg, 'ns', 1))
unlet msg.ns
endif
if empty(get(msg, 'session', 1))
unlet msg.session
elseif !has_key(self, 'session')
if &verbose
echohl WarningMSG
echo "nREPL: server has bug preventing session support"
echohl None
endif
unlet! msg.session
elseif !has_key(msg, 'session')
let msg.session = self.session
endif
return msg
endfunction
function! fireplace#nrepl#callback(body, type, fn)
function! fireplace#nrepl#callback(body, type, callback) abort
try
let response = {'body': a:body, 'type': a:type}
if has_key(a:body, 'session')
if has_key(g:fireplace_nrepl_sessions, get(a:body, 'session'))
let response.session = g:fireplace_nrepl_sessions[a:body.session]
endif
call call(a:fn, [response])
call call(a:callback[0], [response] + a:callback[1:-1])
catch
endtry
endfunction
function! s:nrepl_call(msg, ...) dict abort
@ -206,6 +247,10 @@ function! s:nrepl_message(msg, ...) dict abort
return call(self.call, [msg, ['done'], sel] + a:000, self)
endfunction
function! s:nrepl_has_op(op) dict abort
return has_key(self.describe.ops, a:op)
endfunction
let s:nrepl = {
\ 'close': s:function('s:nrepl_close'),
\ 'clone': s:function('s:nrepl_clone'),
@ -213,5 +258,6 @@ let s:nrepl = {
\ 'call': s:function('s:nrepl_call'),
\ 'message': s:function('s:nrepl_message'),
\ 'eval': s:function('s:nrepl_eval'),
\ 'has_op': s:function('s:nrepl_has_op'),
\ 'path': s:function('s:nrepl_path'),
\ 'process': s:function('s:nrepl_process')}

View File

@ -1,5 +1,4 @@
" autoload/nrepl/fireplace_connection.vim
" Maintainer: Tim Pope <http://tpo.pe/>
" Location: autoload/nrepl/fireplace_connection.vim
if exists("g:autoloaded_nrepl_fireplace_connection") || &cp
finish
@ -14,15 +13,19 @@ endfunction
" Bencode {{{1
function! nrepl#fireplace_connection#bencode(value) abort
function! fireplace#nrepl_connection#bencode(value) abort
if type(a:value) == type(0)
return 'i'.a:value.'e'
elseif type(a:value) == type('')
return strlen(a:value).':'.a:value
elseif type(a:value) == type([])
return 'l'.join(map(copy(a:value),'nrepl#fireplace_connection#bencode(v:val)'),'').'e'
return 'l'.join(map(copy(a:value),'fireplace#nrepl_connection#bencode(v:val)'),'').'e'
elseif type(a:value) == type({})
return 'd'.join(values(map(copy(a:value),'nrepl#fireplace_connection#bencode(v:key).nrepl#fireplace_connection#bencode(v:val)')),'').'e'
return 'd'.join(map(
\ sort(keys(a:value)),
\ 'fireplace#nrepl_connection#bencode(v:val) . ' .
\ 'fireplace#nrepl_connection#bencode(a:value[v:val])'
\ ),'').'e'
else
throw "Can't bencode ".string(a:value)
endif
@ -34,14 +37,7 @@ function! s:shellesc(arg) abort
if a:arg =~ '^[A-Za-z0-9_/.-]\+$'
return a:arg
elseif &shell =~# 'cmd'
if &shellxquote ==# '"'
return '"' . substitute(a:arg, '"', '""', 'g') . '"'
else
let esc = exists('+shellxescape') ? &shellxescape : '"&|<>()@^'
return &shellxquote .
\ substitute(a:arg, '['.esc.']', '^&', 'g') .
\ get({'(': ')', '"(': ')"'}, &shellxquote, &shellxquote)
endif
throw 'Python interface not working. See :help python-dynamic'
else
let escaped = shellescape(a:arg)
if &shell =~# 'sh' && &shell !~# 'csh'
@ -61,11 +57,11 @@ function! s:id() abort
return 'fireplace-'.hostname().'-'.s:vim_id.'-'.s:id
endfunction
function! nrepl#fireplace_connection#prompt() abort
function! fireplace#nrepl_connection#prompt() abort
return fireplace#input_host_port()
endfunction
function! nrepl#fireplace_connection#open(arg) abort
function! fireplace#nrepl_connection#open(arg) abort
if a:arg =~# '^\d\+$'
let host = 'localhost'
let port = a:arg
@ -95,7 +91,7 @@ function! s:nrepl_transport_command(cmd, args) dict abort
\ . ' ' . s:shellesc(self.port)
\ . ' ' . s:shellesc(s:keepalive)
\ . ' ' . s:shellesc(a:cmd)
\ . ' ' . join(map(copy(a:args), 's:shellesc(nrepl#fireplace_connection#bencode(v:val))'), ' ')
\ . ' ' . join(map(copy(a:args), 's:shellesc(fireplace#nrepl_connection#bencode(v:val))'), ' ')
endfunction
function! s:nrepl_transport_dispatch(cmd, ...) dict abort
@ -108,12 +104,12 @@ function! s:nrepl_transport_dispatch(cmd, ...) dict abort
endfunction
function! s:nrepl_transport_call(msg, terms, sels, ...) dict abort
let payload = nrepl#fireplace_connection#bencode(a:msg)
let payload = fireplace#nrepl_connection#bencode(a:msg)
let response = self.dispatch('call', payload, a:terms, a:sels)
if !a:0
return response
elseif a:1 !=# 'ignore'
return map(response, 'fireplace#nrepl#callback(v:val, "synchronous", a:1)')
return map(response, 'fireplace#nrepl#callback(v:val, "synchronous", a:000)')
endif
endfunction

View File

@ -1,9 +0,0 @@
" Vim compiler file
if exists("current_compiler")
finish
endif
let current_compiler = "lein"
CompilerSet makeprg=lein
CompilerSet errorformat=%+G,fireplace

View File

@ -1,4 +1,4 @@
*fireplace.txt* Clojure REPL tease
*fireplace.txt* Clojure REPL support
Author: Tim Pope <http://tpo.pe/>
License: Same terms as Vim itself (see |license|)
@ -6,7 +6,8 @@ License: Same terms as Vim itself (see |license|)
This plugin is only available if 'compatible' is not set.
*fireplace*
You need Clojure runtime files to use this plugin. Try vim-clojure-static.
While not strictly necessary, this plugin works best with the middleware
provided by <https://github.com/clojure-emacs/cider-nrepl>.
CONNECTING TO A REPL *fireplace-connect*
@ -22,35 +23,31 @@ you can connect by hand.
REPL server.
The REPL is used for the commands below. If no REPL is found for the current
buffer and classpath.vim is installed, java (or $JAVA_CMD) is invoked
directly, which can be quite slow depending on your setup.
buffer and 'path' contains at least one jar file, java (or $JAVA_CMD) is
invoked directly, which can be quite slow depending on your setup.
The only adapter shipped with fireplace.vim is for nREPL. You need either
|if_pyth| or the python command in your PATH.
*fireplace-piggieback* *fireplace-clojurescript*
ClojureScript is can be evaled with Piggieback if the appropriate nREPL
middleware is loaded. https://github.com/cemerick/piggieback. Be aware that
ClojureScript can be evaled with Piggieback if the appropriate nREPL
middleware is loaded: https://github.com/cemerick/piggieback. Be aware that
your ClojureScript files must be available on the classpath for this to work
properly.
properly, and that not all operations are supported.
*fireplace-:Piggieback*
:Piggieback [{env}] Create a new nREPL session and invoke
cemerick.piggieback/cljs-repl with the given or
default (Rhino) environment. This will also happen
automatically on first eval in a ClojureScript buffer
if not invoked explicitly.
if not invoked explicitly. If {env} is a number, the
piggieback repl-env will will use a cljs.repl.browser
(rather than a Rhino) env with the port set to the
number provided.
:Piggieback! Terminate the most recently created piggieback
session.
LEININGEN *fireplace-leiningen*
In addition to automatic repl connection, Clojure buffers in a Leiningen
project will automatically have their 'makeprg' set to lein and 'efm' set to
"%+G,fireplace". This combination enables `:make test` to run `lein test` and
parse the stacktraces in the results.
DOCUMENTATION *fireplace-documentation*
*fireplace-:Doc*
@ -60,19 +57,16 @@ DOCUMENTATION *fireplace-documentation*
:Javadoc {class} Open the java docs for the given class in a browser.
*fireplace-K*
K Look up docs for keyword under cursor.
K Look up docs for symbol under cursor.
*fireplace-:FindDoc*
:FindDoc {arg} Wrapper around (clojure.repl/find-doc ...).
*fireplace-:Apropos*
:Apropos {arg} Wrapper around (clojure.repl/apropos ...).
*fireplace-:Source*
:Source {symbol} Show the source for the given symbol.
*fireplace-[d*
[d Show source for keyword under cursor.
[d Show source for symbol under cursor.
]d
NAVIGATING *fireplace-navigating*
@ -81,11 +75,11 @@ These commands will never use a remote REPL, only a local one, as file paths
on a remote server wouldn't be very useful locally.
*fireplace-[_CTRL-D*
[<C-D> Jump to the source of the keyword under the cursor.
[<C-D> Jump to the source of the symbol under the cursor.
]<C-D>
*fireplace-CTRL-W_CTRL-D*
<C-W><C-D> Jump to the source of the keyword under the cursor in
<C-W><C-D> Jump to the source of the symbol under the cursor in
<C-W>d a split.
*fireplace-gf*
@ -98,21 +92,6 @@ gf Go to the file for the namespace under the cursor.
:Dsplit {symbol} Jump to the definition for the given symbol in a
split.
*fireplace-:A*
:A In a test file, edit the implementation, and vice
versa. Basically adds or removes -test from the end
of the current namespace and searches for it in the
class path.
*fireplace-:AS*
:AS Like :A, but in a split.
*fireplace-:AV*
:AV Like :A, but in a vertical split.
*fireplace-:AT*
:AT Like :A, but in a tab.
EVALUATING CODE *fireplace-eval*
All code is evaluated in the namespace of the current file, requiring it if
@ -127,8 +106,7 @@ stack trace is loaded into the |location-list|. Use |:lopen| to view it.
:Require! [ns] Require :reload-all the given/current namespace.
*fireplace-:Eval*
:Eval Eval/print the outermost expression for the current
line.
:Eval Eval/print the outermost form for the current line.
:{range}Eval Eval/print the given range.
@ -141,13 +119,25 @@ stack trace is loaded into the |location-list|. Use |:lopen| to view it.
:[range]Eval! {expr} Eval the given expression and insert it after
the given range or current line.
*fireplace-:RunTests*
:RunTests [ns] [...] Call clojure.test/run-tests on the given namespaces
and load the results into the quickfix list.
:[range]RunTests Call clojure.test/test-var on the var defined at or
above the specicied line and load the results into the
quickfix list. Typically invoked as :.RunTests to run
the test under the cursor.
:0RunTests [pattern] Call clojure.test/run-all-tests with the given pattern
and load the results into the quickfix list.
*fireplace-cp*
cp{motion} Eval/print the code indicated by {motion}.
cpp Eval/print the outermost form at the cursor.
cpp Eval/print the innermost form at the cursor.
*fireplace-cpr*
cpr Eval a require :reload form.
cpr :Require|RunTests
*fireplace-c!*
c!{motion} Eval/replace the code indicated by {motion}.
@ -169,6 +159,10 @@ c1mm Macroexpand the innermost form at the cursor once.
*fireplace-cqp*
cqp Bring up a prompt for code to eval/print.
*fireplace-cqq*
cqq Bring up a |command-line-window| with innermost form
at the cursor prepopulated.
*fireplace-cqc*
cqc Bring up a |command-line-window| for code to
eval/print. Equivalent to cqp<C-F>i.

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,13 @@
" fireplace/zip.vim: zip.vim monkey patch to allow access from quickfix
" Maintainer: Tim Pope <http://tpo.pe>
" Location: plugin/fireplace/zip.vim
if exists("g:loaded_zip") || &cp
if exists("g:loaded_zip") || &cp || v:version >= 704
finish
endif
runtime! autoload/zip.vim
" Copied and pasted verbatim from autoload/zip.vim.
" Patched to allow loading from the quickfix list. The version that ships
" with Vim 7.4 already has this change.
fun! zip#Read(fname,mode)
" call Dfunc("zip#Read(fname<".a:fname.">,mode=".a:mode.")")

View File

@ -4,7 +4,10 @@ import select
import socket
import sys
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
def noop():
pass
@ -46,12 +49,12 @@ def bdecode(f, char=None):
key = bdecode(f, char)
d[key] = bdecode(f)
elif char == 'i':
i = 0
i = ''
while True:
char = f.read(1)
if char == 'e':
return i
i = 10 * i + int(char)
return int(i)
i += char
elif char.isdigit():
i = int(char)
while True:
@ -84,13 +87,16 @@ class Connection:
return self.socket.close()
def send(self, payload):
if sys.version_info[0] >= 3:
self.socket.sendall(bytes(payload, 'UTF-8'))
else:
self.socket.sendall(payload)
return ''
def receive(self, char=None):
while len(select.select([self.socket], [], [], 0.1)[0]) == 0:
self.poll()
f = self.socket.makefile()
while len(select.select([f], [], [], 0.1)[0]) == 0:
self.poll()
try:
return bdecode(f)
finally:
@ -118,8 +124,8 @@ def dispatch(host, port, poll, keepalive, command, *args):
def main(host, port, keepalive, command, *args):
try:
sys.stdout.write(vim_encode(dispatch(host, port, noop, keepalive, command, *[bdecode(StringIO(arg)) for arg in args])))
except Exception, e:
print(e)
except Exception:
print((sys.exc_info()[1]))
exit(1)
if __name__ == "__main__":