← Back to context

Comment by kazinator

2 years ago

I've written all my Lisp in Vim for the past quarter century.

Nowadays I'm experimenting with parinfer in Vim.

It's quirky. First off, it doesn't work well with the lisp mode autonindenting, so that has to be turned off. It doesn't handle some syntax like #; to comment out an object.

I rigged Ctrl-_ to toggle parinfer on and off.

More about the indenting. If you're in :set lisp mode, and you have this, say:

  (progn  
    (cond
      (foo bar)
      (xyzzy quux)))_   ;; <-- cursor here

If you hit Enter for a new line, it will do this:

  (progn  
    (cond
      (foo bar)
      (xyzzy quux)))
  _                     ;; <-- cursor here

In parinfer mode, though, that is counterproductive, because you control structure through indentation. Say you want to add a fallback (t 42) case to the cond. You just want dumb indentation that is not Lisp aware and which just copies the indentation of the previous line:

  (progn  
    (cond
      (foo bar)
      (xyzzy quux)))
      _                     ;; <-- cursor here

Whereby parindent will instantly move the parentheses:

  (progn  
    (cond
      (foo bar)
      (xyzzy quux)
      ))

So I have it that when parinfer mode turns on, :set nolisp is executed, and vice versa, when parinfer is off, :set lisp goes on.