• Stars
    star
    533
  • Rank 83,238 (Top 2 %)
  • Language
    Rust
  • License
    ISC License
  • Created over 6 years ago
  • Updated 7 months ago

Reviews

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

Repository Details

A Rust port of parinfer.

parinfer-rust

Infer parentheses for Clojure, Lisp and Scheme.

A full-featured, super fast implementation of Shaun Lebronโ€™s parinfer. This repo has Vim, Neovim, and Kakoune plugins, and an Emacs plugin is available. The Rust library can be called from other editors that can load dynamic libraries.

This plugin, unlike others available for Vim, implements "smart" mode. Rather than switching between "paren" mode and "indent" mode, parinfer uses information about how the user is changing the file to decide what to do.

Installing

Dependencies:

  • rust >= 1.36

  • clang and libclang-dev packages or equivalent for your OS

Stand-alone CLI

If you just want to run parinfer-rust from the command-line:

$ cargo build --release
$ cargo install

If you use emacs add the corresponding feature flag during compilation

$ cargo build --release --features emacs

Vim and Neovim

pathogen

If you are using Tim Popeโ€™s pathogen:

$ cd ~/.vim/bundle
$ git clone [email protected]:eraserhd/parinfer-rust.git
$ cd ~/.vim/bundle/parinfer-rust
$ cargo build --release

vim-plug

Plug 'eraserhd/parinfer-rust'

Then, build project using cargo:

$ cd /path/to/parinfer-rust
$ cargo build --release

Or, with optional automatic recompilation on update:

Plug 'eraserhd/parinfer-rust', {'do':
        \  'cargo build --release'}

If you are a NixOS user using Plug, you can use this command instead:

Plug 'eraserhd/parinfer-rust', {'do':
        \ 'nix-shell --run \"cargo build --release \"'}

Nix

If you are a Nix user using Nix + Home Manager to build your vim plugins, you can add:

programs.neovim = {
    [ pkgs.vimPlugins.parinfer-rust ];
}

Kakoune

plug.kak

Add this to your kakrc

plug "eraserhd/parinfer-rust" do %{
    cargo install --force --path .
} config %{
    hook global WinSetOption filetype=(clojure|lisp|scheme|racket) %{
        parinfer-enable-window -smart
    }
}

Re-source your kakrc or restart Kakoune. Then run :plug-install. plug.kak will download, build and install plugin for you. Optionally add cargo clean line to the do block to clean plugin from build files, thus making it load a bit faster.

Manual

$ cd ~/my-projects
$ git clone [email protected]:eraserhd/parinfer-rust.git
$ cd parinfer-rust
$ make install
$ cargo build --release
$ cargo install

Add this to your kakrc

hook global WinSetOption filetype=(clojure|lisp|scheme|racket) %{
    parinfer-enable-window -smart
}

NixOS or nix-darwin

{
  environment.systemPackages = let
    myKakoune = pkgs.wrapKakoune pkgs.kakoune-unwrapped {
      configure = {
        plugins = with self.kakounePlugins; [
          parinfer-rust
        ];
      };
    };
  in [ myKakoune ];
}

Alternately, you can add your plugins as an overlay:

{
  nixpkgs.overlays = [
    (self: super: {
      kakoune = super.wrapKakoune self.kakoune-unwrapped {
        configure = {
          plugins = with self.kakounePlugins; [
            parinfer-rust
          ];
        };
      };
    })
  ];

  environment.systemPackages = [ pkgs.kakoune ];
}

Emacs

To install parinfer-rust for Emacs follow the instructions at parinfer-rust-mode.el

Building WebAssembly

WebAssembly currently needs the ``nigthly'' toolchain:

$ rustup update
$ rustup install nightly
$ rustup target add wasm32-unknown-unknown --toolchain nightly
$ cargo +nightly install cargo-web

It can then be built with:

$ cargo +nightly web build --release

Tests

The CI server uses [Nix](https://nixos.org/nix/download.html) to make reproducible build and test environments. Itโ€™s a good idea to run tests with it.

$ nix-build release.nix                  # Build and test everything
$ cargo test                             # Run the native tests
$ cargo +nightly web test                # Test the WebAssembly version
$ vim --clean -u tests/vim/run.vim       # Test against locally-installed Vim
$ ( cd tests/kakoune && ./run.sh )       # Test against locally-installed Kakoune
$ nix-build release.nix -A vim-tests     # Test against Nix Vim package
$ nix-build release.nix -A neovim-tests  # Test against Nix Neovim package
$ nix-build release.nix -A kakoune-tests # Test against Nix Kakoune package

Vim tests are in a nice, readable format in tests/vim/test-cases.md. Please add tests for any new features (or even old ones!). You can set the VIM_TO_TEST environment variable to Vimโ€™s path to test weird or different builds.

Contributors

This wouldnโ€™t be possible without the work of others:

  • Shaun Lebron - Inventing parinfer and doing the math.

  • Case Nelson - Writing the nvim-parinfer, from which VimL code and some inspiration was stolen.

  • Justin Barclay - Emacs module.

  • Michael Camilleri - User-defined comments.

  • Mitsuhiro Nakamura - Support for Common Lisp and Scheme.

  • ElKowar - User-defined string-delimiters and support for Yuck.

License

More Repositories

1

vim-ios

iOS plugin for Vim
Ruby
165
star
2

rep

A single-shot nREPL client designed for shell invocation
C
93
star
3

kak-ansi

Kakoune support for rendering ANSI-colored text.
C
40
star
4

objective-vim

Quickly bootstrap vim for Objective-C hacking
Vim Script
33
star
5

dotfiles

Nix
19
star
6

Idris-json

Formally verified JSON parser
Idris
14
star
7

vim-kiwi

vim plugin for doing Kiwi BDD
Vim Script
12
star
8

osxsnarf

A Plan 9-inspired way to share your OS X clipboard to multiple hosts.
C
11
star
9

clara-eql

Clojure
9
star
10

kak-plumb

Kakoune integration with the plan9port plumber
Shell
9
star
11

nix-zmk

Nix building and dev environments for ZMK
Nix
9
star
12

Idris-book

Idris for Everybody
TeX
9
star
13

select-nrepl

Text-object support for your editor as nREPL middleware.
Clojure
8
star
14

objc-kata

Skeleton and Makefile for running Objective-C katas
Vim Script
8
star
15

tmux-ctrlw

Emulate Vim's C-w in tmux, making pane navigation really snazzy.
Shell
7
star
16

ehk

What @eraserhd knows
C
6
star
17

acd

Apple Coder utility
Ruby
4
star
18

git-zeal

Zealously run your tests (on every commit)
Shell
4
star
19

tmux-plumb

Send text to the Plan 9 plumber from tmux copy mode.
Shell
3
star
20

markdorg-vim

A somewhat brutal mashup of Org Mode and Markdown.
Vim Script
2
star
21

presentations

My presentations
2
star
22

kb

Keyboard files
OpenSCAD
2
star
23

flow

Solver for the mobile "Flow" game
Scheme
2
star
24

im

Improbable Mission - A clone of the C64 "Impossible Mission"
C++
2
star
25

gd

Binding to the libgd library from Haskell.
Haskell
2
star
26

clojerbil

Scheme
2
star
27

onesock

Creative use of a scanner to do your bills
Haskell
2
star
28

impromptu

Spawn $EDITOR to update association list for CLI scripts
Scheme
2
star
29

ehhack

Vim plugin for writing hacks in various languages super quick
Ruby
2
star
30

kak-jira

Kakoune syntax files for JIRA markup
Nix
2
star
31

rkanban

R utilities for working with software kanban board data
2
star
32

gitout

Scheme
1
star
33

vigilance

Automatically exported from code.google.com/p/vigilance
C++
1
star
34

android-workbench

An alternate build system for Android
1
star
35

git-story

a 'story' subcommand for git for developing tickets on branches
CoffeeScript
1
star
36

gewgaw

Shows an overlay on windows to allow keyboard selection in scripts
C
1
star
37

markdorg-cli

Command-line tool for Markdorg
Makefile
1
star
38

ehgml

ICFP 2000 ray tracer
C++
1
star
39

phptools

An old project for parsing PHP
Scheme
1
star
40

rest-test

Example Clojure REST service
Clojure
1
star
41

gerbil-bencode

Scheme
1
star
42

tmux-editor-copy-mode

Shell
1
star
43

kak-open

Shell
1
star
44

toggl

Add time to toggl
Haskell
1
star
45

facts

Scheme
1
star
46

zmk-config

1
star
47

cl-infix

Infix operators for common lisp
Common Lisp
1
star
48

add-missing

Shell
1
star
49

sqltools

Go
1
star
50

window-sigils

C
1
star
51

suggest-commit

Pre-populate commit messages with likely text
C
1
star
52

git-zeal-vim

Vim helpers for git-zeal
Vim Script
1
star