~skin/zippm

cbd311ccc53b11c7a778ba35d6cf07d0a8a7853b — Daniel Jay Haskin 7 months ago 607d267
Write a formatter
3 files changed, 103 insertions(+), 0 deletions(-)

M README.markdown
A scripts/format.ros
A scripts/nvim-format.ros
M README.markdown => README.markdown +8 -0
@@ 3,3 3,11 @@
## Usage

## Installation

## Contributing

### Release Checklist

1. Run `scripts/nvim-format.ros` if possible, or some other formatter if `nvim`
   is not your editor.
2. Run `ros run-parachute`

A scripts/format.ros => scripts/format.ros +46 -0
@@ 0,0 1,46 @@
#!/bin/sh
#|-*- mode:lisp -*-|#
#|
exec ros -Q -- $0 "$@"
|#
(progn ;;init forms
  (ros:ensure-asdf)
  #+quicklisp
  (ql:quickload '("cl-arrows") :silent t)
  )

(defpackage :ros.script.format.3918404214
  (:use :cl
        :cl-arrows))

(in-package :ros.script.format.3918404214)

(defun lisp-files (dir)
  (->> dir
       (uiop/filesystem:directory-files)
       (remove-if-not (lambda (x) (string= (pathname-type x) "lisp")))))

(defun main (&rest argv)
  (declare (ignorable argv))
   (let ((flag-file (probe-file "./skin.djha.zippm.asd")))
     (when (not flag-file)
       (error "This script must be run from the root of the project."))
     (let* ((root-path (uiop/os:getcwd))
            (format-files
              (concatenate 'list
                           (lisp-files (merge-pathnames "./src/" root-path))
                           (lisp-files (merge-pathnames "./tests/" root-path))
                           '("skin.djha.zippm.asd"
                           "zippm.ros"))))
       (loop for file in format-files
             do
             (uiop:run-program
               `("nvim"
                 "-es"
                 "-c"
                 "normal gg=G"
                 "-c"
                 "wq"
                 ,file))))))

;;; vim: set ft=lisp lisp:

A scripts/nvim-format.ros => scripts/nvim-format.ros +49 -0
@@ 0,0 1,49 @@
#!/bin/sh
#|-*- mode:lisp -*-|#
#|
exec ros -Q -- $0 "$@"
|#
(progn ;;init forms
  (ros:ensure-asdf)
  #+quicklisp
  (ql:quickload '("cl-arrows") :silent t)
  )

(defpackage :ros.script.format.3918404214
  (:use :cl
        :cl-arrows))

(in-package :ros.script.format.3918404214)

(defun lisp-files (dir)
  (->> dir
       (uiop/filesystem:directory-files)
       (remove-if-not (lambda (x) (string= (pathname-type x) "lisp")))))

(defun main (&rest argv)
  (declare (ignorable argv))
   (let ((flag-file (probe-file "./skin.djha.zippm.asd")))
     (when (not flag-file)
       (format *error-output* "We are not in a git repository~%")
       (uiop:quit 1))
     (let* ((root-path (uiop/os:getcwd))
            (format-files
              (concatenate 'list
                           (lisp-files (merge-pathnames "./src/" root-path))
                           (lisp-files (merge-pathnames "./tests/" root-path))
                           '("skin.djha.zippm.asd"
                           "zippm.ros"))))
       (loop for file in format-files
             do
             (uiop:run-program
               `("nvim"
                 "-es"
                 "-c"
                 "normal gg=G"
                 "-c"
                 "wq"
                 ,(namestring
                   (pathname-name file))))))))
#+(or)
(main)
;;; vim: set ft=lisp lisp: