user/settings/emacs.nix (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | {
config,
pkgs,
lib,
inputs,
...
}:
let
inherit (pkgs) stdenv;
inherit (lib) removePrefix;
nixfiles = config.home.homeDirectory + "/projects/alin.ovh/nixfiles";
direct_symlink = path: config.lib.file.mkOutOfStoreSymlink "${nixfiles}/${removePrefix "/" path}";
editorScript = pkgs.writeScriptBin "emacsc" ''
#!${pkgs.runtimeShell}
if [ -z "$1" ]; then
exec ${config.programs.emacs.finalPackage}/bin/emacsclient --create-frame --alternate-editor ${config.programs.emacs.finalPackage}/bin/emacs
else
exec ${config.programs.emacs.finalPackage}/bin/emacsclient --alternate-editor ${config.programs.emacs.finalPackage}/bin/emacs --create-frame "$@"
fi
'';
in
{
imports = [
../modules/eshell.nix
];
programs.git.attributes = [
"*.el diff=elisp"
];
programs.git.settings."diff.elisp" = {
xfuncname = "^\\([^[:space:]]+[[:space:]]+([^()[:space:]]+)";
};
services.emacs = lib.mkIf stdenv.isLinux {
enable = true;
package = config.programs.emacs.finalPackage;
client.enable = true;
};
programs.emacs = {
enable = true;
package = lib.mkDefault (if stdenv.isLinux then pkgs.emacs-gtk else pkgs.emacs-macport);
eshell = {
aliases = {
pk = "eshell-up-pk $1";
up = "eshell-up $1";
ec = "find-file $1";
l = "ls $*";
la = "ls -A $*";
ll = "ls -lh $*";
lla = "ls -lhA $*";
http = "xh";
https = "xh --default-scheme https $*";
cdg = "cd (project-root)";
};
};
extraPackages =
epkgs:
(with epkgs; [
aggressive-indent
apheleia
avy
buffer-terminator
cape
corfu
consult
consult-ghq
consult-eglot
consult-lsp
crux
dtrt-indent
envrc
editorconfig
eldoc-box
elisp-refs
esh-buf-stack
esh-help
eshell-fringe-status
eshell-toggle
eshell-up
evil
evil-anzu
evil-collection
evil-embrace
evil-exchange
evil-lion
evil-matchit
evil-numbers
evil-org
evil-quickscope
evil-space
evil-surround
evil-textobj-tree-sitter
exec-path-from-shell
expand-region
feature-mode
flycheck
flymake-popon
general
git-gutter-fringe
git-modes
git-timemachine
gl-conf-mode # gitolite
goto-chg
helpful
jinx
just-ts-mode
kind-icon
lua-mode
link-hint
lispyville
magit
markdown-mode
marginalia
nerd-icons
nix-ts-mode
doom-modeline
persist-state
posframe
rainbow-mode
rainbow-delimiters
systemd
tempel
tempel-collection
eglot-tempel
(treesit-grammars.with-grammars (
grammars: with grammars; [
tree-sitter-nix
tree-sitter-markdown
tree-sitter-json
tree-sitter-json5
tree-sitter-toml
tree-sitter-yaml
]
))
try
vc-msg
vertico
vertico-prescient
wgrep-ag
ws-butler
which-key
]);
extraConfig = lib.mkBefore ''
;;; default --- site init file -*- lexical-binding: t; -*-
(with-eval-after-load 'editorconfig
(setq editorconfig-exec-path "${pkgs.editorconfig-core-c}/bin/editorconfig"))
'';
};
home.packages = with pkgs; [
editorScript
enchant
];
xdg.configFile = {
"emacs/early-init.el".source = "${inputs.minimal-emacs}/early-init.el";
"emacs/init.el".source = "${inputs.minimal-emacs}/init.el";
"emacs/pre-early-init.el".source = direct_symlink "user/settings/emacs/pre-early-init.el";
"emacs/post-early-init.el".source = direct_symlink "user/settings/emacs/post-early-init.el";
"emacs/pre-init.el".source = direct_symlink "user/settings/emacs/pre-init.el";
"emacs/post-init.el".source = direct_symlink "user/settings/emacs/post-init.el";
};
}
|