2019-11-17 23:13:50 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
mkIf (elem "emacs::rust" config.machine.pkgs) {
|
|
|
|
programs.emacs.init.usePackage.rust-mode = {
|
|
|
|
enable = true;
|
2020-03-23 10:10:31 +01:00
|
|
|
hook = [ ''(rust-mode . (lambda () (cargo-minor-mode)))'' ]
|
|
|
|
++ (if (elem "emacs::lsp" config.machine.pkgs)
|
|
|
|
then [''(rust-mode . (lambda () (lsp)))'']
|
|
|
|
else [''(rust-mode . (lambda () (racer-mode)))'']);
|
2019-11-17 23:13:50 +01:00
|
|
|
mode = [ ''("\\.rs\\'" . rust-mode)'' ];
|
|
|
|
command = [ "rust-mode" ];
|
2020-03-23 10:10:31 +01:00
|
|
|
bindLocal = optionalAttrs (elem "emacs::company" config.machine.pkgs) { rust-mode-map = {
|
|
|
|
"<tab>" = "company-indent-or-complete-common";
|
|
|
|
};};
|
2019-11-17 23:13:50 +01:00
|
|
|
config = ''
|
|
|
|
(setq rust-rustfmt-bin "${pkgs.rustfmt}/bin/rustfmt")
|
|
|
|
(setq rust-format-on-save t)
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
programs.emacs.init.usePackage.cargo = {
|
|
|
|
enable = true;
|
|
|
|
defer = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
programs.emacs.init.usePackage.racer = {
|
|
|
|
enable = true;
|
|
|
|
defer = true;
|
|
|
|
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")
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|