0

I am an experienced Clojure developer making the transition to using Spacemacs. I would like to use parinfer in my setup to manipulate my Clojure code structure, but I am struggling to get the behavior I would expect from parinfer in Spacemacs. I have never used Emacs or Spacemacs before, so I only have a fairly basic understanding of how it all works, especially on the config side.

Regardless of how I have tried to configured my init.el file, I cannot use TAB to manipulate indentation, and Spacemacs does not clearly indicate which parinfer mode is active.

Relevant parts of init.el:

   dotspacemacs-configuration-layers
   '((clojure :variables
              ;;cider-repl-display-help-banner nil      
              cider-pprint-fn 'fipp                   
              cider-overlays-use-font-lock t
              cider-repl-buffer-size-limit 100        
              clojure-indent-style 'align-arguments
              clojure-align-forms-automatically t
              clojure-toplevel-inside-comment-form t  
              clojure-enable-kaocha-runner t
              clojure-enable-linters '(clj-kondo joker)
              clojure-enable-fancify-symbols t)
     (lsp :variables
          lsp-lens-enable t)
     parinfer)

(defun dotspacemacs/user-config ()
  "Configuration for user code:
This function is called at the very end of Spacemacs startup, after layer
configuration.
Put your configuration code here, except for variables that should be set
before packages are loaded."
  (dotspacemacs-activate-smartparens-mode nil)
  ((add-hook 'clojure-mode-hook 'parinfer-rust-mode)))

UPDATE: I noticed opening Spacemacs that the following error message is displayed:

File mode specification error: (module-open-failed /Users/hestey264/.config/emacs/.cache/parinfer-rust/parinfer-rust-darwin.so dlopen(/Users/hestey264/.config/emacs/.cache/parinfer-rust/parinfer-rust-darwin.so, 0x0001): 
tried: '/Users/hestey264/.config/emacs/.cache/parinfer-rust/parinfer-rust-darwin.so' (mach-o file\, but is an incompatible architecture (have (x86_64), need (arm64e))))

Apparently the parinfer-rust library is built for the Intel chip, while my machine has Apple's M1 chip.

Can anyone please advise me on what I need to add to my config in order to utilize this tool?

1 Answer 1

0

Configure the hook inside of the parinfer invocation in dotspacemacs-configuration-layers like so:

(parinfer :hook clojure-mode)

If you have a Mac with the Apple M1 chip (as I do), then there will be a conflict with the version of parinfer-rust downloaded by Spacemacs, because it is built for the Intel chip. This is the cause of the (have (x86_64), need (arm64e)) error I was getting. In that case (and if no one has handled automatically installing a binary for the appropriate architecture in the future in the future), you will need to install Rust and build parinfer-rust from the source code on your machine. The github repo for parinfer-rust-mode has a guide on how to do this. Just make sure you have rust>=1.36 and clang and libclang-dev packages installed as prerequisites (can let Homebrew take care of this). Also, use cargo build --release --features emacs as the command to compile the binary file, otherwise it won't compile it in a format for emacs.

Once you have the binary, put it into a directory for emacs and give the path to it to the layer in the config:

(parinfer :variables
           parinfer-rust-library "path/to/your/emacs/config/parinfer-rust/parinfer-rust-library.so"
           :hook clojure-mode)

It should prompt you when you edit Clojure files to allow Parinfer to edit it now. I haven't figured out how to configure TAB and BACK TAB to edit the indentation the way I would like it to, but Parinfer will move parens based on indentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.