Can't get Emacs going with racer and flycheck

So I've been trying to set up Emacs for Rust using this guide, but I'm completely stuck. I've installed all the Emacs packages, racer seems to be working in the terminal, my emacs config seems okay. But nothing except simple highlighting (rust-mode stuff) and an autocompleter that doesn't seem to Rust-specific (Company I think) actually work inside Emacs. No syntax checker, no jump to definition, no keyboard shortcuts. I'm not that experienced with Emacs, so I just have absolutely no idea what might be wrong or how to find out. Emacs config here. Any help would be appreciated.

Hey Morten,

Couple thoughts:
First, there are a few things funky about your emacs config. The lambda form in your rust-mode-hook shouldn't be quoted. I have a working setup with Racer, company etc. that is a bit simpler. I've changed some of your emacs configs to use the way I did it, and I got your config to do show racer completions with company. .emacs for rust - Pastebin.com

I got my own company/racer configurations straight from the source: https://github.com/racer-rust/emacs-racer

If it doesn't work, definitely test that racer completion works from the command-line. That's always a good sanity check: RUST_SRC_PATH=/home/morten/.rust/src <path/to/racer>/racer complete std::io::B

Hope that gets you going. :slight_smile:

2 Likes

Yes, that's the first step to test. I had problems making racer work within Emacs too. Which version of Emacs are you using? Mine is Emacs 24.5.1. I'm not using flycheck though. Type:

M-x package-list-packages

And search for your company, rust-mode, and racer versions. Mine are:

company            0.8.12
racer              20150925.1415
rust-mode          20150828.2055

My rust-mode and racer config in .emacs is:

;; Rust                                                                             
(add-to-list 'load-path "/Users/jan/git/rust-mode/")
(autoload 'rust-mode "rust-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode))
;; Racer                                                                            
(setq racer-cmd "/mill3d/users/jan/git/github/racer/target/release/racer")
(setq racer-rust-src-path "/usr/local/src/rustc-1.3.0/src/")
(add-hook 'rust-mode-hook #'racer-mode)
(add-hook 'racer-mode-hook #'eldoc-mode)
(add-hook 'racer-mode-hook #'company-mode)
(global-set-key [f2] #'company-complete)
(setq company-tooltip-align-annotations t)

Of course your paths will be different.

Anyway, let us know if that helped.

RadicalZephyr: Thanks for looking through and editing my emacs file, that's great for people who are not too comfortable manually piecing together an init file. I've spent the day repeating my work on another computer, now using your config, but everything is the same here and I'm not making any progress. Racer from command line does return Rust-specific autocompletion, but in Emacs it still just tries to autocomplete to any text string in the current file.

wahn: I'm using Emacs 24.4.1 (Ubuntu 15.04) on this new computer, and Emacs 24.x (Ubuntu 14.04) on the other. Here are all my installed packages in package-list-packages, apologies for the formatting:

  company            20151008.452 installed             Modular text completion framework
  company-racer     20150628.1933 installed             Company integration for racer
  dash                20151010.929 installed             A modern list library for Emacs
  deferred            20151007.... installed             Simple asynchronous functions for emacs lisp
  epl                 20150517.433 installed             Emacs Package Library
  flycheck            20151013.131 installed             On-the-fly syntax checking
  flycheck-rust      20150609.1248 installed             Flycheck: Rust additions and Cargo support
  haskell-mode        13.14.2      installed             A Haskell editing mode
  let-alist           1.0.4        installed             Easily let-bind values of an assoc-list by their names
  pkg-info            20150517.443 installed             Information about packages
  racer               1.0.0        installed             Rust completion via racer with company
  rust-mode          20150828.2055 installed             A major emacs mode for editing Rust source code
  sml-mode            6.7          installed             Major mode for editing (Standard) ML

Hi @MortenLohne

Sorry, I've just noticed this. I'm one of the maintainers of company-racer. Would you mind opening an issue on company-racer?

Oh, that was dumb. The correct URL for company-racer is https://github.com/racer-rust/emacs-racer, so please file bugs there.