2023-09-11 20:23:04 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib; let
|
2020-06-12 09:10:09 +02:00
|
|
|
rustEnv = pkgs.symlinkJoin {
|
|
|
|
name = "rustEnv";
|
|
|
|
paths = config.machine.pkgsets.rustpkgs.pkgwrap;
|
|
|
|
};
|
2023-09-11 20:23:04 +02:00
|
|
|
in
|
|
|
|
mkIf (elem "emacs::rust" config.machine.pkgs) {
|
|
|
|
programs.emacs.init.usePackage.rust-mode = {
|
|
|
|
enable = true;
|
|
|
|
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)))'']
|
|
|
|
);
|
|
|
|
mode = [''("\\.rs\\'" . rust-mode)''];
|
|
|
|
command = ["rust-mode"];
|
|
|
|
bindLocal = optionalAttrs (elem "emacs::company" config.machine.pkgs) {
|
|
|
|
rust-mode-map = {
|
|
|
|
"<tab>" = "company-indent-or-complete-common";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
config = ''
|
|
|
|
(setq rust-rustfmt-bin "${rustEnv}/bin/rustfmt")
|
|
|
|
(setq rust-format-on-save t)
|
|
|
|
'';
|
|
|
|
};
|
2019-11-17 23:13:50 +01:00
|
|
|
|
2023-09-11 20:23:04 +02:00
|
|
|
programs.emacs.init.usePackage.cargo = {
|
|
|
|
enable = true;
|
|
|
|
defer = true;
|
|
|
|
};
|
2019-11-17 23:13:50 +01:00
|
|
|
|
2023-09-11 20:23:04 +02:00
|
|
|
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)))'';
|
2019-11-17 23:13:50 +01:00
|
|
|
|
2023-09-11 20:23:04 +02:00
|
|
|
config = ''
|
|
|
|
(setq racer-rust-src-path "${rustEnv}/lib/rustlib/src/rust/src")
|
|
|
|
(setq racer-cmd "${rustEnv}/bin/racer")
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|