dgrnbrg / vim-redl

A better Vim integration story for Clojure
106 stars 8 forks source link

Forms are not evaluated in the REPL #20

Closed wwentland closed 10 years ago

wwentland commented 10 years ago

When I evaluate forms in the REPL I see the following behaviour:

user=> (+ 1 1)
"(+ 1 1)"
user=>

which is obviously not what one wants. This happens if I run a nrepl in leiningen (2.3.3) with lein repl as trying to run :Repl with no open nrepl results in the following error (regardless of $PWD and vim's :pwd):

java.lang.ClassNotFoundException: redl.core, compiling:(NO_SOURCE_PATH:1:1)
Error detected while processing function redl#repl#create..fireplace#evalparse:
line   12:
E605: Exception not caught: Clojure: class clojure.lang.Compiler$CompilerException

Some information about my system:

$ cat ~/.lein/profiles.clj 
{:user {:dependencies [[spyscope "0.1.3"]
                       [redl "0.1.0"]]
        :injections [(require 'spyscope.core)
                     (require '[redl complete core])]
        :plugins [[lein-pprint "1.1.1"]
                  [lein-ancient "0.4.4"]]}}

$ cat project.clj 
(defproject foo "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.5.1"]])

$ find ~/.vim/ -name *.vim | grep -E '(redl|fireplace|classpath)' |xargs md5sum
c685e77fc92a7de281e9802100845eed  /home/babilen/.vim/bundle/vim-classpath/autoload/classpath.vim
d341f225c13b406379af89ca885ad656  /home/babilen/.vim/bundle/vim-classpath/plugin/classpath.vim
12f7c5fc248a71a3d5a12402ce963205  /home/babilen/.vim/bundle/vim-fireplace/autoload/nrepl/fireplace_connection.vim
921c49d14fd7feeedd7dcddec1af6bc8  /home/babilen/.vim/bundle/vim-fireplace/plugin/fireplace.vim
de4c2e4cd34164bc93de3ab0fd538bda  /home/babilen/.vim/bundle/vim-fireplace/plugin/fireplace/zip.vim
7741f9cdd797d00c425b412751feb29a  /home/babilen/.vim/bundle/vim-redl/plugin/redl.vim
f7d1fc0506fbd099950153056408b8aa  /home/babilen/.vim/bundle/vim-redl/plugin/redl/repl.vim
fada85a4214bc9c09fb0ffc3743242c0  /home/babilen/.vim/bundle/vim-redl/plugin/redl/util.vim

$ md5sum ~/.m2/repository/redl/redl/0.1.0/redl-0.1.0.jar
7b8bacc2cf0fba3e747ce854d81a517c  /home/babilen/.m2/repository/redl/redl/0.1.0/redl-0.1.0.jar

Running :Eval (require 'redl.core) never returns, but I can run, say, :Eval (+ 1 1) just fine (regardless of running the leiningen nrepl or not).

dgrnbrg commented 10 years ago

Have you updated to the latest redl vim script and clj code? You should check out the clj code on GitHub and "Lein install". I'll also release it this weekend as 0.1.1.

Sent from my iPhone

On Oct 15, 2013, at 9:46 AM, Wolodja Wentland notifications@github.com wrote:

When I evaluate forms in the REPL I see the following behaviour:

user=> (+ 1 1) "(+ 1 1)" user=>

which is obviously not what one wants. This happens if I run a nrepl in leiningen (2.3.2) with lein repl as trying to run :Repl with no open nrepl results in the following error (regardless of $PWD):

java.lang.ClassNotFoundException: redl.core, compiling:(NO_SOURCE_PATH:1:1) Error detected while processing function redl#repl#create..fireplace#evalparse: line 12: E605: Exception not caught: Clojure: class clojure.lang.Compiler$CompilerException

Some information about my system:

$ find ~/.vim/ -name .vim | grep -E '(redl|fireplace)' |xargs md5sum 12f7c5fc248a71a3d5a12402ce963205 /home/babilen/.vim/bundle/vim-fireplace/autoload/nrepl/fireplace_connection.vim 921c49d14fd7feeedd7dcddec1af6bc8 /home/babilen/.vim/bundle/vim-fireplace/plugin/fireplace.vim de4c2e4cd34164bc93de3ab0fd538bda /home/babilen/.vim/bundle/vim-fireplace/plugin/fireplace/zip.vim 7741f9cdd797d00c425b412751feb29a /home/babilen/.vim/bundle/vim-redl/plugin/redl.vim f7d1fc0506fbd099950153056408b8aa /home/babilen/.vim/bundle/vim-redl/plugin/redl/repl.vim fada85a4214bc9c09fb0ffc3743242c0 /home/babilen/.vim/bundle/vim-redl/plugin/redl/util.vim $ cat ~/.lein/profiles.clj {:user {:dependencies [[spyscope "0.1.3"] [redl "0.1.0"]] :injections [(require 'spyscope.core) (require '[redl complete core])] :plugins [[lein-pprint "1.1.1"] [lein-ancient "0.4.4"]]}} $ find ~/.vim/ -name .vim | grep -E '(redl|fireplace|classpath)' |xargs md5sum c685e77fc92a7de281e9802100845eed /home/babilen/.vim/bundle/vim-classpath/autoload/classpath.vim d341f225c13b406379af89ca885ad656 /home/babilen/.vim/bundle/vim-classpath/plugin/classpath.vim

12f7c5fc248a71a3d5a12402ce963205 /home/babilen/.vim/bundle/vim-fireplace/autoload/nrepl/fireplace_connection.vim 921c49d14fd7feeedd7dcddec1af6bc8 /home/babilen/.vim/bundle/vim-fireplace/plugin/fireplace.vim de4c2e4cd34164bc93de3ab0fd538bda /home/babilen/.vim/bundle/vim-fireplace/plugin/fireplace/zip.vim 7741f9cdd797d00c425b412751feb29a /home/babilen/.vim/bundle/vim-redl/plugin/redl.vim f7d1fc0506fbd099950153056408b8aa /home/babilen/.vim/bundle/vim-redl/plugin/redl/repl.vim fada85a4214bc9c09fb0ffc3743242c0 /home/babilen/.vim/bundle/vim-redl/plugin/redl/util.vim $ cat project.clj (defproject foo "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.5.1"]]) $ md5sum ~/.m2/repository/redl/redl/0.1.0/redl-0.1.0.jar 7b8bacc2cf0fba3e747ce854d81a517c /home/babilen/.m2/repository/redl/redl/0.1.0/redl-0.1.0.jar

Running :Eval (require 'redl.core) never returns, but I can run, say, :Eval (+ 1 1) just fine (regardless of running the leiningen nrepl or not).

— Reply to this email directly or view it on GitHubhttps://github.com/dgrnbrg/vim-redl/issues/20 .

wwentland commented 10 years ago

I've just tried redl 77304824e8730330429d1aabfefefae4eee116dc and it wouldn't install because it couldn't find core.async, but a small change to project.clj solved that problem and I can now work in a REPL started with :Repl or :ReplHere iff I run lein repl in the project root first, so that is definitely an improvement.

The error I got when I tried to install redl 77304824e8730330429d1aabfefefae4eee116dc is:

 lein install
Retrieving org/clojure/tools.nrepl/0.2.0-RC1/tools.nrepl-0.2.0-RC1.jar from central
Could not find artifact core.async:core.async:jar:0.1.0-SNAPSHOT in clojars (https://clojars.org/repo/)
This could be due to a typo in :dependencies or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.

which is not very surprising as that artifact is no longer on clojars. I therefore changed [core.async "0.1.0-SNAPSHOT"] to [org.clojure/core.async "0.1.242.0-44b1e3-alpha"] as detailed on https://github.com/clojure/core.async and it installed happily. I opened a pull request for this, but am not entirely sure if you developed against the version of core.async I included.

All that being said: I still get an error when I run either :Repl or :ReplHere if I do not open a repl via lein repl first (and therefore rely on vim-classpath doing its thing). It is the same as before, but I include it for the sake of completeness:

 COMMND  src/calculon/parser.clj                                                                                                                                                                    unix  utf-8  clojure   45%    22:5  
java.lang.ClassNotFoundException: redl.core, compiling:(NO_SOURCE_PATH:1:1)
Error detected while processing function redl#repl#create..fireplace#evalparse:
line   12:
E605: Exception not caught: Clojure: class clojure.lang.Compiler$CompilerException

which is (educated guess) probably due to the fact that tpope/vim-classpath does not pick up the :injections in ~/.lein/profiles.clj. Does that work for you or do you simply always run a repl in a, then forgotten, terminal?

dgrnbrg commented 10 years ago

That is correct. I don't really like vim-classpath, because of the 1-2 second delay it adds when starting a non-lein repl outside of projects. Redl is designed to work with projects, since it requires quite a bit of code to be injected into the VM.

Also, be sure to try running something like (Thread/sleep 1000000) or (range) in this version of redl--it's got a features to understand that kind of "stuck" repl.

On Wed, Oct 16, 2013 at 6:49 AM, Wolodja Wentland notifications@github.comwrote:

I've just tried redl 7730482https://github.com/dgrnbrg/vim-redl/commit/77304824e8730330429d1aabfefefae4eee116dcand it wouldn't install because it couldn't find core.async, but a small change to project.clj solved that problem and I can now work in a REPL started with :Repl or :ReplHere iff I run lein repl in the project root first, so that is definitely an improvement.

The error I got when I tried to install redl 7730482https://github.com/dgrnbrg/vim-redl/commit/77304824e8730330429d1aabfefefae4eee116dcis:

lein install Retrieving org/clojure/tools.nrepl/0.2.0-RC1/tools.nrepl-0.2.0-RC1.jar from central Could not find artifact core.async:core.async:jar:0.1.0-SNAPSHOT in clojars (https://clojars.org/repo/) This could be due to a typo in :dependencies or network issues. If you are behind a proxy, try setting the 'http_proxy' environment variable.

which is not very surprising as that artifact is no longer on clojars. I therefore changed [core.async "0.1.0-SNAPSHOT"] to [org.clojure/core.async "0.1.242.0-44b1e3-alpha"] as detailed on https://github.com/clojure/core.async and it installed happily. I opened a pull request for this, but am not entirely sure if you developed against the version of core.async I included.

All that being said: I still get an error when I run either :Repl or :ReplHere if I do not open a repl via lein repl first (and therefore rely on vim-classpath doing its thing). It is the same as before, but I include it for the sake of completeness:

COMMND  src/calculon/parser.clj  unix  utf-8  clojure  45%   22:5 java.lang.ClassNotFoundException: redl.core, compiling:(NO_SOURCE_PATH:1:1) Error detected while processing function redl#repl#create..fireplace#evalparse: line 12: E605: Exception not caught: Clojure: class clojure.lang.Compiler$CompilerException

which is (educated guess) probably due to the fact that tpope/vim-classpath does not pick up the :injections in ~/.lein/profiles.clj. Does that work for you or do you simply always run a repl in a, then forgotten, terminal?

— Reply to this email directly or view it on GitHubhttps://github.com/dgrnbrg/vim-redl/issues/20#issuecomment-26408272 .