Well, you could use the racket-mode from emacs to indent your files.  You 
will need to install GNU Emacs and racket-mode, and save the following in 
indent-racket-file.sh:

#!/bin/bash
FILE=$1
emacs --daemon --eval "
(progn
  (find-file \"$1\")
  (racket-mode)
  (indent-region (point-min) (point-max))
  (save-buffer (current-buffer))
  (kill-buffer (current-buffer))
  (setq confirm-kill-processes nil)
  (save-buffers-kill-terminal))"

You will than be able to indent racket files from the terminal by calling 
(and presumably you can setup vim to call this script).

    indent-racket-file.sh some-file.rkt

This script will indent the file in place but you could write the file to a 
temporary one and indent that.  You could also update the shell script to 
read from stdin, save to a temporary file, load it in Emacs and indent it 
than pipe it out -- this would make the script work as a pipe, but it will 
not be very efficient.

Also, if Emacs startup is slow, you can write an indent helper function in 
elisp:

;; save to racket-indent-helper.el
(defun indent-racket-file (name)
  (find-file name)
  (racket-mode)
  (indent-region (point-min) (point-max))
  (save-buffer (current-buffer))
  (kill-buffer (current-buffer)))

and start emacs as a background process:

    emacs --daemon --load racket-indent-helper.el

You can than update the shell script to be:

#!/bin/bash
FILE=$1
emacsclient --eval "(indent-racket-file \"$1\")"

Alex.

On Thursday, October 24, 2019 at 7:11:49 AM UTC+8, Martin DeMello wrote:
>
> Is there a good way to call out to the indentation code drracket uses from 
> within vim? even just manually piping the whole file through an indenter 
> would be fine.
>
> martin
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/895ceca0-8191-4e0c-96f6-a4077883be7d%40googlegroups.com.

Reply via email to