Git Product home page Git Product logo

rubyfmt's Introduction

How do I pronounce rubyfmt

  • en: Ruby format
  • jp: ルビーフォーマット

How do I use it

Install from brew

On Mac and Linux, rubyfmt can be installed with Homebrew:

brew install rubyfmt

Build from source

  1. Make sure you've got cargo installed
  2. Run make all
  3. Copy target/release/rubyfmt-main to somewhere on your path as rubyfmt

Rubyfmt supports the following CLI invocations:

  • <whatever> | rubyfmt pipe from standard in
  • rubyfmt -i -- files or directories to format files and directories in place
  • rubyfmt -- files or directories output rubyfmtted code to STDOUT.
  • rubyfmt -c -- files or directories output a diff of input and rubyformatted input.
  • rubyfmt --header-opt-in -- files or directories to format files only with a # rubyfmt: true comment at the top of the file
  • rubyfmt --header-opt-out -- files or directories to skip formatting files with a # rubyfmt: false comment at the top of the file

rubyfmt also supports ignoring files with a .rubyfmtignore file when present in the root of the working directory. .rubyfmtignore uses the same syntax as .gitignore, so you can choose to ignore whole directories or use globs as needed. By default, rubyfmt also ignores files in .gitignore during file traversal, but you can force these files to be formatted by using the --include-gitignored flag.

Editor Support

Vim

We aren't currently tested with any vim plugin managers, however, adding the plugin from a git clone is fairly easy:

  • Run cargo build --release
  • Add source /path/to/rubyfmt.vim to your ~/.vimrc (e.g. my dotfiles please note, this line is commented)
  • Add let g:rubyfmt_path = /path/to/target/release/rubyfmt-main beneath the source line

Neovim + LSP + null-ls

If you use the popular null-ls LSP plugin to manage formatters, it supports rubyfmt out of the box. You can add the formatter to your existing setup() configuration:

local null_ls = require("null-ls")

null_ls.setup({
  sources = {
+   null_ls.builtins.formatting.rubyfmt,
  },
})

Read more in the null-ls documentation.

Visual Studio Code

Rubyfmt is a supported formatter in the popular vscode ruby extension. You should copy rubyfmt-main to be called rubyfmt on your PATH . Once installed, add the following to vscode's settings.json file:

  "ruby.useLanguageServer": true,
  "ruby.format": "rubyfmt",
  "[ruby]": {
      "editor.formatOnSave": true
  },

RubyMine (and similar Jetbrains family IDE)

Install the File Watchers plugin and go to File | Settings | Tools | File Watchers. Now import watchers.xml from editor_plugins/rubymine/. Optionally set Level to Global to have it available across all projects.

See this reference on using file watchers to learn more.

Sublime Text

Install the rubyfmt plugin from Package Control: Install Package -> rubyfmt.

Ruby files are formatted on save or by pressing Alt + ; or on macOS: Cmd + ;. rubyfmt is assumed to be on path.

Overridable default settings:

{
  "ruby_executable": "ruby",
  "rubyfmt_executable": "rubyfmt",
  "format_on_save": true,
}

Atom

Install the rubyfmt package from Settings > Packages.

Ruby files are formatted on save or by pressing Alt + ; or on macOS: Cmd + ; rubyfmt is assumed to be on path. See the package settings for more options.

Contributing

Please checkout our contributing guide

rubyfmt's People

Contributors

bibstha avatar bquorning avatar brett-lempereur avatar cbliard avatar clint-stripe avatar coreyja avatar dbalatero avatar fables-tales avatar froydnj-stripe avatar georgebrock avatar harsh183 avatar iz-stripe avatar kaoru avatar kddnewton avatar mikker avatar nroman-stripe avatar penelope-stripe avatar phiggins avatar pjsk-stripe avatar reese avatar reese-stripe avatar robotdana avatar searls avatar sgrif avatar shkm avatar tenderlove avatar teoljungberg avatar toreriklinnerud avatar twe4ked avatar wadetandy 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.