Giter Club home page Giter Club logo

parinfer-rust's Introduction

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

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, you can use this command instead:

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

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
}

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.

License

parinfer-rust's People

Contributors

eraserhd avatar andreyorst avatar cbcoutinho avatar anticrisis avatar justinbarclay avatar wbthomason avatar jlesquembre avatar amarshall avatar oakmac avatar nsmaciej avatar

Watchers

James Cloos 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.