nixos/pkgs/pkgsets/emacs/rust.nix

40 lines
1.1 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
with lib;
mkIf (elem "emacs::rust" config.machine.pkgs) {
programs.emacs.init.usePackage.rust-mode = {
enable = true;
hook = [ ''(rust-mode . (lambda () (racer-mode)))'' ];
mode = [ ''("\\.rs\\'" . rust-mode)'' ];
command = [ "rust-mode" ];
config = ''
(setq rust-rustfmt-bin "${pkgs.rustfmt}/bin/rustfmt")
(setq rust-format-on-save t)
'';
};
programs.emacs.init.usePackage.cargo = {
enable = true;
defer = true;
# hook = [ ''ru];
};
programs.emacs.init.usePackage.racer = {
enable = true;
defer = true;
bindLocal = optionalAttrs (elem "emacs::company" config.machine.pkgs) { rust-mode-map = {
"<tab>" = "company-indent-or-complete-common";
};};
hook = [
''(racer-mode . (lambda () (eldoc-mode)))''
] ++ optional (elem "emacs::company" config.machine.pkgs) ''(racer-mode . (lambda () (company-mode)))'';
config = ''
(setq racer-rust-src-path (concat (getenv "HOME")
"/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/"))
(setq racer-cmd "${pkgs.rustracer}/bin/racer")
'';
};
}