I am trying to autoindent a .lisp file from the command line, leveraging vim+slimv to do the indenting.
I tried scripting it:
vi -c 'call SlimvConnectSwank()' -c 'normal gg=G' -c 'wq' -c 'q!' temp.lisp
But the swank server isn't queried to do the indenting, so this just indents the file to .lisp vim defaults (if slimv and the server were not running).
Do I need to put some sort of delay/wait -c command after the call to connect to the swank server? It seems that the whole vi process is closing much too fast, and it isn't giving swank a chance to connect. If the swank connection happens on a separate thread, I suppose this could be the case.
Thoughts/comments/suggestions are appreciated.
Thanks!
Tamas got it. It was (and I checked on this, both are actually needed; really :) ) a sleep command and swank command that got it to work.
I added this to my .bashrc and aliased it to 'ai' so that I can easily indent a .lisp file from the command line:
alias ai="vi \
-c 'call SlimvConnectSwank()' \
-c 'sleep 1' \
-c 'call SlimvEval(['0'])' \
-c 'normal gg=G' \
-c 'wq' \
-c 'q!'"
Now 'ai temp.lisp' auto indents temp.lisp to slimv+vim+swank etc. standards.
All sorts of ways to script this for auto indenting a repo of lisp files, once you have the bash command to do it for one file.
The whole process is single threaded, so no need to add delays, each command shall finish before the next one is executed. You can verify that Slimv's indenting is in charge via this command:
vi -c "call SlimvConnectSwank()" -c "setlocal indentexpr?" temp.lisp
It should print indentexpr=SlimvIndent(v:lnum)
.
I suspect that you have some definitions in your temp.lisp
that affect indentation. First those definitions must be told to the swank server, otherwise the swank server does not know e.g. the function arguments, etc. Remember: the whole process is dynamic, the runtime information is used for indenting forms.
So I think first you need to eval the whole buffer and do the indentation only after that. You can use this command:
vi -c "call SlimvConnectSwank()" -c "call SlimvEvalBuffer()" -c "normal gg=G" -c "wq" -c "q!" temp.lisp