user4813927
user4813927

Reputation:

Indent clojure on Emacs

I am trying to set up the emacs to have auto-Indentation for clojure code.

Until now unsuccessful. What is the command to set into the config file for that?

Upvotes: 0

Views: 1099

Answers (2)

user4813927
user4813927

Reputation:

I added

(global-set-key (kbd "RET") 'newline-and-indent)

to the init file and this worked. I am not sure if this was the best solutaion, but it did the trick.

Upvotes: 0

Arthur Ulfeldt
Arthur Ulfeldt

Reputation: 91534

Here is a sample emacs config for what i consider the "minimal" usable emacs config for Clojure. I say minimal in that I'm not willing to work without good code completion, jump to definition, project aware file handling etc:

from this example which you can clone to ~/.emacs.d:

This is just a hilight, see the init file in the example project for the context, look at the project for recent versions, etc. don't just copy these:

(use-package clojure-mode
  :ensure t
  :config
  (add-hook 'clojure-mode-hook 'yas-minor-mode))

(use-package cider
 :ensure t
 :config (progn (add-hook 'clojure-mode-hook 'cider-mode)
                 (add-hook 'clojure-mode-hook 'cider-turn-on-eldoc-mode)
                 (add-hook 'cider-repl-mode-hook 'subword-mode)
                (setq cider-annotate-completion-candidates t
                       cider-prompt-for-symbol nil)))

;; clojure refactor library
;; https://github.com/clojure-emacs/clj-refactor.el
(use-package clj-refactor
  :ensure t
  :config (progn (setq cljr-suppress-middleware-warnings t)
                 (add-hook 'clojure-mode-hook (lambda ()
                        (clj-refactor-mode 1)
                        (cljr-add-keybindings-with-prefix "C-c C-m")))))

there is also some code to add to ~/.lein/profiles.clj:

{:user {:plugins [[cider/cider-nrepl "0.10.0-SNAPSHOT"]
                 [refactor-nrepl "1.1.0"]]
        :dependencies [[acyclic/squiggly-clojure "0.1.3-SNAPSHOT"]]}}

Upvotes: 3

Related Questions