Skip to content

fosskers/clfmt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clfmt

clfmt is a tool that lightly refactors your Common Lisp code.

It mainly aims to reduce extraneous whitespace and newlines, and avoids “being a hero”, leaving parenthesis management and sexp alignment to the editor. Staying simple keeps clfmt performant and nimble, compiling to a small executable.

Table of Contents

Installation

From Source

clfmt requires ECL to build.

ecl --load build.lisp

Linux

Arch

clfmt is available on the AUR and can be installed with tools like Aura:

aura -A clfmt

Editor Integration

Emacs (Apheleia)

In general, it should be enough to add:

(add-to-list 'apheleia-formatters '(clfmt . ("clfmt")))
(add-to-list 'apheleia-mode-alist '(lisp-mode . (lisp-indent clfmt)))

Provided that apheleia has already been loaded and those lists exist.

Doom Emacs

Due to how set-formatter! is used by Doom internally, we must:

(after! sly
  (after! apheleia
    (assq-delete-all 'lisp-mode apheleia-mode-alist)
    (add-to-list 'apheleia-mode-alist '(lisp-mode . (lisp-indent clfmt)))))

(after! apheleia-formatters
  (add-to-list 'apheleia-formatters '(clfmt . ("clfmt"))))

Then, upon saving a Common Lisp buffer, you will get both automatic alignment and whitespace clearing.

Usage

Format a File

Just pass clfmt a file:

clfmt foo.lisp

And its reformatted form will print to STDOUT.

Format from STDIN

Some editor integrations want to feed input via STDIN. That’s equivalent to:

cat foo.lisp | clfmt

Format Files in-place

The -i flag will directly overwrite a given file:

clfmt -i foo.lisp

You can reformat all files in a directory too:

clfmt -i src/

About

Lightly reformat your Common Lisp code.

Topics

Resources

License

Stars

Watchers

Forks

Contributors