Parinfer
Parinfer plugin for Sublime Text
Details
Installs
- Total 2K
- Win 471
- Mac 1K
- Linux 545
Apr 20 | Apr 19 | Apr 18 | Apr 17 | Apr 16 | Apr 15 | Apr 14 | Apr 13 | Apr 12 | Apr 11 | Apr 10 | Apr 9 | Apr 8 | Apr 7 | Apr 6 | Apr 5 | Apr 4 | Apr 3 | Apr 2 | Apr 1 | Mar 31 | Mar 30 | Mar 29 | Mar 28 | Mar 27 | Mar 26 | Mar 25 | Mar 24 | Mar 23 | Mar 22 | Mar 21 | Mar 20 | Mar 19 | Mar 18 | Mar 17 | Mar 16 | Mar 15 | Mar 14 | Mar 13 | Mar 12 | Mar 11 | Mar 10 | Mar 9 | Mar 8 | Mar 7 | Mar 6 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Mac | 2 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 |
Linux | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 0 |
Readme
- Source
- raw.githubusercontent.com
Parinfer for Sublime Text
A Parinfer package for Sublime Text.
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
Package Control
If you have Package Control installed, you can easily install the Parinfer package:
- In Sublime Text, open the Command Palette by typing Ctrl+Shift+p (Cmd+Shift+p on Mac)
- Type
install
and selectPackage Control: Install Package
- A text prompt should appear shortly after Package Control loads a list of packages from the Internet.
- Type
parinfer
and press Enter - That's it! Parinfer is now installed.
Linux / OSX
You can symlink the the parinfer repo to the Sublime Text Packages directory.
cd ~
git clone git@github.com:oakmac/sublime-text-parinfer.git
ln -s ~/sublime-text-parinfer ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/Parinfer
Windows
cd %APPDATA%\Sublime Text 2\Packages
git clone https://github.com/oakmac/sublime-text-parinfer.git Parinfer
Usage
File Extensions
Once the package has been installed, it will automatically load in the
background when you open Sublime Text and watch for file extensions found in a
config file. The default file extensions are: .clj
.cljs
.cljc
.lfe
.rkt
You can edit these file extensions by going to Preferences –> Package Settings –> Parinfer –> Settings - Default
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 likely scenario once you start using Parinfer regularly.
- Paren Mode changed the file. The buffer will receive the changes and you will be dropped into Indent Mode. This is most likely to happen when you first start using Parinfer on an existing file.
- Paren Mode failed. This is almost certainly caused by having unbalanced parens in your file (ie: it will not compile). The text will not be changed and you will be dropped into Paren Mode in order to fix the problem.
Running Paren Mode is a necessary first step before Indent Mode can be safely turned on. See Fixing existing files for more information.
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 :)
Hotkeys and Status Bar
Command | Windows/Linux | Mac |
---|---|---|
Turn on / Toggle Mode | Ctrl+( | Cmd+( |
Turn off | Ctrl+) | Cmd+) |
The status bar will indicate which mode you are in or show nothing if Parinfer is turned off.
Future Features
More options and configuration settings are planned for future releases. Browse the issues for an idea of future features. Create a new issue if you can think of a useful feature :)
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 #23; please add to
that if you experience problems.