• Stars
    star
    152
  • Rank 244,685 (Top 5 %)
  • Language
    Vim Script
  • Created almost 10 years ago
  • Updated over 1 year ago

Reviews

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

Repository Details

A Vim plugin for cljfmt, the Clojure formatting tool.

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

If you need to pass custom configuration to cljfmt, you can do it like this:

let g:clj_fmt_config = '{:indentation? true, :remove-surrounding-whitespace? true, :remove-trailing-whitespace? true, :remove-consecutive-blank-lines? false, :insert-missing-whitespace? true, :align-associative? false, :indents {#"^\w" [[:inner 0]], #".*" [[:inner 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.

More Repositories

1

ultra

A Leiningen plugin for a superior development environment
Clojure
1,245
star
2

pyro

Light up your Clojure stacktraces
Clojure
318
star
3

accountant

ClojureScript navigation for single-page applications, made simple.
Clojure
250
star
4

yagni

A Leiningen plugin for finding dead code
Clojure
219
star
5

glojure

The Glojure programming language
Go
172
star
6

glow

Syntax highlighting for Clojure source code.
Clojure
101
star
7

vim-eastwood

A Vim plugin for Clojure's Eastwood linter
Vim Script
84
star
8

dotfiles

It's creepy that you want these
Shell
18
star
9

maze

Mazes for Programmers
Go
7
star
10

photon

Experiments in realtime web framework design. Like Meteor, but for Clojure(Script)
Clojure
7
star
11

droplet

Droplet is a Python library for sampling, sketching, and summarizing data from massive data streams.
Python
6
star
12

school

C
2
star
13

takehome

Various puzzles, homework assignments, and interview questions
Python
2
star
14

rethink

A Clojure driver for RethinkDB.
Clojure
1
star
15

yagni-test

Dummy app for testing Yagni
Clojure
1
star
16

spindle

Playing with Node.js and express. Don't take this seriously.
JavaScript
1
star
17

demo

A demo application that shows repeated 404s for a valid worker endpoint using Google App Engine push queues
Go
1
star
18

babel

Chat bots for yo' chat ops.
Clojure
1
star
19

etrade-statement-scraper

A Python script for scraping E*Trade monthly statements for data
Python
1
star
20

shrike

Hosted Code Quality for Clojure -- an abandoned CodeClimate competitor.
CSS
1
star
21

orcs-in-space

Orcs in space!!!
Haskell
1
star
22

darg

Kill the status meeting -- an abandoned IDoneThis competitor.
CSS
1
star