ExLisp. Formatter
(exlisp v0.1.2)
Copy Markdown
Code formatter for Common Lisp.
Based on CST (Concrete Syntax Tree), handles indentation, parenthesis placement, and comment preservation according to standard Common Lisp conventions.
Features
- Parenthesis placement: Does not place closing
)on separate lines, collecting them at line ends. - Standard indentation:
- Body of definition forms like
defun,defmacro,defmethod: 2 spaces - Binding forms like
let,let*,flet,labels: binding part and 2-space body - Control structures like
if,when,unless,cond,case: appropriate indentation - Blocks like
with-*,dolist,dotimes,loop,progn: 2 spaces - General function calls: aligned with first argument or 2 spaces
- Body of definition forms like
- Preserving comments and blank lines:
- Preserves positions of
;;;;,;;;,;;,;and inline comments. - Preserves intentional blank lines (compresses consecutive blank lines to one).
- Preserves positions of
Summary
Functions
Formats and returns a Lisp code string.
Reads a Lisp file, writes back formatted content, or returns as a string.
Generates a Concrete Syntax Tree (CST) from a token stream.
Splits source code into a token stream for CST generation.
Types
@type format_opts() :: [max_width: pos_integer(), indent: pos_integer()]
Functions
@spec format(String.t(), format_opts()) :: String.t()
Formats and returns a Lisp code string.
Reads a Lisp file, writes back formatted content, or returns as a string.
Generates a Concrete Syntax Tree (CST) from a token stream.
Splits source code into a token stream for CST generation.