Giter VIP home page Giter VIP logo

conjure-efroot's Introduction

Conjure Ef[fective]root

Conjure extension that allows evaluating top-level forms, ignoring comment forms. That is, evaluating the effective root form: the top-most form under the cursor that is not a comment-form.

During REPL driven development we often evaluate forms in so called Rich comment blocks: forms enclosed in a comment-form, which are ignored by the Clojure compiler, but very useful for development with a REPL.

Conjure supports evaluating the root form under the cursor, but when that root form is a comment-form, it dutifully does nothing. This is technically correct behavior, but it would be more convenient if we could easily evaluate the effective root form in Rich comments.

Efroot enables that behavior by adding the commands ConjureEvalEffectiveRootForm and ConjureEvalCommentEffectiveRootForm, which does the same as ConjureEvalRootForm and ConjureEvalCommentRootForm respectively, but ignores top-level comment-forms. These new commands reuse the original mappings.

Requires Conjure.

Installation

Using vim-plug:

Plug 'walterl/conjure-efroot'

Usage

Suppose you are testing generation of a configuration file in your REPL, in a Rich comment like in this example:

(comment
  (do
    (spit "config.edn" (pr-str (generate-config)))
    (let [config (edn/read-string (slurp "config.edn"))]
      (get-in config [:server :port])))
  )

When making changes inside the let-form's body, you want to re-evaluate the entire do-form, but moving the cursor back and forth between the editing position and the do-form (so you can call ConjureEvalCurrentForm) is cumbersome.

Calling :ConjureEvalEffectiveRootForm from the let-form's body will evaluate the do-form.

Mappings

  • <LocalLeader>er - Evaluates the effective root form under the cursor.
  • <LocalLeader>ecr - Evaluates the effective root form under the cursor and adds the result as a comment after the form.

The original ConjureEvalRootForm and ConjureEvalCommentRootForm commands are remapped to <LocalLeader>eR and <LocalLeader>ecR, respectively.

Caveats

Efroot does not use tree-sitter functionality. It also does more work than ConjureEvalRootForm, increasing with each form nesting level. Performance could therefore become an issue when evaluating deeply nested forms, but that has not been observed yet.

This is because Efroot first collects all forms along the form tree, "between" the current (inner-most) form and the root form, inclusive.

License

MIT

conjure-efroot's People

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.