• Stars
    star
    204
  • Rank 192,063 (Top 4 %)
  • Language
    Clojure
  • License
    ISC License
  • Created about 9 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Parinfer for Atom

Parinfer for Atom

A Parinfer package for Atom.

What is Parinfer?

Parinfer is a text editing mode that can infer Lisp code structure from indentation (and vice versa). A detailed explanation of Parinfer can be found here.

Put simply: the goal of Parinfer is to make it so you never have to think about "balancing your parens" when writing or editing Lisp code. Just indent your code as normal and Parinfer will infer the intended paren structure.

Installation

  1. Install Atom
  2. In Atom, pull up the Settings tab by pressing Ctrl+, (Cmd+, on Mac) or using the main menu Edit --> Preferences
  3. Click on the Install tab
  4. Search for "parinfer" and find this package
  5. Press the Install button :)

Usage

File Extensions

Once the package has been installed, it will automatically load in the background when you open Atom and watch for file extensions of popular Lisp languages. The file extensions are listed here and can be changed in the Settings.

Opening a File

When a file with a recognized extension is first opened, Parinfer runs Paren Mode on the entire file and one of three things will happen (in order of likelihood):

  • The file was unchanged. You will be automatically dropped into Indent Mode. This is the most common scenario once you start using Parinfer regularly.
  • Paren Mode changed the file. You will be prompted to apply the changes (recommended) and then dropped into Indent Mode. This is common the first time you use Parinfer on a file.
  • Paren Mode failed. This scenario is uncommon and almost certainly means you have unbalanced parens in your file (ie: it will not compile). A prompt will show and you will be dropped into Paren Mode in order to fix the syntax problem.

Running Paren Mode is a necessary first step before Indent Mode can be safely turned on. See Fixing existing files for more information.

If you do not want to be prompted when opening a new file, the prompts can be disabled in the Settings.

Please be aware that - depending on the indentation and formatting in your Lisp files - this initial processing may result in a large diff the first time it happens. Once you start using Indent Mode regularly, this initial processing is unlikely to result in a large diff (or any diff at all). You may even discover that applying Paren Mode to a file can result in catching very hard-to-find bugs in your existing code! As usual, developers are responsible for reviewing their diffs before a code commit :)

If you want to convert a project over to Parinfer-compatible indentation, please check out the Parlinter project.

Hotkeys and Status Bar

Command Windows/Linux Mac
Turn on / Toggle Mode Ctrl+Shift+( Cmd+Shift+(
Turn off Ctrl+Shift+) Cmd+Shift+)

The status bar will indicate which mode you are in or show nothing if Parinfer is turned off.

If you are in Paren Mode and Parinfer detects unbalanced parens (ie: code that will not compile), the status bar text will be red. Note that this will never happen in Indent Mode because Parinfer ensures that parens are always balanced. Also note that there is a known bug with this feature due to the "parent expression" hack explained below.

Known Limitations

This extension uses a hack for performance reasons that may act oddly in certain circumstances. It assumes that an open paren followed by an alpha character - ie: regex ^\([a-zA-Z] - at the start of a line is the beginning of a new "parent expression" and tells the Parinfer algorithm to start analyzing from there until the next line that matches the same regex. Most of the time this is probably a correct assumption, but might break inside multi-line strings or other non-standard circumstances. This is tracked at Issue #9; please add to that if you experience problems.

Interestingly, Shaun discovered that this hack is not new. Someone else used the same approach 36 years ago :)

Plugin Development Setup

Install Leiningen.

# clone this repo to your homedir
cd ~
git clone https://github.com/oakmac/atom-parinfer.git

# symlink the repo to the Atom packages folder
ln -s ~/atom-parinfer ~/.atom/packages/parinfer

# compile CLJS files
lein cljsbuild auto

Then run Atom on a Lisp file. Some development notes:

  • View > Developer > Reload Window (to reload plugin changes)
  • View > Developer > Toggle Developer Tools (to see console)

License

ISC License

More Repositories

1

chessboardjs

JavaScript chessboard
JavaScript
1,919
star
2

cuttle

User Interface for the ClojureScript Compiler
JavaScript
315
star
3

vscode-parinfer

Parinfer for VS Code
JavaScript
167
star
4

parinfer-elisp

Parinfer in Emacs Lisp
Emacs Lisp
97
star
5

chessboard2

chessboard.js v2
Clojure
85
star
6

autocompletejs

AutoCompleteJS Widget
JavaScript
72
star
7

cljs-cheatsheet

a ClojureScript Cheatsheet
Clojure
67
star
8

sublime-text-parinfer

Parinfer plugin for Sublime Text
Python
57
star
9

parinfer-viml

Parinfer in Vimscript
Vim Script
51
star
10

tree-sitter-clojure

Clojure / ClojureScript grammar for tree-sitter
C
32
star
11

record-linking-talk

Slides + code for my talk on Record Linking at Clojure/conj 2019
JavaScript
30
star
12

standard-clojure-style-js

Standard Clojure Style in JavaScript
Clojure
26
star
13

cljs-logo

ClojureScript logo
22
star
14

tourney-bot

an app to run the Houston Ultimate Indoor Tournament
Clojure
18
star
15

kidif.js

Store raw text as structured data in simple text files.
JavaScript
17
star
16

parinfer-lua

Parinfer core algorithm in Lua
Lua
16
star
17

snowflake-css

Snowflake CSS - simplify your CSS with globally unique selectors
Clojure
13
star
18

humble-animations

Animations using HumbleUI
Clojure
12
star
19

parinfer-jvm

Parinfer on the JVM
Kotlin
12
star
20

sublime-pretty-edn

Format, Validate, Minify EDN files in Sublime Text
Python
9
star
21

parinfer.py

Parinfer in Python
Python
9
star
22

flex-class-capstone-project-requirements

Capstone Project Requirements for DigitalCrafts Flex Class Houston
7
star
23

phase3-react-project-requirements

Phase 3 React Project Requirements for DigitalCrafts Flex coding bootcamp
6
star
24

teaching-resources

List of Teaching Resources
5
star
25

phase2-backend-project-requirements

Phase 2 Backend Project Requirements for DigitalCrafts Flex coding bootcamp
5
star
26

clojurescript-radio

Implementing a radio using ClojureScript and React
CSS
5
star
27

humble-mondrian

Piet Mondrian painting in HumbleUI
Clojure
4
star
28

phase1-final-project-requirements

Final Project Requirements for Phase 1 - DigitalCrafts Flex coding bootcamp
4
star
29

flexbox-layout-exercises

CSS Layout Exercises using Flexbox
4
star
30

Professional-JavaScript

Talk on JavaScript to the Houston.js group for March 2012
JavaScript
4
star
31

cljs101

Beginning Exercises for a ClojureScript Programmer
Clojure
3
star
32

professional-clojurescript-curriculum

Curriculum and Lesson Outlines for Professional ClojureScript Course
3
star
33

jquery-login-form

Create a login form using jQuery and AJAX
JavaScript
3
star
34

object-oriented-calculator

Create a JavaScript calculator widget in a object-oriented fashion
JavaScript
3
star
35

js201

JavaScript Exercises for beginners
JavaScript
3
star
36

react-concepts

Some examples to help teach the concepts behind React.js
JavaScript
3
star
37

open-ideas

a Place to Store Ideas
2
star
38

hat-tourney-builder

UI for sorting players for an Ultimate Hat Tournament (random teams)
HTML
2
star
39

clojurescript-for-javascript-developers

2
star
40

Introducing-AutoCompleteJS

talk for the Houston JS group 26 March 2013
JavaScript
2
star
41

js101

js101 Exercises
JavaScript
2
star
42

humble-modal-example

Example Modal component using HumbleUI
Clojure
2
star
43

react-state-examples

Teach some common state management patterns using React
Clojure
2
star
44

calculate-tournament-results

A programming puzzle using higher-order functions.
JavaScript
2
star
45

Pidgin-Plugin-block-user-has-left-the-conversation

simple pidgin plugin to block the <user> has left the conversation system messages.
C
2
star
46

intro-to-ajax

Introduction to AJAX Programming
JavaScript
2
star
47

re-frame-talk

Slides and code for my talk about using Re-Frame and ClojureScript - Houston Functional Meetup, March 2019
Clojure
2
star
48

shipping-packages-puzzle

Shipping Packages Logic Puzzle (programming exercise)
2
star
49

mori-react-example

An example of using Mori.js with React.js
JavaScript
1
star
50

rice-talk

talk to Rice CS undergrads, Jan 2014
1
star
51

flex-class-2018-02

Live Code from lectures for the Digital Crafts Flex Class 2018-02
JavaScript
1
star
52

professional-javascript-short

Short version of Professional JavaScript talk (originally for Houston Techfest 2013)
JavaScript
1
star
53

connect-four

Connect Four assignment
JavaScript
1
star
54

tourney-nerd

library to handle Ultimate tournament logic
Clojure
1
star
55

why-cljs

slides for Why ClojureScript? talk, March 2014
CSS
1
star
56

threading-macros.info

Clojure threading macros animations
CSS
1
star
57

JavaScript-Patterns

1
star
58

usb-file-sorter

Sort files on a USB drive
JavaScript
1
star
59

houstonbudget.info

Visualization of the Houston Budget
JavaScript
1
star
60

headmaster

Coding Bootcamp Classroom Tracking System
JavaScript
1
star
61

cljs-color-clock

Color Clock Assignment using ClojureScript
Clojure
1
star
62

example-build-system

An example build system for a simple website.
JavaScript
1
star
63

clojurescript-tic-tac-toe

Tic-Tac-Toe implemented in ClojureScript. Used as a teaching exercise for the Professional ClojureScript course (https://cljs.pro)
HTML
1
star
64

color-clock

JavaScript
1
star
65

example-tic-tac-toe

Example Tic Tac Toe Game
JavaScript
1
star
66

re-frame-project-skeleton

create a project skeleton for a re-frame application
Clojure
1
star
67

parinfer-annotations

Parinfer annotation helper library
JavaScript
1
star
68

basic-express-with-knex

JavaScript
1
star
69

Pidgin-Plugin--Block-AOL-System-Msg

Simple plugin to block messages from "AOL System Msg" in Pidgin.
C
1
star
70

js201-continued

JavaScript Exercises for beginners (part 2)
JavaScript
1
star