betterthantomorrow / calva Goto Github PK
View Code? Open in Web Editor NEWClojure & ClojureScript Interactive Programming for VS Code
Home Page: https://marketplace.visualstudio.com/items?itemName=betterthantomorrow.calva
License: Other
Clojure & ClojureScript Interactive Programming for VS Code
Home Page: https://marketplace.visualstudio.com/items?itemName=betterthantomorrow.calva
License: Other
Something has broken linting. Joker recently updated to 0.9.2 so it could be the culprit, but the update didn't include anything major.
Trace:
TypeError: Cannot read property 'getDocument' of undefined at Object.lintDocument$$module$calva$repl$middleware$lint [as lintDocument]
Thanks for publishing a very promising VS Code integration!
It would be great if the middleware dependency can be automatically handled a la emacs cider.
It would be good you didnt have to keep switching back to the source code buffer every time you evaluate an expression
my peek definition is not working. what is the shortcut to use this peek definintion
This is a very exciting project! I have been waiting for Clojure to get better support in VS Code and this looks to be a very strong start in the right direction! Inline code evaluation is huge and its really nice to see an editor other than emacs finally adopt this :)
After reading #44 and some of the other discussions, I am wanting to open this issue as a more general discussion about the current state of Clojure tooling in VS Code and how this project fits in to all of that.
Personally I use VS Code for all my development work except Clojure for which I use Cursive on Intellij. Cursive is fantastic, but intellij is slow and resource hungry and ideally I would like to do all my development on the same editor. Here are the major areas I feel need to be addressed before the productivity loss from moving to VS Code would be small enough that the benefits of VS Code would out-weight. This is coming from the perspective of a 'mediumly' experience Clojurian and I don't know if these points will match the goal of this project or the pain points of the majority of Clojurians :) It will be nice to hear your thoughts on this.
This is huge - it is perhaps the biggest reason why I am unwilling to move to VS Code as it directly affects my productivity while writing Clojure. There is currently a project (https://github.com/shaunlebron/vscode-parinfer) to try add support for this in VS Code but it's integration right now really isn't great.
Perhaps a possible route is for this repo to also replace the existing parinfer extension and make it work (well). I'm not sure about the viability of this?
This is already a point on your readme about planned future work which is nice to see. This would make usage of the reloaded workflow much more viable in VS Code.
I will be trying out Calva more and will add to this if I find anything else I feel is key. I am very keen to see this project make Clojure great in VS Code and I'll try to dedicate some time to contributing! Custom user commands seems like a good place to start, perhaps we can chat on slack about what that will entail.
Keep up the good work!
Hello, here is my system and what I am running into.
OS: Windows 10 64 bit
Shell: 1.7.12
VS Code Version: 1.24.0
Clojure 1.8.0
REPL-y 0.3.7, nRPL 0.2.12
Java HotSpot(TM) Client VM 1.8.0_144-b01
I took the steps that were previously working, that is navigate to the root directory of my project. Create a rpl with lein repl. Use CTRL + Shift + P and then use Calva: Connect, enter in localhost:(port number shown in repl), and nothing happens. I cannot execute code with CTRL + Shift + V and E. It does not give any errors but is also not seemingly connecting to the repl.
So far I have tried restarting the computer, starting repl's in different sub directories but to no avail. Any ideas or suggestions?
Saving the file with these examples doesn't fix the indentation:
editor.formatOnSave
both as true and falseMy settings are here:
{
"atomKeymap.promptV3Features": true,
"editor.multiCursorModifier": "ctrlCmd",
"editor.formatOnPaste": true,
"editor.minimap.enabled": false,
"calva.lintOnSave": true,
"calva.autoAdjustIndent": true
}
Thanks
I'm finding that if I use :refer :all
in a namespace require, that Calva shows me some unexpected errors around unresolved symbols and unused namespace. For example, if I have:
(ns my.thing.user-test
(:require [clojure.test :refer :all]))
Then assuming I have some tests defined, I will get the following errors:
Parse error: Unable to resolve symbol: deftest
Parse error: Unable to resolve symbol: is
Parse warning: unused namespace clojure.test
If I change my requires to use :as
, or to list the referred items (e.g. [clojure.test :refer [deftest is testing use-fixtures]]
), then the errors go away. I'm relatively new to Clojure, but these tests run fine, so it seems like a Calva parsing issue?
My environment:
Calva today assumes that there is always a ClojureScript part of the project. It shouldn't. We probably can consume the project.clj
file and figure things out. Or if this should be fixed in some other way.
This is a pretty odd issue, but I've been able to reproduce it pretty simply in multiple clojure projects, and it took me quite a while to trace it back to this extension. I'd like someone else to try as a sanity check for me, though the repro steps are simple enough that I'm pretty sure it's a Calva problem.
Repro steps:
lein repl
nREPL
button in the status bar and use the pre-populated host:portnREPL
button in the status bar again to "re-do" the connection to that same host:portI noticed this several times yesterday during the work day. If I ever have code changes that require a repl restart, I will often reconnect Calva to that repl in order to get all its functionality. So it's a pretty common workflow for me. Restarting my computer is the only way I've been able to get a bash prompt in any new terminal windows. I tried restarting the terminal, restarting VSCode, killing processes.... nothing seemed to work except a restart.
My System Details:
macOS High Sierra Version 10.13.6
VSCode 1.26.1
Leiningen 2.8.1 on Java 1.8.0_152 Java HotSpot(TM) 64-Bit Server VM
Project dependencies:
:dependencies [[org.clojure/clojure "1.8.0"]
[ring/ring "1.1.6"]]
I tried uninstalling/reinstalling, but its not working. The strange thing is, it was working, and then upon closing and reopening code, starting and entering the new repl, it stopped working.
Any way to troubleshoot the exception when this happens?
I am using 1.24.0.
Thanks--
Bug report coming from conversation in #vscode in clojurians slack on April 28/29/30.
When evaluating code in VSCode, ansi color codes are printed in terminal.
For example, instead of just outputting nil
, it will output ?[36mnil?[0m
In other (Windows) clients which use lein repl which support color output in terminal, the response text would be colorized correctly(with the ansi color information then removed after use).
Noticable, issue seems to be fundamental to Windows as cmd.exe, Powershell & VSCode terminal all suffer from this issue,
##Other Info
similar to clojure-emacs/cider#275 which was solved client side.
TODO
We don't want to throw all the existing JavaScript code away, that's not very practical. So let's try to incrementally 'migrate' existing functionalities to ClojureScript. But...where should we start? 🤔
What concerns do you have about changing this behavior to not showing the output panel? What I like about Calva is that it 'just works'. Once the programmer has Calva installed one doesn't need to think much about it.
I have a fix for this, but I'm logging the issue for tracking purposes.
Not an indentation issue, but cmd-click doesn't take you to the function definition of functions that use the syntax-quote macro (a backtick), which is convention in a certain method of defining routes in the pedestal framework. (See http://pedestal.io/reference/routing-quick-reference#_table_syntax)
In this case, I can cmd-click through to map
in the first println, but I can't when it's syntax-quoted with a ` in the second println:
(println map)
;; => #function[clojure.core/map]
(println `map)
;; => clojure.core/map
The alt-v prefix in the international Mac KB inserts (ˇ), and although the command is recognized, the character's already been inserted.
One feature i notice lacking in the intelli-sense is displaying the expected params to function
I get auto completion and documentation in line like so:
But it would be nice to have the different arity's of the methods show up when the cursor is in the arguments position (ie after you have selected a specific function), something like this:
In Cursive there is a function "Sync files in REPL". It reloads all namespaces which changed (files edited).
So during coding after changes I can reload whole app (all modified namespaces / files) in REPL by shift+cmd+m
.
It would be great to see this option here. I use it all the time to test my code after each part of changes.
The defstate
macro from mount.core
used to define special kind of vars.
But the editor shows an error popup with message that myvar is not defined.
(defstate myvar
:start ...
Rerunning previously failed tests would be nice. As requested in the latest review here: https://marketplace.visualstudio.com/items?itemName=cospaia.clojure4vscode#review-details
In issue #2, @tjbrandt writes:
For formatting/indenting, a good example is using a let
form.
Consider the following snippet:
(let [x :first-val
y :second-val]
(println x y))
As you're typing that out, hitting the return
key after :first-val
should, if honoring the style guide, put your cursor directly below x
, so that when you then type y
, the x
and y
should be vertically aligned. However, VSCode instead either puts you back at the beginning of the next line (if auto-indent is off) or indents you only 2 spaces (if auto-indent is on).
But then, hitting return
after typing the closing bracket ]
after :second-val
, the cursor should then be placed on the next line and indented two spaces, according to the style guide. But VSCode "intelligently" decides that you're trying to indent everything at the same indentation as the last couple variables, so it then puts you directly under the y
, even though this time that's not what you wanted.
deftest
, testing
, and defn-
should be added to the oneIndentForms
array in ontype_formatter.js
.
deftest
and testing
should have the form:
(deftest my-test
(testing "some subtest description"
(test-functions-here)))
But auto-indent is doing this:
(deftest my-test
(testing "some subtest description"
(test-functions-here)))
Similarly, defining a function with defn-
should behave the same as defn
with regards to indentation. Should look like this:
(defn- private-fn [arg]
(indents-two-spaces))
Actual behavior:
(defn- private-fn [arg]
(this-is-indented-to-far))
This is one I could have fixed myself, but I haven't yet gotten ramped up on how to build and test an extension locally :)
Currently when evaluating code and showing the results inline the results disappear when the selection changes/cursor is moved.
Other editors/plugins let the evaluation results stay and you can evaluate some other piece of code and have those results displayed inline too.
This would call for another way for the user to be able to dismiss the results.
Hi there,
I am working on some Clojurescript projects that are just simple command line apps, targeting Node js.. as such, I don't need the all the features of Figwheel or Shadow-cljs e.g. reloading and browser support.
I did manage to get the repl working for Figwheel and Shadow-cljs, but it was a bit cumbersome since I needed to create and compile a 'main' cljs script first, and then manually run the resulting js script with Node before the Figwheel or Shadow-cljs would connect (in addition running to the nrepl server with lein repl
). Even then I had (Figwheel) issues, such as not being able to evaluate code with ctrl-alt-v e
in a different namespace, until said namespace had been loaded by Figwheel.. but the only way I could get that to work was by changing the file in the other namespace and saving it. This all seemed a bit complex for what I needed, so I wondered if there was a simpler solution.
I wondered if it would be possible to avoid the manual invocation of Node, and also be able to start coding from scratch without needing to create a 'main' cljs script first, by using the Node repl in Clojure 1.9. Then I found the following article describing a process that worked for Cider/Emacs, and I thought I'd try it with Calva:
https://oli.me.uk/2018-03-04-clojure-and-clojurescript-nrepl-with-clojure-cli/
The result is that it 'nearly' worked.. after starting an nrepl server with lein repl
and the needed project.clj
config (see below), I could start a Clojurescript repl (backed by Node) from the Clojure repl in Calva by running
(cider.piggieback/cljs-repl (cljs.repl.node/repl-env))
I then updated the Calva calva.startCLJSREPLCommand
setting to use this command for starting a Clojurescript repl. The result was promising, and Calva seemed to think the cljs repl was running!
However, when I tried to evaluate cljs code with ctrl-alt-v e
I got various errors, for example when evaluating (ns my-app.main)
I get
Evaluating:
my-app.main
Error: repl:13
throw e__9740__auto___19169;
^
ReferenceError: my_app is not defined
at repl:1:59
at repl:9:3
at ContextifyScript.Script.runInThisContext (vm.js:50:33)
at Object.runInThisContext (vm.js:139:38)
at Domain.<anonymous> ([stdin]:56:38)
at Domain.run (domain.js:242:14)
at Socket.<anonymous> ([stdin]:55:29)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
And when evaluating (def my-vals ["a" "b" "c"])
I get
Evaluating:
my-vals
Error: WARNING: Use of undeclared Var /my-vals at line 1 <cljs repl>
repl:1
try{cljs.core.pr_str((function (){var ret__9739__auto__ = .my_vals;
^
SyntaxError: Unexpected token .
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Domain.<anonymous> ([stdin]:56:38)
at Domain.run (domain.js:242:14)
at Socket.<anonymous> ([stdin]:55:29)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:246:13)
at Socket.Readable.push (_stream_readable.js:208:10)
Am I wrong in expecting this solution to work for Cider/Calva? I was kind of hopeful since it's working for Cider/Emacs...
Thanks!
My project.clj
config:
(defproject my-app "0.1.0-SNAPSHOT"
:description "my-app"
:dependencies [[org.clojure/clojure "1.9.0"]
[org.clojure/clojurescript "1.10.64"]]
:profiles {
:repl {:plugins [[cider/cider-nrepl "0.18.0"]]
:dependencies [[org.clojure/tools.nrepl "0.2.13"]
[cider/piggieback "0.3.8"]]
:repl-options {:nrepl-middleware [cider.piggieback/wrap-cljs-repl]}}})
I am getting a "command not found"
message for each calva function. vscode reinstallation and deleting ~ / .vscode
folder does not help.
Linux 4.16.14-2-MANJARO
Version 1.24.1
Commit 24f62626b222e9a8313213fb64b10d741a326288
Date 2018-06-13T17:47:35.732Z
Shell 1.7.12
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64
Format-on-save used to work perfectly, but lately for some reason it only works some of the time. Most times when I save nothing happens, and I have to manually save a couple more times before the formatting actually happens.
Any idea if this may be an issue with calva or if there's something else I should look into?
I am not sure this is always the case, but clojure4vscode should format the code upon saving if the user has that feature enabled. But it looks to me like it doesn't right now.
Macros are not shown in the IntelliSense list when attempting to require
a macro. Behavior is working as expected for functions.
Example:
(require [compojure.core :refer [defrou...]])
should show defroutes
as an option, but doesn't.
Hi. Thank you for calva
, it's awesome.
I found a very weird bug. In some cases when we run server
or watch
task in shadow-cljs
, start the browser and only then connect calva to the nRepl, browser console throws the error every time we hot reload the code.
Here the steps to reproduce:
npm install
or yarn
npx shadow-cljs watch app
expected result: console is clear
actual result: the error in the browser console
env.cljs:114 Uncaught TypeError: Cannot read property 'cljs$core$IFn$_invoke$arity$1' of null
at core.cljs:4199
at Object.cljs$core$some [as some] (core.cljs:4199)
at browser.cljs:205
at Function.G__24106__1 [as cljs$core$IFn$_invoke$arity$1] (core.cljs:4222)
at core.cljs:5120
at cljs.core.filter.cljs$core$IFn$_invoke$arity$2 (core.cljs:5120)
at cljs.core.LazySeq.sval (core.cljs:3394)
at cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (core.cljs:3448)
at Object.cljs$core$seq [as seq] (core.cljs:1210)
at Function.cljs.core.seq_reduce.cljs$core$IFn$_invoke$arity$3 (core.cljs:2445)
The same error happens every time shadow-cljs
reloads the code
If we first do 5 and then 4 - everything works fine.
I also tried the same steps in Emacs Cider and it works perfectly fine there.
I have Calva working fine on my Linux machine but when I try the same setup on my Mac VS Code Calva does not connect to the running nREPL. The Calva commands can't seem to be found. Please see screenshot:
I've attached my ~/.lein/profiles.clj
file (which works fine on Linux).
Any idea what's wrong?
Thank you for your help,
Eric
Hi there,
Thank you for making this tool! It's been a great improvement for me over other Clojure plugins I've tried.
I'm unable to successfully use "Calva: Run all tests". I'm running a Clojure service inside a Docker container and connecting to that with Calva. In the docker server logs, I can see logging related to my tests, but Calva/VSCode doesn't report on any passes or failures.
In the VSCode output for "Calva says", all I see is:
Running all tests
At the time the tests appear to stop running (the server stops logging anything), nothing more is printed out, and I don't see any visual feedback over my code (like failing tests highlighted).
Could this be an issue with my dev machine configuration? Or is this an unsupported use case?
Hello Peter and Pedro, my name is Piotr ^^
I've been willing to give this awesome project a try, but it looks like the outline doesn't work yet with Clojure(Script) files. What do you think it would take to add outline support to calva?
Thanks
This page documents pretty well what to do with Joker not recognizing macros: https://github.com/BetterThanTomorrow/calva/wiki/Getting-Started
It would be kind of cool if the editor would offer to create a .joker file with the offending macro. If the .joker file already exists, then it could just update it.
Not a huge deal and feel free to close it if it's too difficult, but it would be a nice addition.
I'm using Clojure, and I've been using this extension for a few weeks now and have never had the go to / peek definition working. I was thinking it would be nice if this extension had this feature, and then I noticed in the readme that it does, but mine is not working.
I noticed a closed issue related to this problem. I'm not sure if it's back with recent versions of VS Code or something else is going on with my setup. I have a fresh lein project open with no dependencies besides Clojure 1.8. My VS Code version is 1.25.1.
If I right click on a symbol and click peek definition I get "No definition found for..." My file is evaluated before trying this as well, and in the repl if I type the symbol in it shows it exists.
I have a brand-new install of VS Code, Calva and Calva Paredit (installed yesterday).
The REPL seems to work ok (see screenshot - not sure if that is required for Peek and Go to to work)
I get "No definition found" when control-clicking on the function name and choosing either Go to or Peek:
Hovering also doesn't work. I've tried this for both clj and cljs files. Any suggestions?
If I open up VSCode like this:
$ cd my-cljs-proj
$ code .
VS Code will have the Welcome page active. If I then try to connect with Calva, I'll get the error command 'calva.connect' not found
It seems to be this line:
Line 60 in 562887c
vscode.window.activeTextEditor
is undefined
when only the welcome page is showing.
Edit:
$ code --version
1.26.1
493869ee8e8a846b0855873886fc79d480d342de
x64
What you think about the idea of working a little bit on Calva's branding? What about presenting Calva more like a product?
What you think about this: Calva: Clojure & ClojureScript IDE for VSCode
A command to run the current test was requested here; https://marketplace.visualstudio.com/items?itemName=cospaia.clojure4vscode#review-details
It seems to call for a smart way to ”see” which tests is ”under the cursor”. I'll have a look at it. If someone has an idea for how this should be done, I am all ears.
The editor + REPL is a significant hurdle to beginners. There are plenty of people advocating for Clojure and REPL-driven development and showing results, but those are people who already get it. They were either really persistent or had peers to help them navigate all of the incidental complexity of setting up an app, editor and REPL to become productive. If Clojurist want broader adoption, we need to simplify the setup.
I would consider myself a Clojure beginner - I've read books, watched videos, done all of the 4Clojure problems, made simle Re-frame apps. Often with a REPL. But it's been a struggle - not from the language but from the setup. So I'm going to take my beginner mindset and lay out some of the problems I've run into and imagine the setup that I would have loved to discover when I started (and would still probably use).
lein new [TEMPLATE] NAME
. We might consider this done.(in-ns '...)
. As an experienced user, you can also turn off the auto-tracking the files. But the default REPL always represents the file you are working in.I'm sure this may be too inflexible for some experienced users. But they already have very customizable, complicated tools that they use. And that's not really VSCode+Calva's target audience. Calva could expose options to turn some of these features off. But the idea is that beginners would get an amazing, productive experience right away.
It's steps 2 and 3 that gloss over so many implementation details and potential problems. Some things, as a beginner, that I don't want (yet) to know or care about:
I don't know how you would implement step 3. Maybe it's a single dependency that is added to either profiles.clj or the project. If that was all that would be cool. Or maybe that dependency is effectively built into the editor. I really don't know.
Part of the problem is that there is a lot of mixed information out there that is out-of-date. For example:
lein dev
. But that's not actually how most people would do it - they want REPL integration with their editor. Which requires you to not run lein dev
but run something else that is editor dependent.There are a lot of people who put a lot of time into tools to make things easier. Like you guys. But it's still hard. I have a sense of why - the REPL(S) run independently of the editor, even though that's not how people generally use it. But there is still the editor/REPL divide. How do we cross it? How do we make professional tools that are easy to get started with?
It seems like you guys are thinking of similar issues and why you are putting so much work into Calva. So I thought I would share these ideas and see what you think. Are steps 1-3 unrealistic? Are 4-6 something beginners would want?
Is this an idealized version of a Clojure/Clojurescript beginner experience? Or does it look like something else?
Thanks for all of your hard work.
There seems to be a problem with the REPL connection when editing cljc
files. It's the session that is undefined in these cases. I'm looking in to it.
currently eval current form only works when the cursor is touching the form, ie:
(+ 1 2 3)| => 6
but these examples do not work:
(+ 1 2 3)
|
(+ 1 2 3) |
I'm having a problem to use the extension. I'm using the following workflow:
lein repl
or lein repl :headless
.But the only message that shows is nrepl - trying to connect, and when I gave the command for evaluate the form it doesn't respond.
My environment is Ubuntu 16.04 with leningen.
I'm lost in how to proceed, maybe I'm using it in the wrong way, any help is welcome.
Thanks
I really like this project, the fact that cljc
files have an option to switch between repls is great.
However, I'm finding the combination of ctrl-alt-v, e
really awkward to use and would like to set up alternate keybindings such as ctrl-x, ctrl-e
instead of ctrl-alt-v, e
. Is there a guide on how this can be done?
Hey guys i have been enjoying watching this project grow and would like to contribute, im just going to dump my ideas for how the ux could be improved and ill try and implement the simplest ones over the coming weeks if you think they make sense. Anyway firstly....
You added a nice switch current repl namespace to the current file command. This is handy but it would be even better if whenever the active window changes and it starts with a valid ns form it automatically does this
I really enjoy using the integrated terminal in VSCode, so I tend to start my repl using lein repl
from there.
I've noticed that clojure4vscode allows you to connect to a new REPL port if it was able to connect to some REPL at startup. But if you start VSCode first, there's no way to connect to a newly started REPL.
This is what I have to do to get it to work, which isn't ideal:
This is what I would like to work:
nrepl - trying to connect
label in the task bar, which pops up the text box that allows you to put in your newly-started REPL addressIf this is supposed to work already and I'm doing something wrong, please let me know!
Really liking what you've done with this plugin so far. Nice work!
Keep up the great work, Peter! I noticed a few format-as-you-go issues as I've been using the extension for a while, but most of it is working nicely.
Here's one, and I might file a couple more when I get around to it.
Take the following code snippet:
(ns testapp.core
(:require
[clojure.string :as string]))
If you want to add paste in [clojure.set :as set]
in as a new required namespace, do the following:
[clojure.set :as set]
string]
and hit ENTER
, which correctly lines up your cursor with the first [
[clojure.set :as set]
The auto-indentation indents the new code an extra space:
(ns testapp.core
(:require
[clojure.string :as string]
[clojure.set :as set]))
An example with slightly different behavior. Start with this:
(let [var1 :test]
(do-something))
var1 :test
:test
to add a new binding to the binding list and hit ENTER
, which correctly aligns your cursor under var1
The pasted text this time gets un-indented in a strange way:
(let [var1 :test
var1 :test]
(do-something))
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.