feat: emacs daemon

This commit is contained in:
Ryan Yin
2024-01-03 19:09:26 +08:00
parent 59d9601f49
commit f68fe49720
4 changed files with 92 additions and 53 deletions
+13
View File
@@ -167,3 +167,16 @@ test-emacs:
test-emacs-clean: test-emacs-clean:
rm -rf $"($env.HOME)/.config/doom/" rm -rf $"($env.HOME)/.config/doom/"
emacs-plist-path := "~/Library/LaunchAgents/org.nix-community.home.emacs.plist"
reload-emacs-cmd := if os() == "macos" {
"launchctl unload " + emacs-plist-path
+ "\n"
+ "launchctl load " + emacs-plist-path
} else {
"systemctl --user restart emacs.service"
}
reload-emacs:
{{reload-emacs-cmd}}
@@ -13,11 +13,6 @@
- Emacs Wiki: <https://www.emacswiki.org/emacs/SiteMap> - Emacs Wiki: <https://www.emacswiki.org/emacs/SiteMap>
- Awesome Emacs: <https://github.com/emacs-tw/awesome-emacs#lsp-client> - Awesome Emacs: <https://github.com/emacs-tw/awesome-emacs#lsp-client>
Emacs daemon:
- <https://github.com/nix-community/home-manager/blob/master/modules/services/emacs.nix>
- <https://github.com/LnL7/nix-darwin/blob/1a41453cba42a3a1af2fff003be455ddbd75386c/modules/services/emacs.nix>
## Install or Update ## Install or Update
After deploying this nix flake, run the following command to install or update emacs: After deploying this nix flake, run the following command to install or update emacs:
+79 -48
View File
@@ -19,9 +19,9 @@ with lib; let
export PATH="${config.xdg.configHome}/emacs/bin:$PATH" export PATH="${config.xdg.configHome}/emacs/bin:$PATH"
''; '';
shellAliases = { shellAliases = {
e = "emacs"; e = "emacsclient -c";
ediff = ''emacs -nw --eval "(ediff-files \"$1\" \"$2\")"''; ediff = ''emacsclient -c -nw --eval "(ediff-files \"$1\" \"$2\")"'';
eman = ''emacs -nw --eval "(switch-to-buffer (man \"$1\"))"''; eman = ''emacsclient -c -nw --eval "(switch-to-buffer (man \"$1\"))"'';
}; };
in { in {
options.modules.editors.emacs = { options.modules.editors.emacs = {
@@ -31,51 +31,82 @@ in {
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable (mkMerge [
home.packages = with pkgs; [ {
## Emacs itself home.packages = with pkgs; [
((emacsPackagesFor emacs-unstable-nox).emacsWithPackages librime
(epkgs: [ emacs-all-the-icons-fonts
## Doom dependencies
git
(ripgrep.override {withPCRE2 = true;})
gnutls # for TLS connectivity
## Optional dependencies
fd # faster projectile indexing
imagemagick # for image-dired
zstd # for undo-fu-session/undo-tree compression
## Module dependencies
# :checkers spell
(aspellWithDicts (ds: with ds; [en en-computers en-science]))
# :tools editorconfig
editorconfig-core-c # per-project style config
# :tools lookup & :lang org +roam
sqlite
# :lang latex & :lang org (latex previews)
texlive.combined.scheme-medium
];
programs.bash.bashrcExtra = envExtra;
programs.zsh.envExtra = envExtra;
home.shellAliases = shellAliases;
programs.nushell.shellAliases = shellAliases;
# allow fontconfig to discover fonts and configurations installed through `home.packages`
fonts.fontconfig.enable = true;
xdg.configFile."doom".source = ./doom;
home.activation = mkIf cfg.doom.enable {
installDoomEmacs = lib.hm.dag.entryAfter ["writeBoundary"] ''
${pkgs.rsync}/bin/rsync -avz --chmod=D2755,F744 ${doomemacs}/ ${config.xdg.configHome}/emacs/
'';
};
}
(mkIf pkgs.stdenv.isLinux {
services.emacs = {
enable = true;
package = with pkgs; ((emacsPackagesFor emacs-unstable-pgtk).emacsWithPackages (epkgs: [
epkgs.vterm epkgs.vterm
])) ]));
librime client.enable = true;
emacs-all-the-icons-fonts startWithUserSession = true;
};
})
## Doom dependencies (mkIf pkgs.stdenv.isDarwin {
git launchd.enable = true;
(ripgrep.override {withPCRE2 = true;}) launchd.agents.emacs = {
gnutls # for TLS connectivity enable = true;
config = {
## Optional dependencies ProgramArguments = with pkgs; let
fd # faster projectile indexing emacsPkg = (emacsPackagesFor emacs-unstable).emacsWithPackages (epkgs: [
imagemagick # for image-dired epkgs.vterm
zstd # for undo-fu-session/undo-tree compression ]);
in [
## Module dependencies "${pkgs.bash}/bin/bash"
# :checkers spell "-l"
(aspellWithDicts (ds: with ds; [en en-computers en-science])) "-c"
# :tools editorconfig "${emacsPkg}/bin/emacs --fg-daemon"
editorconfig-core-c # per-project style config ];
# :tools lookup & :lang org +roam StandardErrorPath = "${config.home.homeDirectory}/Library/Logs/emacs-daemon.stderr.log";
sqlite StandardOutPath = "${config.home.homeDirectory}/Library/Logs/emacs-daemon.stdout.log";
# :lang latex & :lang org (latex previews) RunAtLoad = true;
texlive.combined.scheme-medium KeepAlive = true;
]; };
};
programs.bash.bashrcExtra = envExtra; })
programs.zsh.envExtra = envExtra; ]);
home.shellAliases = shellAliases;
programs.nushell.shellAliases = shellAliases;
# allow fontconfig to discover fonts and configurations installed through `home.packages`
fonts.fontconfig.enable = true;
xdg.configFile."doom".source = ./doom;
home.activation = mkIf cfg.doom.enable {
installDoomEmacs = lib.hm.dag.entryAfter ["writeBoundary"] ''
${pkgs.rsync}/bin/rsync -avz --chmod=D2755,F744 ${doomemacs}/ ${config.xdg.configHome}/emacs/
'';
};
};
} }