I've been developing C# applications for a long time. Commercial IDEs and tools provide extremely good code completion features. I'm now learning clojure and I really miss familiar workflow.
So, about emacs. I've installed nrepl, ac-nrepl and clojure-mode. Auto completion works fine in repl. It also works for symbols in current buffer. But not for:
- symbols from other project files
- external libraries (managed with leiningen).
Is there any existing package that fully covers cases 1 and 2?
My clojure-related config:
;;;;;;;;;;;;;;;
;;; clojure ;;;
;;;;;;;;;;;;;;;
(require 'nrepl)
;; Configure nrepl.el
(setq nrepl-hide-special-buffers t)
(setq nrepl-popup-stacktraces-in-repl t)
(setq nrepl-history-file "~/.emacs.d/nrepl-history")
;; Some default eldoc facilities
(add-hook 'nrepl-connected-hook
(defun pnh-clojure-mode-eldoc-hook ()
(add-hook 'clojure-mode-hook 'turn-on-eldoc-mode)
(add-hook 'nrepl-interaction-mode-hook 'nrepl-turn-on-eldoc-mode)
(nrepl-enable-on-existing-clojure-buffers)))
;; Repl mode hook
(add-hook 'nrepl-mode-hook 'subword-mode)
;; Auto completion for NREPL
(require 'ac-nrepl)
(eval-after-load "auto-complete"
'(add-to-list 'ac-modes 'nrepl-mode))
(add-hook 'nrepl-mode-hook 'ac-nrepl-setup)
(add-hook 'clojure-nrepl-mode-hook 'ac-nrepl-setup)
(define-key clojure-mode-map (kbd "C-<ret>") 'nrepl-eval-expression-at-point)
;(global-set-key (kbd "C-<ret>") 'nrepl-eval-expression-at-point)
;;;;;;;;;;;;;;;;;;;;;
;;; auto-complete ;;;
;;;;;;;;;;;;;;;;;;;;;
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
(setq ac-delay 0.0)
(setq ac-use-quick-help t)
(setq ac-quick-help-delay 0.05)
(setq ac-use-fuzzy 1)
(setq ac-auto-start 1)
(setq ac-auto-show-menu 1)
(ac-config-default)
(define-key ac-mode-map (kbd "C-SPC") 'auto-complete)
After installing a fresh nrepl and ac-nrepl, here is what I put into the .emacs
When I now
nrepl-jack-in
into a test-project and open a file of it, I have tab-completion on every namespace currently loaded in the project. It seems like you forgot the'ac-nrepl-setup
on the'nrepl-interaction-mode-hook
.