diff --git a/modules/home/doom/doom.nix b/modules/home/doom/doom.nix index 267d83a..a8f326b 100644 --- a/modules/home/doom/doom.nix +++ b/modules/home/doom/doom.nix @@ -85,9 +85,21 @@ ${config.xdg.configHome}/doom-emacs/bin/doom "$@" fi ''; + doom-open = pkgs.writeShellScriptBin "doom-open" '' + if [ -t 0]; then + exec ${wrapped-emacs}/bin/emacsclient -t "$@" + else + exec ${wrapped-emacs}/bin/emacsclient -c "$@" + fi + ''; in { options.hive.doom = { enable = lib.mkEnableOption "Enable Doom Emacs"; + asDefaultEditor = lib.mkOption { + type = lib.types.bool; + default = false; + description = "set the EDITOR variable to use the current emacs server (graphical/non-graphical)"; + }; enableCopilot = lib.mkEnableOption "Enable Copilot in Doom Emacs"; enableTidal = lib.mkEnableOption "Enable TidalCycles"; withLatexPkgs = lib.mkEnableOption "Enable LaTeX packages in doom path"; @@ -146,10 +158,14 @@ in { home = { sessionPath = ["${config.xdg.configHome}/doom-emacs/bin"]; - sessionVariables = { - DOOMDIR = "${config.xdg.configHome}/doom-config"; - DOOMLOCALDIR = "${config.xdg.configHome}/doom-local"; - }; + sessionVariables = + { + DOOMDIR = "${config.xdg.configHome}/doom-config"; + DOOMLOCALDIR = "${config.xdg.configHome}/doom-local"; + } + // lib.optionalAttrs cfg.asDefaultEditor { + EDITOR = "${doom-open}"; + }; }; systemd.user.services.doom-emacs-server = {