venantius / vim-cljfmt

A Vim plugin for cljfmt, the Clojure formatting tool.
152 stars 22 forks source link

Plugin fails after restarting REPL #28

Closed Jeiwan closed 8 years ago

Jeiwan commented 8 years ago

To reproduce:

  1. Start REPL, open a file, save. Everything works fine.
  2. Stop current REPL session and run REPL again.
  3. Try to save the file and get an exception.

The plugin fails on this line https://github.com/venantius/vim-cljfmt/blob/master/plugin/cljfmt.vim#L53 with a message saying that cljfmt.core namespace is not found. And this is true, since after restarting REPL we have to re-require the namespace. And this check https://github.com/venantius/vim-cljfmt/blob/master/plugin/cljfmt.vim#L66 is wrong. I guess there should be a call to fireplace#session_eval with (find-ns 'cljfmt.core) and a check that it returns non-nil. Or maybe something better. (I'm a Vim-script noob and failed to make a working fix)

jasonmm commented 8 years ago

Removing the if statement @Jeiwan referenced worked for me. I was able to exit the REPL and then open a new REPL without needing to manually reconnect to the REPL in VIM. If no REPL is available then the code is not formatted.

This is my first attempt at vimscript so it is always possible I've inadvertently done something horrible. :)