All Projects → clojure-emacs → ac-nrepl

clojure-emacs / ac-nrepl

Licence: other
[DEPRECATED] Emacs auto-complete backend for nrepl completions

Programming Languages

emacs lisp
2029 projects

nrepl completion source for Emacs auto-complete package

Deprecation notice: These days you probably want to use ac-cider or Cider's built-in company completion support instead of this.

This plugin provides a completion source for the popular Emacs interactive auto-completion framework auto-complete.

Where nrepl provides it, pop-up documentation for completed symbols will be displayed.

Latest stable version: see the latest numbered tag, which will also be the latest version available via Marmalade.

Installation

First, ensure auto-complete and cider are installed: I recommend using packages from Marmalade or Melpa.

You'll need both auto-complete and cider to be enabled and working, so please consult the corresponding documentation if you have any trouble with this.

Next, install ac-nrepl. If you choose not to use the convenient package in Melpa and Marmalade, you'll need to add the directory containing ac-nrepl.el to your load-path, and then (require 'ac-nrepl).

ac-nrepl provides an nrepl-specific completion source, so auto-complete needs to be told to use them when cider-repl-mode is active. To do this, put the following code in your emacs init file to

(require 'ac-nrepl)
(add-hook 'cider-repl-mode-hook 'ac-nrepl-setup)
(add-hook 'cider-mode-hook 'ac-nrepl-setup)
(eval-after-load "auto-complete"
  '(add-to-list 'ac-modes 'cider-repl-mode))

If you want to trigger auto-complete using TAB in nrepl buffers, you may want to put auto-complete into your completion-at-point-functions:

(defun set-auto-complete-as-completion-at-point-function ()
  (setq completion-at-point-functions '(auto-complete)))
(add-hook 'auto-complete-mode-hook 'set-auto-complete-as-completion-at-point-function)

(add-hook 'cider-repl-mode-hook 'set-auto-complete-as-completion-at-point-function)
(add-hook 'cider-mode-hook 'set-auto-complete-as-completion-at-point-function)

You might consider using ac-nrepl's popup documentation in place of nrepl-doc:

(eval-after-load "cider"
  '(define-key cider-mode-map (kbd "C-c C-d") 'ac-nrepl-popup-doc))

Usage

ac-nrepl should now automatically be enabled when you visit a buffer in which cider-repl-mode is active and auto-complete is enabled. (The symbols "nrepl and "AC" should appear in the modeline.)

Simply trigger auto-completion, and completion candidates supplied by nrepl should be displayed, with symbols on the right hand side of the completion pop-up to indicate the "flavour" of the completion candidate, e.g. "v" for variables. After a short delay, popup documentation for the completed symbol should also be displayed.

Acknowledgements

ac-nrepl was written by Steve Purcell, with important contributions from Sam Aaron.


Author links:

Steve Purcell's blog // @sanityinc on Twitter

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].