radicalzephyr

.emacs for rust

Oct 13th, 2015
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (add-to-list 'load-path "~/.emacs.d/lisp/")
  2.  
  3. (setq TeX-auto-save t)
  4. (setq TeX-parse-self t)
  5.  
  6. (require 'package)
  7.  
  8. ;; Add melpa repository to archives
  9. (add-to-list 'package-archives
  10.     '("melpa" . "http://melpa.milkbox.net/packages/") t)
  11.  
  12. ;; Initialize packages
  13. (package-initialize)
  14. (require 'company)
  15.  
  16. (require 'compile)
  17. (add-hook 'rust-mode-hook
  18.           (lambda ()
  19.             (set (make-local-variable 'compile-command)
  20.                  (if (locate-dominating-file "Cargo.toml")
  21.                      "cargo build"
  22.                    "rustc *.rs"))))
  23.  
  24. ;; Enable company globally for all mode
  25. (global-company-mode)
  26.  
  27. ;; Reduce the time after which the company auto completion popup opens
  28. (setq company-idle-delay 0.2)
  29.  
  30. ;; Reduce the number of characters before company kicks in
  31. (setq company-minimum-prefix-length 1)
  32.  
  33. ;; Set path to racer binary
  34. (setq racer-cmd "/usr/local/bin/racer")
  35.  
  36. ;; Set path to rust src directory
  37. (setq racer-rust-src-path "/home/morten/.rust/src/")
  38.  
  39. ;; Load rust-mode when you open `.rs` files
  40. (add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode))
  41.  
  42. (add-hook 'rust-mode-hook #'racer-mode)
  43. (add-hook 'racer-mode-hook #'eldoc-mode)
  44. (add-hook 'racer-mode-hook #'company-mode)
  45.  
  46. ;; Setting up configurations when you load rust-mode
  47. (add-hook 'rust-mode-hook
  48.           (lambda ()
  49.             ;; Use flycheck-rust in rust-mode
  50.             (add-hook 'flycheck-mode-hook #'flycheck-rust-setup)
  51.  
  52.             ;; Key binding to auto complete and indent
  53.             (local-set-key (kbd "TAB") #'company-indent-or-complete-common)))
  54.  
  55. (custom-set-variables
  56.  ;; custom-set-variables was added by Custom.
  57.  ;; If you edit it by hand, you could mess it up, so be careful.
  58.  ;; Your init file should contain only one such instance.
  59.  ;; If there is more than one, they won't work right.
  60.  '(inhibit-startup-screen t))
  61. (custom-set-faces
  62.  ;; custom-set-faces was added by Custom.
  63.  ;; If you edit it by hand, you could mess it up, so be careful.
  64.  ;; Your init file should contain only one such instance.
  65.  ;; If there is more than one, they won't work right.
  66.  )
Advertisement
Add Comment
Please, Sign In to add comment