avli / clojurevscode Goto Github PK
View Code? Open in Web Editor NEWClojure support for Visual Studio Code
Home Page: https://avli.github.io/clojureVSCode/
License: MIT License
Clojure support for Visual Studio Code
Home Page: https://avli.github.io/clojureVSCode/
License: MIT License
This is just a preliminary thought, but I wanted to post here for discussion.
It might very nice to have the ability to run both a clj and cljs repl in a single project. I know this is probably a complex/big feature, but it seems like it would effect the architecture of the entire extension so it might make sense to start thinking about it early.
Having 2 repls brings up some hard questions like how to handle .cljc files? Should they be sent to one or should they be sent to both repls on evaluation? What about errors coming back?
Or perhaps it should simply be 1 repl per editor and the clj and cljs editing should be separate?
If the embedded nREPL instance exists unexpectedly it would be nice to report to the user about it and maybe print some service information to the VSCode output channel.
We should think if we want to wire the embedded nREPL output with the VSCode output channel. I can see both pros and cons in this approach.
Pros:
Cons:
Hi!
This is tangentially related to a few recent issues, namely #70 and #59 - I'd like to get automatic evaluation of all code in project source files mainly to enable IntelliSense navigation immediately in the following two cases:
The main idea here is to keep code navigation as up to date as possible and the nice side effect of course is that it becomes really easy to check whether what I've just written makes sense or not. I'm sure there's some alternate route I could take and create a two-command macro in VSCode itself but I'd rather have this as add-on feature so that I can also turn it off at times if I'm, for example, working on such a humongous project that VSCode would grind to halt if it was autoevaluated.
(and with my track record this already exists in some form, I just couldn't find it before posting... :))
Hi folks, I've been using this mode for VS Code, and I love it. Thanks for all your hard work.
I have a little UX suggestion: when connecting to the nREPL, default the 'host' question box to 'localhost'. I expect 99% of the time localhost will be the answer, so perhaps it's an option to even elide the question entirely, or just have one box where you can type a port or a host:port combo?
Thanks,
Mark
This is a must for any language support extension. As far as I can see, this feature is currently supported only with Javascript in VS Code, which leads me to believe it might be due to external support eg. Node.
Do you guys have any channel of communication, I could help with this.
Given this code:
(defn process-file [fname]
(slurp (clojure.java.io/resource fname)))
(process-file "hello.txt")
and this file in resources/hello.txt
:
Hello Resources!
When I eval
Then I get a stacktrace:
clojure.lang.Compiler$CompilerException java.lang.IllegalArgumentException: Cannot open <nil> as a Reader.
at null:69:22
clojure.lang.Compiler$InvokeExpr.eval (Compiler.java:3657)
clojure.lang.Compiler$DefExpr.eval (Compiler.java:451)
clojure.lang.Compiler.eval (Compiler.java:6932)
clojure.lang.Compiler.load (Compiler.java:7379)
clojure.lang.Compiler.eval (Compiler.java:6927)
clojure.lang.Compiler.eval (Compiler.java:6890)
clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__5508.invoke (interruptible_eval.clj:87)
clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invokeStatic (interruptible_eval.clj:85)
clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invoke (interruptible_eval.clj:55)
clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__5553$fn__5556.invoke (interruptible_eval.clj:224)
clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__5548.invoke (interruptible_eval.clj:192)
This works without issue in a lein repl
.
I'd love a way to evaluate the outermost form (searching from the position of the cursor, similar to proto-repl for Atom). This way I won't have to select the whole text/form I want to evaluate.
(sorry if this is already possible, I didn't find a way to do this)
I'm running the latest version of VS Code (1.15.0), the clojureVSCode plugin (0.7.10), and Mac OSX (10.12.6).
I get decent intellisense for functions in the core namespace, but not for symbols in my own files. I don't get any of the doc comments on hover (or as typing) that are shown in the demos. I also can't do any code-navigation.
It does show that nrepl is connected (in the lower toolbar).
Is there something I need to do to properly configure things?
I've searched through the old issues here and can't find anything.
Simply, how do I display what the compilation errors are? I'm getting compile errors when trying to eval some code, but I can't for the life of me figure out how to see them.
@avli
How do you feel about putting the eval compilation errors in the "Output" panel, instead of the "Problems" panel?
This is how proto-repl displays compilation errors, and I think it is more convenient, since one doesn't need to click or hotkey to the other panel for feedback.
From a workflow perspective, it just feels clunky to me to have to change panels to see all the Repl output. I don't want to move my cursor, and I don't want to memorize the hotkeys to switch between the Output and Problems panes.
Moreover, from a logical perspective, should the repl compiler errors even fall under "Problem", anyways?
The blank Problems window reads: No problems have been detected in the workspace so far.
The eval compilation may fail due to issues that are not directly related to your workspace, your code, etc. For example, when you eval a function (foo)
without first evaluating (defn foo [] ())
. Therefore I think that categorically speaking, Output may be a more fitting place for the repl compilation errors.
As written on README.md from earlier versions, for this extension to function properly when using Connect to a running nREPL
it's necessary for the user to add cider-nrepl plugin and tools.nrepl dependency.
If they don't do it, there are no clear warnings about it and the extension just doesn't work as intended (as seen on #30 comments).
The idea here is to check if those dependencies are correctly declared and warn the user otherwise.
Sometimes it is necessary to restart the nrepl.
It would be convenient to drop the current connection and reconnect.
Presently, it seems like a VSCode "Reload Window" does the trick.
If that is the best approach then an update to the documentation would be nice.
I used it on my 2 macs, one is ok, the other cannot work(printing "Starting nREPL..." like, forever).
I ps grep java, and found the java process will disappear after a while, so I want to see what happened, but I cannot find any console output.
Thanks
https://github.com/avli/clojureVSCode/blob/master/src/clojureFormat.ts#L39 passes nil
as opts. cljfmt has some intrusive defaults like consecutive-blank-line?
which are true by default and can thus not be disabled.
For those that might want to assist in development work on clojureVSCode, it would be very helpful to document process to setup development of, and make/test changes to the extension. Thanks!
Hey, I totally randomly stumbled upon your extension. I was just looking for some example VS Code language support extensions :)
While reading clojureDefinition.ts I noticed there is probably a return statement missing at line 31, or maybe I'm missing something. I think the code that follows should throw if info.file
is null/undefined/empty? But apparently that never happened yet?
I think the issue is that you're invoking lein with LEIN_ARGS, defining a bunch of libraries wanted, but I don't have those libraries installed.
Then lein prints this to stderr:
"""
Retrieving refactor-nrepl/refactor-nrepl/2.3.0-SNAPSHOT/refactor-nrepl-2.3.0-20170531.195417-17.jar from clojars
Retrieving org/clojure/clojure/1.2.0/clojure-1.2.0.jar from central
Retrieving cider/cider-nrepl/0.15.0-SNAPSHOT/cider-nrepl-0.15.0-20170720.063753-24.pom from clojars
Retrieving org/clojure/tools.nrepl/0.2.13/tools.nrepl-0.2.13.pom from central
Retrieving org/clojure/pom.contrib/0.2.2/pom.contrib-0.2.2.pom from central
Retrieving org/tcrawley/dynapath/0.2.5/dynapath-0.2.5.pom from central
"""
And we treat any data coming in off stderr as a signal to stop() and reject the start promise:
https://github.com/avli/clojureVSCode/blob/master/src/nreplController.ts#L49
Then it kills the process.
I imagine this didn't happen during development because you already have these libraries installed on your machine?
Debugging screenshot illustrating the point (see the console at the bottom, printing out the stderr data we received):
What can we do? Maybe
(a) document that these libraries are required?
(b) install these libraries? lein tries to, but it gets killed soon after.
(c) assume processes will send user-facing information to stderr (rather than it explicitly signalling an error), and only treat a non-zero exit code as actually signalling error?
(c) seems best to me. What do you think?
See Keep a Changelog.
Description: When opening a lein project for the first time or choosing Clojure: start nREPL from the command palette, the nREPL is not started and the error, "Can't start nREPL." is seen. Nothing is shown in the Problems or Debug Console panel.
System info
Steps to reproduce
lein new app foo && cd foo
Starting a REPL in the CLI and connecting as described in #11 works perfectly, though.
When I run the following code
(reduce
(fn [acc next]
(str acc "\n" next))
""
["foo"
"bar"])
against the extensions "Format" command the newline character in the string concatenation will do unecpected things and I receive the following result:
(reduce
(fn [acc next]
(str acc "\
" next))
""
["foo"
"bar"])
which is invalid code. Running the original snippet against lein-cljfmt
s fix
works as expected:
(reduce
(fn [acc next]
(str acc "\n" next))
""
["foo"
"bar"])
Never having worked in the VSCode ecosystem I am slightly stumped on where to look for the cause of this, but if you could give me a hint or two, I'd be more than happy to fix this myself.
coda_hale commented this in reddit
Looks like a great start, and it's awesome to see more high-quality support for Clojure!
One quick note: I'm pretty sure you can get around the manual cider-nrepl/nrepl dependencies steps if you invoke lein the same way cider does:/usr/local/bin/lein update-in :dependencies conj \ \[org.clojure/tools.nrepl\ \"0.2.12\"\ \:exclusions\ \ \[org.clojure/clojure\]\] -- update-in :plugins conj \ \[refactor-nrepl\ \"2.3.0-SNAPSHOT\"\] -- update-in :plugins conj \ \[cider/cider-nrepl\ \"0.15.0-SNAPSHOT\"\] -- repl :headless
That also means you're not tied down to a particular version of those libraries.
As far as I know, clojure doesn't have the notion of optional parameters.
These operations ('def', 'defn' and 'fn') are widely used and their current signature have some optional parameters that are handled inside their implementation. Since the signature helper just looks at the parameter position, sometimes it shows the wrong active parameter (as already noted by @avli in #15).
It would be nice to try to provide better signature helper for them that takes into account more information than just their parameter position.
PROBLEM:
cannot connect to running REPL.
REPRO:
EXPECTED:
Successful connect to running REPL
OBSERVED:
"command 'clojureVSCode.manuallyConnectToNRepl' not found"
ENVT:
Mac OSX 10.12
VSCODE 1.16.1
NOTE: Also found that the nREPL was also taking an indefinite amt of time when automatically starting-
After you eval, a "Successfully Compiled" notification appears at top of editor.
Perhaps it should be shown after eval of the entire file to give indication that the operation was successful, but it might be nice if it faded away after a few seconds.
It probably should not be shown after "Eval and show the result" operations because indications the result was returned is shown in the output window, and the top bar notification becomes a nuisance during repeated usage.
The embedded REPL fails to start when you open a file outside a Leiningen project. Steps to reproduce:
@fasfsfgs Any ideas?
It looks like you're only grabbing one line of output
I have my code hooked up to a lein repl, and the following command only prints "hello" (and not "world")
(when true
(println "hello")
(println "world"))
The grammar file that comes with Visual Studio Code is far from perfect especially in terms of indenting. We should consider to improve it in order to conquer the world :-)
Steps to reproduce:
Hi!
Due to Reasons™ I'm currently working with a project that uses the lately hyped monorepo pattern; that is, within the same repository the first level of subdirectories are each their own individual projects meaning the build configs etc. are also in those subdirectories, not the project root. In this context running the nREPL from project root doesn't really produce anything useful as it will systematically fail at loading anything without rigorous typing and it is just far easier to jump to the Terminal tab, cd sub-dir and start another REPL from there onwards.
Of course supporting monorepos could be a nice feature, especially with VSCode itself being soon able to have multi-root workspaces but that's something for the future, for immediate issue just having a switch for nREPL works the best IMHO :)
Hello there,
First off, great work so far!
As you can probably tell from the title, when manually connecting, this doesn't stop the loading animation in the bottom of the vs code window, and it just kind of ticks over forever, occasionally distracting me and making me think I have a notification of some sort.
Please let me know if you need any more information or steps to replicate.
Thanks!
-Jordan
Following code isn't highlighted correctly:
(map (fn [[k v]] (str (name k) "=\"" v \")) xs)
This breaks all further syntax highlighting.
Thanks!
Currently, we try to updateConnectionParams() by reading the .nrepl-port file during extension activation (when a clojure file is first opened), then we try to auto-connect.
This fails when you open the clojure file first, then the repl after extension activation.
Perhaps we can setup a file watcher, and automatically connect to the repl if a .nrepl-port file becomes available?
This isn't a fully fleshed-out idea: we'll need to think a bit about how to handle a change the .nrepl-port file when we're already connected to a nrepl. Do we connect to the new one? Or keep the existing one - which may be closed, and maybe we haven't noticed it's gone? I'd propose taking the less-destructive route of staying with the existing REPL.
What do you think?
Some special forms that didn't follow a simple pattern for their forms-str (used for the signature helper) were left out in #15.
It would be nice to find a solution for them.
Maybe their signature helper will need to be manually handled.
Hmm, after following the boot-related config steps described in https://github.com/boot-clj/boot/wiki/Cider-REPL (more specifically fixing ~/.boot/profile.boot described in A better way / point 1.), everything works nicely for me.
After working some more with VS Code, it turned out that code completion doesn't work for me with a Boot REPL after all. With the plugin's built-in REPL starter, code-completion seems to work, but as I currently have my project configurations in Boot, I cannot really use it for testing.
In addition to the user-global profile, I mentioned in my previous comment, I have my project specific Boot settings as in https://github.com/pdkovacs/clj-todo .
Thinking about what might have solved the actual issue at hand for me, I have removed something (sorry, I don't remember anymore exactly what it was) from ~/lein/profiles.clj. It is currently at the bare minimum of:
{:user {:dependencies [[org.clojure/tools.nrepl "0.2.13"]]} } Let me know if I can help any more with this.
This is also related with #31.
Hi, I'm not sure what features you want to include in this extension over time, but I started adding some features that are important to my workflow. So far I've added cider-nrepl's "refresh-all namespaces" and "run all tests in project". I'm sure it needs more testing and cleanup (I'm not a javascript developer). If this is something you would be interested in having contributed to the extension, just let me know!
https://github.com/matthias-margush/clojureVSCode/tree/refresh-test
Thanks so much for really nice extension.
Currently, if file have defmulti/defmethod code changed, it couldn't reload (eval) in REPL. Is it limited of repl/cider-nrepl/.., or something we can improve?
Thanks,
Does println or output get shown anywhere? When selecting and evaluating the expression below, no output is show in the external repl, the output window or any other locations I checked within vscode.
(println "hi")
After NRepl started, while idle in the editor, java.exe CPU usage hovers around 25% with the August 1 version of the extension. Killing Visual Studio Code results in zombie java.exe which must be killed seperately.
Windows 10 1703 build 15063.540
Visual Studio Code: version 1.15.0
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
Please advise on how to troubleshoot.
When selecting a block of code that will cause an exception, and evaluating it with "Clojure: Eval and show the result", an error notification bar is shown at top of editor, but no details on the error are displayed.
Are error details already show in some location? Perhaps error details could be show in the output window?
The current video is just 100% reflection of my movie director skills, in other words, it sucks :) If you can provide a better one, please, send it to me.
Good examples are vscode-go and pythonVSCode.
It would be great to have the option to change the code and reload the file to the repl instead of restarting it
Dan
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.