Giter Club home page Giter Club logo

vim-cljfmt's Introduction

vim-cljfmt

vim-cljfmt is a vim plugin for cljfmt, the code formatting tool for Clojure(Script). Rather than invoking the plugin by shelling out to Leiningen, it uses a vim-fireplace REPL connection to only format the current file. This has the advantage of sidestepping Leiningen's startup time and keeping Vim from hanging, though the first time you use it with a given REPL server there will be a slight delay as it loads the cljfmt namespace.

Demo below:

Configuration and Usage

vim-cljfmt allows you to format the file in the current buffer with the following:

:Cljfmt

Of course, manually formatting files is for people who aren't lazy. So, by default, vim-cljfmt automatically does the formatting when you save. If you want to turn this off, add the following line to your .vimrc:

let g:clj_fmt_autosave = 0

To format the code in current visual selection use the following command:

:'<,'>CljfmtRange
Re-starting the REPL while editing

If you expect the have to re-start the REPL while working, you have two options. You can manually re-load vim-cljfmt from within Vim with the following:

:CljfmtRequire

Alternatively, you can add the following line to your ~/.lein/profiles.clj:

:repl-options {:init (require 'cljfmt.core)}

The latter will slow down your REPL startup time, but will mean you won't have to do any extra typing if you restart your REPL. Personally, I prefer this approach.

Installation

Requirements

You'll want to have cljfmt and vim-fireplace installed, and you'll need to make sure Cljfmt is somewhere on your project's classpath. I'd recommend adding the following to your ~/.lein/profiles.clj:

:dependencies [[cljfmt "0.5.1"]]

You'll also need to have a REPL connection open through fireplace.

After that, the rest should take care of itself.

Installing with Pathogen

Assuming you already have Pathogen installed, you should be good to go with the following:

cd ~/.vim/bundle && \
git clone https://github.com/venantius/vim-cljfmt.git

Installing with Vundle

To install vim-cljfmt with Vundle, add the following line to your .vimrc:

Bundle 'venantius/vim-cljfmt'

Other Vim + Clojure Plugins

If you like this, you should check out vim-eastwood!

License

Copyright (c) 2015 W. David Jarvis.

Licensed under the Eclipse Public License, the same as Clojure.

vim-cljfmt's People

Contributors

fortino645 avatar jasonmm avatar jblackwood avatar micheam avatar mluts avatar qmacro avatar venantius avatar

Watchers

 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.