Giter Club home page Giter Club logo

parinfer-rust-mode's Introduction

https://circleci.com/gh/justinbarclay/parinfer-rust-mode.svg?style=svg

Parinfer

Parinfer is a plugin that aims to make writing lisp simple. This library wraps justinbarclay/parinfer-rust to provide an Emacs minor mode. parinfer-rust-mode aims to be a simpler adaptation of Parinfer that only offers “smart mode”, leveraging the parinfer-rust plugin to do most of the heavy lifting.

Capabilities:

  • Making code auto-adhere to formatting conventions
  • Influencing expression-nesting with indentation
  • Maintaining indentation when expressions shift
  • Allowing Paredit-like features without hot keys

Requirements

  1. Emacs (25+) compiled with Dynamic Module support.
  2. Running on MacOS/Linux, with Windows support coming soon.
  3. (Optional) Curl - to download the library for you

Installation

Option 1: Building library from sources

Step 1: Build the Parinfer Rust library

When compiling manually the library name differs from platform to platform. Additionally, Emacs expects that these libraries have specific file extensions when first loading them up. This is a problem for MacOS because Rust compiles it as .dylib and we’ll need to give the file an .so extension when we copy it to it’s final location.

PlatformFile nameRequired extension
Linuxlibparinfer_rust.so.so
MacOSlibparinfer_rust.dylib.so
Windowsparinfer_rust.dll.dll
git clone https://github.com/eraserhd/parinfer-rust.git
cd parinfer-rust
cargo build --release
cp ./target/release/${library-name} ~/.emacs.d/parinfer-rust/${lib-name}

Step 2: Configure parinfer-rust-mode

Once you have compiled the libraries from source code you’ll need to tell parinfer-rust-mode how to find these libraries

(setq parinfer-rust-library "/path/to/parinfer-rust-library.so")

Option 2: Manual

Step 1: Download parinfer-rust-mode

cd /path/for/elisp-packages
git clone [email protected]:justinbarclay/parinfer-rust-mode.git

Step 2: add the following to your init.el file

(add-to-list 'load-path "/path/to/parinfer-rust-mode")
(add-hook 'emacs-lisp-mode 'parinfer-rust-mode)

Option 3: MELPA

Coming soon?

Commands

KeyCommandDescription
C-c sparinfer-switch-modeQuickly switch between paren, indent, and smart modes
C-c dDisable parinfer-rust-modeSometimes you need to make a change or undo things quickly and the easiest way to accomplish that is with parinfer-rust-mode disabled.

Modes

Parinfer can operate under three different modes when writing lisp.

Paren

Paren Mode gives you full control of parens, while Parinfer corrects indentation. You can still adjust indentation, but you won’t be able to indent/dedent past certain boundaries set by parens on previous lines.

./videos/paren-mode.gif

Indent

Indent Mode gives you full control of indentation, while Parinfer corrects or inserts close-parens where appropriate. Specifically, it only touches the groups of close-parens at the end of each line.

./videos/indent-mode.gif

Smart

Smart Mode is like Indent Mode, but it tries to preserve the structure too.

./videos/smart-mode.gif

parinfer-mode

There is an alternate implementation of Parinfer for Emacs called parinfer-mode. It currently has support for Parinfer’s “paren” and “indent”. Additionally, it has had experimental support for “smart” mode, however, this has remained hidden on a branch and not accessible from MELPA for over a year. parinfer-smart-mode aims to be a simpler adaptation of Parinfer that just offers “smart mode”, leveraging the parinfer-rust plugin to do most of the heavy lifting.

Known Issues

  • This is still alpha software and parinfer-rust has been known to get Out of Memory warnings and cause Emacs to crash, so use at your own risk.
  • Multiple cursors do not work as intended
  • Does not play well with other modes that insert parens or manage whitespace. If you have modes like electric-pair-mode or hungry-delete-mode enabled, you may want to disable them for any mode that has parinfer-rust-mode enabled. To help users work around this we offer to disable known troublesome modes if we detect them.

Thanks

  • Shaun Lebron for creating Parinfer
  • Jason Felice for creating and maintaining the parinfer-rust project
  • tianshu for helping me fall in love with parinfer-mode in Emacs.

parinfer-rust-mode's People

Contributors

justinbarclay avatar mack1070101 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.