Code Monkey home page Code Monkey logo

vim-fireplace's Introduction

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 underlying clojure.repl macro (with tab complete, of course).

  • K is mapped to look up the symbol under the cursor with doc.

  • [d is mapped to look up the symbol under the cursor with source.

  • [<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.

vim-fireplace's People

Contributors

apage43 avatar benmoss avatar brandonbloom avatar christoph-frick avatar codewhale avatar cursork avatar deraen avatar dhleong avatar frenchy64 avatar jgdavey avatar junegunn avatar justone avatar kul avatar mikepjb avatar mluts avatar mraveloarinjaka avatar nberger avatar ohpauleez avatar philomates avatar r6eve avatar rafd avatar rasmusto avatar raymond-w-ko avatar rbxbx avatar rm-hull avatar rmschindler avatar severeoverfl0w avatar sumbach avatar tamstrup avatar tpope avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-fireplace's Issues

"Oneoff" eval uses incomplete classpath

Exciting project, Tim!

I ran into trouble using the non-nREPL interactive mode (which shells out to java clojure.main). When I make an interactive call (K for doc lookup, e.g.) I get an error message that java couldn't find the class clojure.main.

I've narrowed things down to the classpath used in the function oneoff.eval: it's incomplete with respect to the value of &path in the buffer. I believe oneoff.eval gets its classpath from foreplay#local_client, which passes the buffer's &path variable through classpath#from_vim. My Vimscript regex knowledge is too shallow to understand what this last function is doing exactly, but the effect is that the classpath it returns doesn't include any of the jar files, only my source directories. So java complains that it can't find clojure.main because the Clojure jar isn't on the classpath.

I think the solution is as simple as including the full classpath (as stored in &path) in the output of classpath#from_vim, but maybe I'm missing something.

cp truncates output

Vim's handling of :echo inside an 'operatorfunc' results in the result of the operation clobbering anything output to *out* or *err*.

Error evaluating code

When trying to evaluate code, for example from the prompt (i.e. cqp) this error is thrown:

Error detected while processing function <SNR>30_inputeval..foreplay#evalprint..foreplay#eval..<SNR>30_eval..170:
line    7:                                                                                                                                                               
E121: Undefined variable: options
E116: Invalid arguments for function s:qsym(options).') (in-ns '.s:qsym(options).') '
E15: Invalid expression: '(require '.s:qsym(options).') (in-ns '.s:qsym(options).') '
Error detected while processing function <SNR>30_inputeval:
line    4:
E171: Missing :endif

Looks like the offending commit is https://github.com/tpope/vim-foreplay/commit/e62540fef9189229ac6239ef0a0d6dd8a5666b8e since resetting the code to the previous commit solved the problem for me.

Workaround:
git reset --hard 39d1e29
HEAD is now at 39d1e29 Defend against broken g:FOREPLAY_HISTORY

I'm running OS X 10.8.2, VIM - Vi IMproved 7.3 and vim-pathogen (commit da1c3c0) to load the plugin.

Eval breaks source mapping // goto-definition

If one file (a.clj) references something in another file (b/some-fn from b.clj), foreplay allows you to Goto-Definition.

However, if you Eval b.clj, Goto-Definition from within a.clj fails with:
Couldn't find source for b/some-fn:

The problem persists even when closing vim and reconnecting to the running nREPL server.

Option to not show location list

Between the all the noise in Clojure stack traces and the fact that the message from the exception is not displayed, automatically opening the location list is more of a distraction for me. Could we have an option to not show it automatically?

Can't eval code from file outside of project tree

I have a project at ~/main-project/. I can fire up a lein repl, load ~/main-project/src/proj.clj in Vim, & can evaluate code snippets or require the file over the nREPL connection foreplay discovered by reading target/repl-port (8080, let's say).

But let's say I have a file at ~/Desktop/scratch.clj that I'd like to evaluate against the same nREPL server. I call :Connect nrepl://localhost:8080 to establish the connection. But when I try to to evaluate code (snippets, or the whole file with :%Eval), I get this error:

Error detected while processing function 20_print_last..foreplay#eval..4:
line 32:
E605: Exception not caught: Error running Clojure: Exception in thread "main" java.lang.NoClassDefFoundError: clojure/main^@caused by: java.lang.ClassNotFoundException: clojure.main [truncated]

which shows that, I believe, the "oneoff" client is being used (as opposed to the nREPL server I intended to use with my :Connect call) & that it doesn't have the proper classpath info, as there's no Clojure jar found (& indeed: :set path? gives path=,).

Am I right to think calling :Connect from outside the project tree should've worked?

:Doc and `K` don't work after trying to use them on Clojure source

  1. Start an nREPL.
  2. Start Vim.
  3. [<c-d> on a clojure.core form.
  4. Try K on something there.

It fails with the message "CompilerException java.lang.RuntimeException: No such var: clojure.core/doc, compiling:(NO_SOURCE_PATH:1)". And it continues to fail with the same message once back to my own code. It fails until I start a new nREPL and connect to that.

:Doc suffers the same fate.

[Controversial] Auto-open and auto-close the quick fix list

I have this change in my fork, at it seems to work okay.

Basically it auto-opens the quick fix list if there is an error and and auto-closes it when it detects that the stack trace is empty.

Since this can change window arrangement, I can see how some people won't want this.

What is your opinion on this? Should the quick fix list be something that the user explicitly manages? Since a Vim Tab / Viewport doesn't have a singular quick fix window like :help XXX it seems to me that this should be more handy than not.

diff --git a/plugin/foreplay.vim b/plugin/foreplay.vim
index c31e4f8..ccb6411 100644
--- a/plugin/foreplay.vim
+++ b/plugin/foreplay.vim
@@ -425,6 +434,11 @@ function! foreplay#eval(expr) abort

   if !empty(get(response, 'stacktrace', []))
     call setloclist(0, foreplay#quickfix_for(response.stacktrace))
+    lopen
+    wincmd W
+  else
+    call setloclist(0, [])
+    lclose
   endif

   if get(response, 'ex', '') !=# ''

Improve error message when namespace not found.

I had the problem that in my "project.clj" :source-paths contained the vector ["src" "src/main/clojure"].

vim-foreplay took this to mean my source is in "src", my namespace starts with "main.clojure".

The repl was returning "namespace not found", and "main.clojure.my-ns", but the error message was simply "{}".

function! s:nrepl_eval(expr, ...) dict abort
    ...
    ...
    let err = 'nREPL: '.string(packet) ; <- line 143: here could do with more info on the error.

No way to access *e, *1, *2, *3, etc

Seems like each successive :Eval is in it's own little world. If I get an exception, I often write (.printStackTrace *e), but after an exception :Eval *e is nil.

Test unit runner

Not sure what the best option is for this but, I've programmed the following which seems to run tests for everything loaded into the REPL;

map ,t :w<CR>:Require<CR>:call fireplace#echo_session_eval("(run-all-tests)")<CR>

Mention somewhere in the documentation where you can get zipinfo.exe

Since Windows lacks zipinfo.exe by default mention somewhere that they can get this from

http://gnuwin32.sourceforge.net/packages/unzip.htm

I have this extracted to C:\Windows and it seems to work fine (stack traces now have origin .jar file when part of the trace is in a .clj file)

Can't evaluate in file without namespace

I sometimes split my namespaces in different files, using (in-ns) in all but one file, and loading the parts from the main file.

If I try to evaluate code in a file without (ns) form but with (in-ns) form I get

"Exception No namespace: the-path-turned-into-ns found clojure.core/the-ns (core.clj:3691)"

Opt in instead of loading on load of a .clj file

foreplay is awesome, but a lot of the time I want to make a trivial change. Sacrificing a few seconds for an edit I can do in less than that kinda sucks, how do you feel about deferring init until you actually ask for something to happen,

ie, getting everything that depends on nrepl to lazy load a cached connection?

Incorrect behavior of K on capital words

K will assume that anything beginning with a capital letter is Java and should be looked up with :Javadoc. While this is often correct, we do occasionally seem fns/macros in the wild that begin with capital letters (ie: POST from compojure).

Not sure of a good way to differentiate between the two without interrogating a clj process.

Thoughts?

Parse stack traces

Challenges:

  1. Parsing itself is kind of a bitch (but I have a proof of concept.)
  2. How do we get our hands on the stack trace from nREPL? We could eval *e, but that has side effects (e.g., *1 changes).
  3. The zipfile plugin screws up the line number if you try to jump to a specific line in a zipped file from the quick fix.

I mainly need help with 2.

Error when trying to talk to lein repl

I am experiencing this error when trying to run :%Eval with a lein repl running. Here's the setup:

Ubuntu 12.10

term1 in /path/to/project/
lein repl

term2 in /path/to/project/src/subdir/
vim file.clj
with proper ns in file
:%Eval

error:

Error detected while processing function <SNR>21_Eval..foreplay#echo_session_eval..foreplay#session_eval..<SNR>21_eval..2..<SNR>42_nrepl_eval..<SNR>42_nrepl_process:
line   28:
E605: Exception not caught: nREPL: namespace not found
Error detected while processing function <SNR>21_Eval:
line   33:
E171: Missing :endif

The work around I am currently using is to stop the lein repl, then :%Eval, wait for it to finish, then start the lein repl. Then everything works great. The issue is the same if I use other commands like cpp to send code to the repl. I have also tried using a :Connect command to connect to lein repl in the defunct state, and that command appears to work, but I still get the same error when trying to send code to the repl.

Support for :source-paths in project.clj

vim-foreplay and presumably classpath.vim does not seem to handle changes to :source-paths gracefully. To reproduce simply run lein new foreplay-bug, move ./foreplay-bug/src/ to ./foreplay-bug/sources/ and use the following foreplay-bug/project.clj:

(defproject foreplay-bug "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
  :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.4.0"]]
  :source-paths ["sources"])

If you edit ./sources/foreplay_bug/core.clj and run cpR the following error is thrown:

(require 'foreplay-bug.core :reload-all)
Error detected while processing function <SNR>56_Require..foreplay#eval_pr_str..    <SNR>56_eval..372:
line   38:
E605: Exception not caught: Error running Clojure: Error: Could not find or load main class clojure.main^@ 

I had a short look at classpath.vim, but couldn't immediately fix the issue. lein classpath does contain foreplay-bug/sources/ and it is no problem to use the namespace in the REPL:

$ lein repl
...
user=> (use 'foreplay-bug.core)
nil

Error with scala buffer

Why is foreplay messing around with scala files? I did
cd ~/.vim/pathogen ( since pathogen#infect('pathogen/{}') )
git clone git://github.com/tpope/vim-foreplay.git
git clone git://github.com/tpope/vim-classpath.git
vim core/src/main/scala/spark/api/python/PythonPartitioner.scala

"core/src/main/scala/spark/api/python/PythonPartitioner.scala" 48L, 1442C

Couldn't determine class path.

[INFO] Scanning for projects...

[INFO] ------------------------------------------------------------------------

[ERROR] BUILD ERROR

[INFO] ------------------------------------------------------------------------

[INFO] Error resolving version for 'net.alchim31.maven:scala-maven-plugin': Plugin requires Maven version 3.0

[INFO] ------------------------------------------------------------------------

[INFO] For more information, run Maven with the -e switch

[INFO] ------------------------------------------------------------------------

[INFO] Total time: < 1 second

[INFO] Finished at: Fri Feb 22 16:48:39 IST 2013

[INFO] Final Memory: 5M/239M

[INFO] ------------------------------------------------------------------------

Support interrupt with if_python

This trick lets you interrupt if_python:

:python for i in range(10): time.sleep(1); vim.eval("getchar(1)")

This seems like it could maybe be adapted to the nREPL adapter, only using select with a timeout rather than sleep. @raymond-w-ko, what do you think?

What kind of dark magic are you doing with the command line window?

I have nnoremap <cr> :w<cr> set. This hinders using return in the command-line-window. So I have also set autocmd CmdwinEnter : nnoremap <buffer> <cr> <cr>.

But vim-fireplace's command line window doesn't respect the fix. I've also tried autocmd BufReadPost nofile nnoremap <buffer> <cr> <cr> to no avail.

Is there some special buffer type that I need to be targeting, or is this conditional remap just not possible currently?

Make command hangs // ctrl-c needed to return

When in a project, if I run :make or append a lein command ala :make check I have to ctrl-c once the lein JVMs spin down to get back into vim.

The behavior I'd expect is the standard:
Press ENTER or type command to continue

However, once I return to vim, the information is available in the quickfix view (as expected)

Feature Request: Show function arglist in status bar

One of my favorite SLIMV features is that when you type a function name and press space in insert mode it will show the arglist in the status bar for you. It's really handy for remembering the order of arguments. Any chance we can get something like that in Foreplay?

Example:

1

2

Running 'cpR' doesn't load new definitions

Maybe this is working as intended, but I expected running cpR would reload the entire current namespace, including new definitions. Instead, I get the following behavior:

If I have a core namespace which has a :use directive for a second namespace, then add new definitions to the second namespace and reload it, those new definitions aren't visible to the REPL. Using :reload-all has no effect.

Not working on new install

Hi. I downloaded all the packages (vim-sensible, vim-foreplay, vim-classpath, vim-closure-static) as instructed. Now when I try to open a file (core.clj) under cygwin I get this error in gvim: "Error detected while processing function classpath#detect" "E484: Can't open file C:/cygwin/tmp/VIo15BA.tmp".

None of vim-foreplay features work. Any idea? Thx.

:Require fails if ns has metadata

If the ns form has metadata (for doc strings, for example) :Require fails:

(require (symbol "^") :reload)
Error detected while processing function <SNR>45_Require..foreplay#eval..163..<SNR>91_n
repl_eval..<SNR>91_nrepl_process:
line   26:
E605: Exception not caught: nREPL: namespace not found

Most of the seesaw namespaces have this issue, for example: https://github.com/daveray/seesaw/blob/develop/src/seesaw/action.clj

This also happens if you try to eval in a namespace like this, use the quasi-repl, etc. Cheers.

Support ClojureScript

We're discussing this in IRC now, but I just wanted to have a place to stash notes.

ClojureScript currently needs https://github.com/cemerick/piggieback to be nREPL compatible.

See this gist for how to get a minimal CLJS nREPL: https://gist.github.com/4262975

ClojureScript doesn't provide require and only sort-of provides in-ns (it's special cased, so (in-ns 'foo) works, but (do (in-ns 'foo)) won't).

Similarly, there is no load-file, but it looks like Piggieback provides an equivalent via some nREPL mechanism: https://github.com/cemerick/piggieback/blob/master/src/cemerick/piggieback.clj#L196

"Couldn't determine class path" error.

Hi, thanks for great plugin! I'm using it for a while and sometimes it can't determine classpath.

For example here is lein classpath output for my current project

/home/gnzh/mydev/clojure-playground/charts-compojure-by/test:/home/gnzh/mydev/clojure-playground/charts-compojure-by/src/clj:/home/gnzh/mydev/clojure-playground/charts-compojure-by/dev-resources:/home/gnzh/mydev/clojure-playground/charts-compojure-by/resources:/home/gnzh/mydev/clojure-playground/charts-compojure-by/target/classes:/home/gnzh/.m2/repository/com/google/guava/guava/13.0.1/guava-13.0.1.jar:/home/gnzh/.m2/repository/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar:/home/gnzh/.m2/repository/args4j/args4j/2.0.16/args4j-2.0.16.jar:/home/gnzh/.m2/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar:/home/gnzh/.m2/repository/org/apache/ant/ant-launcher/1.8.2/ant-launcher-1.8.2.jar:/home/gnzh/.m2/repository/jayq/jayq/2.3.0/jayq-2.3.0.jar:/home/gnzh/.m2/repository/org/clojure/data.xml/0.0.7/data.xml-0.0.7.jar:/home/gnzh/.m2/repository/clout/clout/1.0.1/clout-1.0.1.jar:/home/gnzh/.m2/repository/org/clojure/core.incubator/0.1.0/core.incubator-0.1.0.jar:/home/gnzh/.m2/repository/com/fasterxml/jackson/dataformat/jackson-dataformat-smile/2.1.2/jackson-dataformat-smile-2.1.2.jar:/home/gnzh/.m2/repository/korma/korma/0.3.0-RC4/korma-0.3.0-RC4.jar:/home/gnzh/.m2/repository/com/google/protobuf/protobuf-java/2.4.1/protobuf-java-2.4.1.jar:/home/gnzh/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.1.3/jackson-core-2.1.3.jar:/home/gnzh/.m2/repository/org/clojure/clojurescript/0.0-1586/clojurescript-0.0-1586.jar:/home/gnzh/.m2/repository/org/clojure/tools.macro/0.1.0/tools.macro-0.1.0.jar:/home/gnzh/.m2/repository/commons-io/commons-io/2.1/commons-io-2.1.jar:/home/gnzh/.m2/repository/com/google/javascript/closure-compiler/r2180/closure-compiler-r2180.jar:/home/gnzh/.m2/repository/cheshire/cheshire/5.0.2/cheshire-5.0.2.jar:/home/gnzh/.m2/repository/clj-time/clj-time/0.4.4/clj-time-0.4.4.jar:/home/gnzh/.m2/repository/ring/ring-core/1.1.7/ring-core-1.1.7.jar:/home/gnzh/.m2/repository/org/clojure/tools.logging/0.2.6/tools.logging-0.2.6.jar:/home/gnzh/.m2/repository/org/clojure/clojure/1.5.0/clojure-1.5.0.jar:/home/gnzh/.m2/repository/log4j/log4j/1.2.15/log4j-1.2.15.jar:/home/gnzh/.m2/repository/hiccup/hiccup/1.0.2/hiccup-1.0.2.jar:/home/gnzh/.m2/repository/org/mozilla/rhino/1.7R4/rhino-1.7R4.jar:/home/gnzh/.m2/repository/commons-codec/commons-codec/1.6/commons-codec-1.6.jar:/home/gnzh/.m2/repository/compojure/compojure/1.1.5/compojure-1.1.5.jar:/home/gnzh/.m2/repository/org/clojure/java.jdbc/0.2.2/java.jdbc-0.2.2.jar:/home/gnzh/.m2/repository/joda-time/joda-time/2.1/joda-time-2.1.jar:/home/gnzh/.m2/repository/org/clojure/google-closure-library/0.0-2029-2/google-closure-library-0.0-2029-2.jar:/home/gnzh/.m2/repository/com/googlecode/jarjar/jarjar/1.1/jarjar-1.1.jar:/home/gnzh/.m2/repository/postgresql/postgresql/9.0-801.jdbc4/postgresql-9.0-801.jdbc4.jar:/home/gnzh/.m2/repository/org/clojure/google-closure-library-third-party/0.0-2029-2/google-closure-library-third-party-0.0-2029-2.jar:/home/gnzh/.m2/repository/ring-mock/ring-mock/0.1.3/ring-mock-0.1.3.jar:/home/gnzh/.m2/repository/org/apache/ant/ant/1.8.2/ant-1.8.2.jar:/home/gnzh/.m2/repository/org/json/json/20090211/json-20090211.jar:/home/gnzh/.m2/repository/commons-fileupload/commons-fileupload/1.2.1/commons-fileupload-1.2.1.jar:/home/gnzh/.m2/repository/c3p0/c3p0/0.9.1.2/c3p0-0.9.1.2.jar

But vim still can't figure out classpath.
Can it be caused by lein-drip plugin?
Any advice? Thank you!

Require namespace before going to file

Currently attempting to gf a symbol without previously requiring the namespace blows up in an ugly way:

Error detected while processing function <SNR>31_GF..foreplay#findfile..<SNR>31_eval..2..<SNR>48_nrepl_eval..<SNR>48_nrepl_process:
line   28:
E605: Exception not caught: nREPL: namespace not found
Error detected while processing function <SNR>31_GF..foreplay#findfile:
line   17:
E171: Missing :endif

Possible solution would be to remember whether a buffer was required at least once, and if not require it before performing find-file.
Alternatively, catch the exception and provide a better error message ("You must :Require your namespace to go to files").

Teach K about javadoc

Is a simple regex to check for an uppercase letter following the final dot sufficient?

REPL doesn't load correct namespace

I've created a test project via leiningen and when editing foreplay-test.core, the command cqp loads the namespace foreplan-test which doesn't exist.

Any attempts to interact with it causes a java.io.FileNotFoundException Could not locate foreplay_test__init.class or foreplay_test.clj on classpath:

Screen Shot 2013-01-02 at 17 13 01

Really excited by this plugin, thanks for sharing!

:Eval doesn't always find top-level sexp

Here's some test code:

(defn top-level-test [arg]
  (let [a 1]              
    (println a)           
    10))                  

With the cursor on (defn, (let, or 10, a call to :Eval successfully evaluates the whole form, but when the cursor is on (println, it fails with an "EOF while reading" exception.

If I call :call searchpair('(','',')','bcr', foreplay#skip) with the cursor at each position (including at (println), I'm correctly taken back to the (defn position; it looks like the problem is in determining line2.

Possible solution: removing the 'n' option from the searchpair calls (so the second call happens with the cursor on the outermost opening paren), but remembering & restoring cursor position at the time of the :Eval invocation.

Cache the result of the check for 'zipinfo' so that minimize input lag when a stack trace needs to be processed.

Mainly affects Windows system due to slow (?) executable lookup and the fact there are many directories in PATH usually. Not like UNIX where the majority is in '/usr/bin;/bin/' etc.

diff --git a/plugin/foreplay.vim b/plugin/foreplay.vim
index c31e4f8..ccb6411 100644
--- a/plugin/foreplay.vim
+++ b/plugin/foreplay.vim
@@ -26,7 +26,10 @@ endfunction
 let s:jar_contents = {}

 function! foreplay#jar_contents(path) abort
-  if !has_key(s:jar_contents, a:path) && executable('zipinfo')
+  if !has('g:foreplay_has_zipinfo')
+    let g:foreplay_has_zipinfo = executable('zipinfo')
+  endif
+  if !has_key(s:jar_contents, a:path) && g:foreplay_has_zipinfo
     let s:jar_contents[a:path] = split(system('zipinfo -1 '.shellescape(a:path)), "\n")
     if v:shell_error
       return []

Conflict with Command-T

Using the nREPL client with the automatic connection based on the target/repl-port file, I'm failing to connect & receiving an error message when opening the first Clojure file with Command-T.

I start an nREPL server with target/repl-port containing its port, fire up vim, invoke Command-T to find & open a Clojure file, then get this message:

Error detected while processing function 20_leiningen_init..20_leiningen_connect..nrepl#foreplay_connection#open..60_nrepl_eval..60_nrepl_process..60_nrepl_call:
line 19:
NoMethodError: undefined method `command' for CommandT::VIM:Module

I've traced the foreplay call path from the message & nothing stands out to me, & this could certainly just be a bug with Command-T, but I open this issue on the off chance something strikes you. (You helped me identify the source of my last problem, & no good deed goes unpunished, &c.)

I can manually :Connect with the nREPL server without a problem, & if I do this subsequent calls to Command-T do not raise the error above. If I open the first Clojure file w/o the help of Command-T, same thing: the automatic connection is established & subsequent calls to Command-T are fine.

Configure standart repl target without project

I like to experiment with clojure but don't need to set up a project every time I write a few lines. It is not quite clear to me how I can set up foreplay to use my open nrepl server so I don't have to :Connect every time.

Would you mind to share your knowledge with me? 🙏

gf/ctlr-o clobbers iskeyword

I'm not sure this is a foreplay for vim-clojure-static issue (cc @guns), but switching files with gf and then switching back seems to clobber the keyword setting.

First I open a clojure buffer. iskeyword looks like:

  iskeyword=@,48-57,_,192-255,?,-,*,!,+,/,=,<,>,.,:,$
    Last set from ~/.vim/bundle/vim-clojure-static/syntax/clojure.vim

Next, I hit gf on a namespace to move to another one. iskeyword on the new buffer also looks good:

  iskeyword=@,48-57,_,192-255,?,-,*,!,+,/,=,<,>,.,:,$
    Last set from ~/.vim/bundle/vim-clojure-static/syntax/clojure.vim

Now ctrl-o back to the original buffer and iskeyword is now:

  iskeyword=@,48-57,_,192-255
    Last set from /Applications/MacVim.app/Contents/Resources/vim/runtime/ftplugin.vim

I intentionally removed paredit.vim to make sure it wasn't the culprit.

Problems on Windows

When I run, for example, :Doc reverse without an nrepl, I get the error java.lang.RuntimeException: Unsupported escape character: \U (from the clojure reader) and when I have connected, the nrepl says the following. (Same with cqp1)

user=> Exception in thread "nREPL-worker-0" java.lang.NullPointerException
at clojure.core$refer.doInvoke(core.clj:3779)
at clojure.lang.RestFn.applyTo(RestFn.java:139)
at clojure.core$apply.invoke(core.clj:603)
at clojure.core$load_lib.doInvoke(core.clj:5279)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:603)
at clojure.core$load_libs.doInvoke(core.clj:5298)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:605)
at clojure.core$use.doInvoke(core.clj:5392)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.main$repl.doInvoke(main.clj:259)
at clojure.lang.RestFn.invoke(RestFn.java:1096)
at clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__1145.invoke(interruptible_eval.clj:51)
at clojure.lang.AFn.applyToHelper(AFn.java:159)
at clojure.lang.AFn.applyTo(AFn.java:151)
at clojure.core$apply.invoke(core.clj:601)
at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1771)
at clojure.lang.RestFn.invoke(RestFn.java:425)
at clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invoke(interruptible_eval.clj:36)
at clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__1182$fn__1184.invoke(interruptible_eval.clj:164)
at clojure.core$comp$fn__4034.invoke(core.clj:2278)
at clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__1175.invoke(interruptible_eval.clj:131)
at clojure.lang.AFn.run(AFn.java:24)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Capture the Output

Currently when eval'ing code or looking up the source or documentation for a symbol, the result is echoed as a message. There's not a way (as far as I know) to capture this output for later use, to yank it or to throw it in a buffer. Especially for eval'd code, when there could be an error message printed or a large return value, this is important.

The foreplay ! eval variants, which replace an expression with its value, offer a way to capture output if you don't mind losing the original expression (say if you're working from a scratch buffer as your REPL replacement), but they don't let you capture stuff that's printed (not returned).

Ideas on how to do this? VimClojure opens a buffer for its results. I understand foreplay's use of messages rather than buffers to be part of its more native-feeling Vim integration, but I wonder if there's a way to have both things (integration & capturing output). It's an important feature, at least for my workflow.

Thanks.

Omni-complete in command window crashes Vim

Using Vim 7.3 (non-MacVim, but it happens there too) on OSX 10.7.5.

Steps to reproduce:

  • Open a namespace
  • Hit cqc to open the command window
  • Start typing an expression like (ns- and hit ctrl-x ctrl-o

Vim crashes:

Vim: preserving files...
vim(10763) malloc: *** error for object 0x7f9198e0cc08: incorrect checksum for freed object - object was probably modified after being freed.
                                      *** set a breakpoint in malloc_error_break to debug
                                                                                         Vim: Double signal, exiting
vim(10763) malloc: *** error for object 0x7f9198e0cc08: incorrect checksum for freed object - object was probably modified after being freed.
                                      *** set a breakpoint in malloc_error_break to debug
                                                                                         Abort trap: 6

Properly process stack trace when source file is "(Unknown Source)"

Sometimes when an exception is thrown, part of the stack trace has "(Unknown Source)" as the originating file. This break vim-foreplay since the regex that parses the file and line number expects a colon to always exists.

Following patch fixes it, although I'm sure not if there is a cleaner / better way. Maybe unify (Unknown Source) and NO_SOURCE_FILE so they are the same logically?

diff --git a/plugin/foreplay.vim b/plugin/foreplay.vim
index c31e4f8..ccb6411 100644
--- a/plugin/foreplay.vim
+++ b/plugin/foreplay.vim
@@ -371,9 +374,15 @@ endfunction
 function! foreplay#quickfix_for(stacktrace) abort
   let qflist = []
   for line in a:stacktrace
-    let match = matchlist(line, '\(.*\)(\(.*\):\(\d\+\))')
+    let match = matchlist(line, '\(.*\)(Unknown Source)$')
+    if !empty(match)
+      let [_, class; __] = match
+      let file = "UNKNOWN_SOURCE_FILE"
+      let lnum = 1
+    else
+      let [_, class, file, lnum; __] = matchlist(line, '\(.*\)(\(.*\):\(\d\+\))')
+    endif
     let entry = {'text': line}
-    let [_, class, file, lnum; __] = match
     let entry.lnum = lnum
     let truncated = substitute(class, '\.[A-Za-z0-9_]\+\%($.*\)$', '', '')
     if file == 'NO_SOURCE_FILE'

Running

Windows 7
Java 1.7u11
Leiningen 2.0.0-RC2
[org.clojure/clojure "1.5.0-RC1"]
[org.clojure/tools.nrepl "0.2.0-RC2"]

if it matters.

Switch to test file support

I'd love if vim-foreplay had a command to switch to the test namespace associated with the namespace in the current buffer (and vice versa). There are at least a handful of ways people namespace their tests. Given namespace project.foo I've seen:

  • project.test.foo
  • project.test-foo
  • project.foo (same namespace)

Thanks.

Strip '\r' in addition to '\n' in s:output_response() to ensure echo messages always show

In Leiningen 2.0.0-RC1 (fixed in RC2) on Windows, NULL pointer stack traces are broken. The one line stack trace (which doesn't qualify it as a stack trace due to no tab characters) with no source info disappears extremely fast or often doesn't show at all. This gives the illusion that Eval command completed successfully, and is difficult to notice a problem has actually occurred.

The cause appears to be a stray \r character at the end of the out messages. In order to prevent future cases of ninja messages, this character should be sanitized out.

diff --git a/plugin/foreplay.vim b/plugin/foreplay.vim
index c31e4f8..ccb6411 100644
--- a/plugin/foreplay.vim
+++ b/plugin/foreplay.vim
@@ -398,11 +407,11 @@ endfunction
 function! s:output_response(response) abort
   if get(a:response, 'err', '') !=# ''
     echohl ErrorMSG
-    echo substitute(a:response.err, '\n$', '', '')
+    echo substitute(a:response.err, '\r$|\n$', '', '')
     echohl NONE
   endif
   if get(a:response, 'out', '') !=# ''
-    echo substitute(a:response.out, '\n$', '', '')
+    echo substitute(a:response.out, '\r$|\n$', '', '')
   endif
 endfunction

"nREPL: namespace not found" from scratch file

[15:52:50] tpope: my scratch file is in the root of my project
[15:52:56] scratch.clj, next to project.clj
[15:53:02] i have scratch.* in my global git ignore
[15:53:02] well then it shouldn't be in the classpath
[15:53:14] :echo foreplay#ns()
[15:53:38] tpope: no output
[15:54:09] err, I don't think I ever gathered what your problem actually is
[15:54:42] so i have a src/proj/core.clj file
[15:54:44] in there K works
[15:54:57] in ./scratch.clj i get "nREPL: namespace not found"
[15:55:17] oh hrmm
[15:55:30] my intent was for it to fall back to user
[15:56:00] yeah, please open a bug, I have to run an errand
[15:56:04] should be a simple fix

Problem connecting to nrepl in windows

When connecting to nrepl in windows vim hangs indefinitely.

This is the command sent to cmd.exe (ruby is my path):

C:\Windows\system32\cmd.exe /c ruby -rsocket -e "begin;TCPSocket.open("%"(localh
ost), 6662) {|s|s.write(ARGV.first); loop {body = s.readpartial(8192);raise "%"(
not an nREPL server: upgrade to Leiningen 2) if body =~ /=> $/;print body;break
if body.include?("%"(6:statusl4:done)) }};rescue; abort $!.to_s;end" "d4:code116
:(do (println ""success"") (symbol (str (System/getProperty ""path.separator"")
(System/getProperty ""java.class.path""))))7:session36:f20559ae-b7a4-4a4a-bdad-1
80c188548e22:op4:evale" >C:\tmp\VIoA433.tmp 2>&1

It just gets stuck in that state until I Ctrl-C out of the command,

I was able to connect to nrepl before and this started happening when I updated to the latest version of foreplay. Any ideas what might be wrong?

P.S. I'm using leiningen 2.0.0 RC2 to start the nrepl session.

Eliminate dependency on VimClojure

VimClojure has been serving me quite well for syntax highlighting, indentation, etc, but I never did get the Nailgun thing working correctly. Foreplay's nRepl integration has been working splendidly so far.

Would be nice to halve the number of Clojure-related plugins I've got installed. In that vein, maybe @kotarak is interested in contributing the static parts of VimClojure to ship as part of the standard vim distribution?

Vim seg faults when opening .clj files

I'm running Vim 7.3.761 on OS X 10.8.2. Vim opens, but as soon as I try to load any .clj files, it pauses for a moment and then reports

Vim: Caught deadly signal SEGV

Vim: Finished.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.