Giter Site home page Giter Site logo

jamesmintram / calva Goto Github PK

View Code? Open in Web Editor NEW

This project forked from betterthantomorrow/calva

0.0 1.0 0.0 41.84 MB

Calva: Clojure & Clojurescript interactive programming made easy - Evaluate code, run tests, navigate to definitions, see docs, interactive REPLs, etcetera.

Home Page: https://marketplace.visualstudio.com/items?itemName=betterthantomorrow.calva

License: Other

TypeScript 71.28% Clojure 22.16% JavaScript 1.94% CSS 3.69% HTML 0.93%

calva's Introduction

Calva: Clojure & ClojureScript support for VS Code

Calva logo

Welcome to Calva, an easy to use, integrated REPL powered environment for enjoyable and productive Clojure and ClojureScript coding. It includes inline code evaluation, Paredit (and some little Parinfer), a Clojure formatter, a test runner, Clojure syntax highlighting, and more. Much of the power is provided by The Orchard.

Calva is short for Calvados, a liquid gifted to humanity from God. It is distilled from Cider.

Raison d´être

With Calva I hope to help lowering the barriers into the Clojure world. The idea is that by leveraging the strengths of VS Code and nREPL, I can offer a turn-key, productive, environment in which to learn and to use Clojure and ClojureScript.

How to Connect Calva to your project

Connect by letting Calva start your project (a.k.a. Jack-in).

  1. Open your project in VS Code.
  2. Issue the command Start a REPL project and connect: ctrl+alt+c ctrl+alt+j.
  3. Answer the quick-pick prompts telling Calva about project types and what profiles to start.

When Calva has connected, it will open a REPL window giving you some getting started tips, and you can start hacking. The first thing you should always do to ”wake” Calva is to load/evaluate the current Clojure(Script) file: ctrl+alt+c enter.

Troubles connecting? Check here. (Please help keeping that wiki page updated.)

Something to try first

You might want to start with evaluating some code. Calva has this notion about the ”current” form (the symbol under the cursor or the paren enclosed s-expr immediately adjacent to the cursor). Issue the Evaluate current form (or selection) command: ctrl+alt+c e.

There are also a command for evaluating the current top level form. Which I use even more often, especially since it works inside (commment) forms and supports my way of experimenting with my code. It looks something like so:

Annotate clojure code evaluation!

See Calva Top 10 Commands for some more things to try.

The Calva Wiki

When something doesn't work and you think there might be a workaround for it, please see the wiki. Anyone can author the wiki so if you know about workarounds or gotchas or anything that is good to know about when usin Calva, please edit the approriate page (or create a new page).

Features

At a glance

Demo: switch between clj and cljs repl sessions for cljc files:

CLJC repl switching

More in depth (and some usage info)

  • Running tests through the REPL connection, and mark them in the Problems tab
    • Run namespace tests: ctrl+alt+c t
    • Run all tests: ctrl+alt+c shift+t
    • Rerun previously failing tests: ctrl+alt+c ctrl+t
    • Marks test failures using the Problem tab
    • User setting for running namespace tests on save (defaults to on)
    • Caveat: Right now the tests are reported only when all are run, making it painful to run all tests in larger projects. I'll fix it. Promise!
  • Code evaluation
    • Evaluate code at cursor and show the results as annotation in the editor: ctrl+alt+c e
      • Dismiss the display of results by pressing escape (there is info on the wiki for vim extension users).
    • Evaluate code and replace it in the editor, inline: ctrl+alt+c r
    • Pretty printing evaluation resuls: ctrl+alt+c p (Currently broken, see issues on Github).
    • Evaluate current top level form (based on where the cursor is) and show results inline: ctrl+alt+c space
      • Send the current top level form to the REPL terminal: ctrl+alt+c alt+space
    • Error information when evaluation fails (at least a hint)
    • Support for cljc files and you can choose if they should be evaluated by the clj or the cljc repl session.
    • Enables clj repl for all files/editors. You now can evaluate those clojure code snippets in Markdown files.
    • The evaluation commands will auto-”detect” vectors and maps as well as list.
    • User setting to evaluate namespace on save/open file (defaults to on)
  • Integrated REPLs
    • Switch to current namespace in the REPL window: ctrl+alt+c n
    • Load current namespace in the REPL window: ctrl+alt+c alt+n
    • Evaluate code from the editor to the REPL window: ctrl+alt+c alt+e
  • When editing cljc files, easily choose if repl commands should go to the clj or cljs repl by clicking the cljc/clj[s] indicator in the status bar.
  • Selection of current form: ctrl+alt+c s. Auto-detected the same way as for evaluation. Will select the form preceding or following the cursor first, otherwise the form the cursor is inside. (Only when the cursor is directly adjacent to any bracket so far.)

Demo: Peek at defintions, etcetera:

Features

Calva Paredit and Calva Formatter included

With Calva you also get structural editing using Paredit and formatting.

You really should have a look at the READMEs for those as well. One thing to note about it is that Calva Formatter sets the default keybinding of the Format current form command to tab. Good to know, right?

Slurp and Barf keyboard shortcuts

To make slurping and barfing forward really easy to perform they are bound to ctrl+right and ctrl+left, respectively. However on MacOS those shortcuts are sometimes bound by Mission Control, causing the Calva shortucts to not work. One way to solve it is to disable the shortcuts in System Preferences -> Keyboard -> Shortcuts:

Disable Mission Control Shortcuts

Clojure Warrior included

This extension bundles @tonsky's Clojure Warrior. Bringing you, amongst other things, rainbow parens and sane bracket matching.

Note. If you for some reason do not want rainbow colors, put this in your settings.json:

    "clojureWarrior.enableBracketColors": false

Where is Calva heading?

There are lots of stuff that needs attention and lots of possible features to add. Please see the Github issue tracker for those things. And please regard it as a way to inform me about what is most important. (There are other ways for that as well, see below.)

Right now I am happy to have released a major upgrade to Calva (”Calva dos” as they say in Spanish), but I am not satisfied. I want to make Calva an even better choice for people starting with Clojure and ClojureScript, so that is where my focus will be. Please consider helping me!

How to contribute

I'm glad you are reading this section!

Calva is built using a combination of TypeScript and ClojureScript. The ClojureScript part uses the shadow-cljs toolchain. See the How to Contribute page on the wiki for instructions on how to hack on Calva.

Other

Started from Visual Clojure

Calva once started off as a clone of the promising (but abandoned) visual:clojure extension.

Happy coding ❤️

I hope you will find good use for Calva. Please let me know what you think. PRs welcome, file an issue or chat me up in the #calva-dev channel in the Clojurians Slack, (I'm @pez there). I would appreciate tweets about Calva too, and extra points for mentioning @pappapez.

calva's People

Contributors

alek-sys avatar andersmurphy avatar andresrgz avatar arjunattam avatar bbatsov avatar bpringe avatar clows avatar dharrigan avatar gnurdle avatar hjers avatar ibexian avatar julienvincent avatar kstehn avatar martinbertolino avatar metaforte avatar mrkam2 avatar mseddon avatar pedrorgirardi avatar pez avatar sivertsenstian avatar slipset avatar taylorwood avatar teves-castro avatar thheller avatar trevor-brandt avatar waffle-iron avatar

Watchers

 avatar

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.