Merge branch 'flake'

This commit is contained in:
Andrea Ciceri 2023-02-12 16:46:43 +01:00
commit e2368dabe4
No known key found for this signature in database
GPG key ID: A1FC89532D1C5654
9 changed files with 675 additions and 326 deletions

3
.gitmodules vendored
View file

@ -1,3 +0,0 @@
[submodule "feeds"]
path = feeds
url = git@github.com:aciceri/feeds.git

View file

@ -1,321 +1,3 @@
#+PROPERTY: header-args:emacs-lisp :tangle yes
* My opinionated Emacs
* My Emacs' configuration
This is my Emacs configuration, it's written as [[https://www.wikiwand.com/en/Literate_programming][literate programming]]
using [[https://orgmode.org/][org-mode]]'s Babel.
All the settings are enclosed inside this single file named
[[README.org]], the reason of this choice is that many services (like
GitHub) automatically looks for these names.
The configuration of different Emacs' aspects are kept divided in
different paragraphs.
This file must be considered part of the Git repository to which it
belongs and it may not work properly without the other files.
Despite I mainly use [[https://nixos.org][NixOS]] I chose to keep my Emacs configuration
detached from my Nix files, this way I should be able get my Emacs'
settings in a non-Nix environment.
However the installing process of the required packages is not managed
by this configuration; for example on my NixOS system I use the
[[https://github.com/nix-community/emacs-overlay][emacs-overlay]] which automatically parses this file looking for the
~(use-package <package>)~ declarations and then downloads and builds
the latest versions from MELPA.
I preferred to maintain this agnostic approach in order to don't make
this already dense file even more complex.
Indeed, as it's configured, ~use-package~ should ensure that the
packages are installed, and if this is not the case it should install
them.
I use [[https://github.com/ch11ng/exwm][EXWM]] (i.e. Emacs X Window Manager) but since I wanted to keep
the possibility to use this configuration also on different systems
(maybe without X.org) I tried to isolate its settings.
So, even if I never tried, it should be easy to disable it without
consequences.
** General settings
This snippet contatins different things that I wasn't able to gather
better.
Hopefully, in a future, this section won't exist anymore.
#+begin_src emacs-lisp
(setq create-lockfiles nil)
(setq backup-directory-alist '((".*" . "~/.emacs-saves/")))
(setq auto-save-file-name-transforms '((".*" "~/.emacs-saves/" t)))
(setq backup-by-copying t)
(setq delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t)
(defalias 'yes-or-no-p 'y-or-n-p)
(setq use-dialog-box nil)
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(fringe-mode 1)
(setq display-time-format "%H:%M")
(display-time-mode 1)
(setq mouse-autoselect-window 't)
(setq inhibit-startup-screen t)
(setq async-shell-command-buffer 'new-buffer)
(add-hook 'prog-mode-hook 'display-line-numbers-mode)
(add-hook 'prog-mode-hook 'hl-line-mode)
(add-hook 'org-mode-hook 'auto-fill-mode)
(set-fill-column 80)
(add-to-list 'default-frame-alist '(font . "Fira Code-12"))
(set-face-attribute 'default t :font "Fira Code-12")
(setq show-paren-delay 0)
(set-face-background 'show-paren-match "#111")
(set-face-attribute 'show-paren-match nil :weight 'extra-bold)
(show-paren-mode 1)
(add-hook 'text-mode-hook
(lambda () (set-input-method "italian-postfix")))
#+end_src
** Theming
I'm using the ~doom-one~ theme from the ~doom-themes~ package.
In addition it's loaded the ~all-the-icons~ fonts and a special
modeline from ~doom-modeline~.
#+begin_src emacs-lisp
(use-package doom-themes
:config
;; Global settings (defaults)
(setq doom-themes-enable-bold t ; if nil, bold is universally disabled
doom-themes-enable-italic t) ; if nil, italics is universally disabled
(load-theme 'doom-one t)
;; Enable flashing mode-line on errors
(doom-themes-visual-bell-config)
(setq doom-themes-treemacs-theme "doom-colors") ; use the colorful treemacs theme
(doom-themes-treemacs-config)
;; Corrects (and improves) org-mode's native fontification.
(doom-themes-org-config)
)
(set-frame-parameter (selected-frame) 'alpha '(98 . 98))
(add-to-list 'default-frame-alist '(alpha . (98 . 98)))
(use-package all-the-icons)
(use-package doom-modeline
:init (doom-modeline-mode 1))
(use-package fira-code-mode
:hook prog-mode
:config (setq fira-code-mode-disabled-ligatures '("x")))
#+end_src
** Evil
In a future I think I'll try the Emacs keybindings, but for now I
prefer the Vim keybindings, at least for the text editing.
Since I use small keyboards I think it's better to use a modal editor,
however for everything that is not text editing I use the normal Emacs
keybindings.
#+begin_src emacs-lisp
(use-package evil
:init
(setq evil-want-keybinding nil)
:config
(progn
(evil-mode 1) ; globally enable evil-mode except for the following modes
(mapcar (lambda (mode) (evil-set-initial-state mode 'emacs))
'(vterm-mode
eshell-mode
dired-mode
))))
(use-package evil-collection
:after (evil company-mode vterm)
:config
(evil-collection-init))
(use-package org-evil)
#+end_src
** Org configuration
#+begin_src emacs-lisp
(require 'org-protocol)
(setq org-default-notes-file (concat org-directory "~/notes.org"))
(setq org-capture-templates `(
("p" "Protocol" entry (file+headline ,(concat org-directory "notes.org") "Inbox")
"* %^{Title}\nSource: %u, %c\n #+BEGIN_QUOTE\n%i\n#+END_QUOTE\n\n\n%?")
("L" "Protocol Link" entry (file+headline ,(concat org-directory "notes.org") "Inbox")
"* %? [[%:link][%:description]] \nCaptured On: %U")
))
(org-babel-do-load-languages
'org-babel-load-languages
'((python . t)))
(setq safe-local-variable-values '((eval add-hook 'after-save-hook 'org-icalendar-export-to-ics nil t)))
(setq org-agenda-files '("~/nas/syncthing/orgzly/Agenda.org" "~/nas/syncthing/orgzly/Lavoro.org"))
(setq org-format-latex-options (plist-put org-format-latex-options :scale 1.6))
;;(use-package org-fragtog
;; :hook (org-mode org-fragtog))
#+end_src
** Helm
Unfortunately this is currently unmantained (there was only a
mantainer, who devoted himself to it for years) but I hope that
someone in the near future will pick up the project.
However this is really stable and I never had problems.
#+begin_src emacs-lisp
(use-package helm
:init
(progn
(require 'helm-config)
(setq helm-autoresize-max-height 0)
(setq helm-autoresize-min-height 20)
(global-set-key (kbd "C-c h") 'helm-command-prefix)
(global-unset-key (kbd "C-x c"))
(when (executable-find "ack")
(setq helm-grep-default-command "ack -Hn --no-group --no-color %e %p %f"
helm-grep-default-recurse-command "ack -H --no-group --no-color %e %p %f"))
(setq helm-semantic-fuzzy-match t
helm-imenu-fuzzy-match t
helm-M-x-fuzzy-match t ;; optional fuzzy matching for helm-M-x
helm-buffers-fuzzy-matching t
helm-recentf-fuzzy-match t
helm-split-window-in-side-p t
helm-buffer-max-length nil)
(helm-mode 1)
(helm-autoresize-mode 1))
:bind
(("C-c h" . helm-command-prefix)
:map helm-command-map
("b" . helm-buffers-list)
("f" . helm-find-files)
("m" . helm-mini)
("o" . helm-imenu))
:bind
(("M-x" . helm-M-x)
("M-y" . helm-show-kill-ring)
("C-x b" . helm-mini)
("C-x C-f" . helm-find-files)))
#+end_src
** Programming
*** FlyCheck
#+begin_src emacs-lisp
(use-package flycheck
:init (global-flycheck-mode))
(use-package company
:init (global-company-mode))
(use-package company-quickhelp
:straight t
:config
(company-quickhelp-mode))
(use-package company-try-hard
:straight t
:bind
(("C-<tab>" . company-try-hard)
:map company-active-map
("C-<tab>" . company-try-hard)))
#+end_src
*** Git
#+begin_src emacs-lisp
(use-package magit)
#+end_src
*** Solidity
#+begin_src emacs-lisp
(use-package solidity-flycheck
:init (setq solidity-flycheck-solc-checker-active t)) ;requires solc in PATH
#+end_src
*** Python
#+begin_src emacs-lisp
(use-package elpy
:init (elpy-enable)
:config :config
(setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
)
(use-package blacken)
(use-package python-flycheck
:init (setq elpy-modules (delq 'elpy-module-flymake elpy-modules)))
(use-package company-jedi)
#+end_src
*** LSP
#+begin_src emacs-lisp
(use-package lsp-mode
:init
;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l")
(setq lsp-keymap-prefix "C-c l")
:hook (;; replace XXX-mode with concrete major-mode(e. g. python-mode)
(XXX-mode . lsp)
;; if you want which-key integration
(lsp-mode . lsp-enable-which-key-integration))
:commands lsp)
;; optionally
(use-package lsp-ui :commands lsp-ui-mode)
;; if you are helm user
(use-package helm-lsp :commands helm-lsp-workspace-symbol)
;; optionally if you want to use debugger
(use-package dap-mode)
;; (use-package dap-LANGUAGE) to load the dap adapter for your language
;; optional if you want which-key integration
(use-package which-key
:config
(which-key-mode))
(add-hook 'haskell-mode-hook #'lsp)
(add-hook 'haskell-literate-mode-hook #'lsp)
#+end_src
*** Haskell
#+begin_src emacs-lisp
(use-package haskell-mode)
(use-package lsp-haskell)
(use-package dap-haskell)
#+end_src
*** Nix
#+begin_src emacs-lisp
(use-package nix-mode
:mode "\\.nix\\'")
;;(use-package company-nixos-options
;; :after company
;; :config
;; (progn
;; (add-to-list 'company-backends 'company-nixos-options)))
(use-package helm-nixos-options)
#+end_src
** Mail
*** Notmuch
#+begin_src emacs-lisp
(use-package notmuch)
(use-package org-notmuch)
#+end_src
*** SMTP settings
#+begin_src emacs-lisp
(setq smtpmail-smtp-server "smtp.autistici.org"
smtpmail-smtp-service 587
smtpmail-local-domain "")
#+end_src
This is a Nix flake to build my Emacs

1
feeds

@ -1 +0,0 @@
Subproject commit 5468c563191acba8601cbf80e7f1fdcce5c7c5f9

119
flake.lock generated Normal file
View file

@ -0,0 +1,119 @@
{
"nodes": {
"emacs-overlay": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1676196577,
"narHash": "sha256-nzXTh2VQZDyzIc6ed2+qoRT/FUKkQQAaLEFPy2MKB+A=",
"owner": "nix-community",
"repo": "emacs-overlay",
"rev": "25bc792c9fe3ab354e7b51539b4da72ac821dde9",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "emacs-overlay",
"type": "github"
}
},
"emacs-src": {
"flake": false,
"locked": {
"lastModified": 1676205563,
"narHash": "sha256-anRfug+WyfWr0HRhdmo65Z1Ey15BrtJzJEMPsuwCVsY=",
"ref": "refs/heads/master",
"rev": "ac2c7a28da0b1bbed0fc92723c041b739b821977",
"revCount": 164935,
"type": "git",
"url": "git://git.savannah.gnu.org/emacs.git?branch=emacs29"
},
"original": {
"type": "git",
"url": "git://git.savannah.gnu.org/emacs.git?branch=emacs29"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1675933616,
"narHash": "sha256-/rczJkJHtx16IFxMmAWu5nNYcSXNg1YYXTHoGjLrLUA=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "47478a4a003e745402acf63be7f9a092d51b83d7",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1676110339,
"narHash": "sha256-kOS/L8OOL2odpCOM11IevfHxcUeE0vnZUQ74EOiwXcs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e5530aba13caff5a4f41713f1265b754dc2abfd8",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1675183161,
"narHash": "sha256-Zq8sNgAxDckpn7tJo7V1afRSk2eoVbu3OjI1QklGLNg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e1e1b192c1a5aab2960bf0a0bd53a2e8124fa18e",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"emacs-overlay": "emacs-overlay",
"emacs-src": "emacs-src",
"flake-parts": "flake-parts",
"nixpkgs": [
"emacs-overlay",
"nixpkgs"
]
}
}
},
"root": "root",
"version": 7
}

39
flake.nix Normal file
View file

@ -0,0 +1,39 @@
{
description = "My opinionated Emacs";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
emacs-overlay.url = "github:nix-community/emacs-overlay";
emacs-src = {
url = "git://git.savannah.gnu.org/emacs.git?branch=emacs29";
flake = false;
};
nixpkgs.follows = "emacs-overlay/nixpkgs";
};
outputs = inputs @ {
flake-parts,
nixpkgs,
...
}:
flake-parts.lib.mkFlake {inherit inputs;} {
systems = ["x86_64-linux"];
imports = [
# flake-parts.flakeModules.easyOverlay
./packages
./hmModules
./formatter
];
};
nixConfig = {
extra-substituters = [
"https://aciceri-fleet.cachix.org"
"https://nix-community.cachix.org"
];
extra-trusted-public-keys = [
"aciceri-fleet.cachix.org-1:e1AodrwmzRWy0eQi3lUY71M41fp9Sq+UpuKKv705xsI="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};
}

5
formatter/default.nix Normal file
View file

@ -0,0 +1,5 @@
{
perSystem = {pkgs, ...}: {
formatter = pkgs.alejandra;
};
}

77
hmModules/default.nix Normal file
View file

@ -0,0 +1,77 @@
{self, inputs, ...}: {
flake.overlays.default = self: super: {
ccrEmacs = self.packages.${self.system}.ccrEmacs;
};
flake.hmModules = {
default = self.hmModules.ccrEmacs;
ccrEmacs = {
lib,
pkgs,
config,
...
}: {
options.ccrEmacs = {
enable = lib.mkEnableOption "Enable custom Emacs";
package = lib.mkOption {
type = lib.types.package;
description = "Custom Emacs package";
default = self.packages.${pkgs.system}.ccrEmacs;
};
};
config = let
ccrEmacsConfig = config.ccrEmacs;
in
lib.mkIf ccrEmacsConfig.enable {
nixpkgs.overlays = [(self: super: {
ccrEmacs = super.hello;
})];
programs.emacs = {
enable = true;
package = ccrEmacsConfig.package;
};
services.emacs = {
enable = true;
client.enable = true;
defaultEditor = true;
socketActivation.enable = true;
startWithUserSession = true;
};
home.packages = with pkgs;
[
# TODO add epub-thumbnailer to nixpkgs
nil
terraform-lsp
imagemagick
ffmpegthumbnailer
mediainfo
unzipNLS
binutils
(ripgrep.override {withPCRE2 = true;})
gnutls
fd
imagemagick
sqlite
maim
jq
xclip
hunspell
]
++ (with hunspellDicts; [
en_US-large
it_IT
]);
home.activation = {
cloneCcrEmacsFlake = lib.hm.dag.entryAfter ["writeBoundary"] ''
PATH=$PATH:${lib.makeBinPath (with pkgs; [ git openssh ])}
if [ ! -d "$HOME/.config/emacs" ]; then
$DRY_RUN_CMD git clone \
https://github.com/aciceri/emacs.git \
"$HOME/.config/emacs"
ln -s "$HOME/.config/emacs" "$HOME/emacs"
fi
'';
};
};
};
};
}

414
init.el
View file

@ -1,2 +1,412 @@
(require 'org)
(org-babel-load-file (concat user-emacs-directory "README.org"))
;; package --- Summary
;;; Commentary:
;; TODO
;; - org-roam
;; - org goodies
;; - persp-mode
;; - understand how cape works
;; - dirvish
;; - prettify eshell
;; - projectile
;;; Code:
(require 'setup)
(setup-define :load-after
(lambda (&rest features)
(let ((body `(require ',(setup-get 'feature))))
(dolist (feature (nreverse features))
(setq body `(with-eval-after-load ',feature ,body)))
body))
:documentation "Load the cvurrent feature after FEATURES.")
(setup fira-code-mode (when (display-graphic-p) (global-fira-code-mode)))
(setup flycheck
(:require flycheck)
(:hook-into prog-mode)
(if (display-graphic-p) (:hook flycheck-posframe-mode) (:hook flycheck-inline-mode)))
(setup eglot
(:with-mode eglot--managed-mode (:hook (lambda () (flymake-mode -1)))))
(setup emacs
(:option use-dialog-box nil
use-short-answers t
native-comp-async-report-warnings-errors nil
inhibit-startup-message t
visible-bell t
scroll-conservatively 101 ;; more than 100 => redisplay doesn't recenter point
scroll-margin 3
temporary-file-directory "~/.emacs-saves/"
backup-directory-alist `(("." . ,temporary-file-directory))
auto-save-files-name-transforms `((".*" ,temporary-file-directory t))
backup-by-copying t)
(set-face-attribute 'default nil :font "Fira Code 12")
(menu-bar-mode -1)
(scroll-bar-mode -1)
(tool-bar-mode -1)
(global-hl-line-mode -1)
(global-auto-revert-mode t)
(show-paren-mode 1)
(column-number-mode 1)
(unless (display-graphic-p)
(advice-add 'enable-theme
:after
#'(lambda (&rest rest)
(let* ((bg-color (face-attribute 'default :background))
(ansi-command (format "\033]11;#%s\007"
(string-remove-prefix "#" bg-color))))
(send-string-to-terminal ansi-command))))
(defun reset-terminal () (send-string-to-terminal "\033c"))
(add-hook 'kill-emacs-hook #'reset-terminal))
(ef-themes-select 'ef-day)
(defun ccr/reload-emacs ()
(interactive)
(load-file "~/.vanilla-emacs.d/init.el"))
(defun ccr/run-in-vterm-kill (process event)
"A process sentinel. Kills PROCESS's buffer if it is live."
(let ((b (process-buffer process)))
(and (buffer-live-p b)
(kill-buffer b))))
(defun ccr/run-in-vterm (command &optional buffer-name)
"Run command in vterm"
(interactive)
(with-current-buffer (vterm (if buffer-name buffer-name (concat "*" command "*")))
(set-process-sentinel vterm--process #'ccr/run-in-vterm-kill)
(vterm-send-string command)
(vterm-send-return)))
(defun ccr/nixos-rebuild-test ()
"Run `nixos-rebuild test`"
(interactive)
(ccr/run-in-vterm
"sudo nixos-rebuild test --flake /home/ccr/fleet"
"*vterm-nixos-rebuild-test*"))
(defun ccr/nixos-rebuild-switch ()
"Run `nixos-rebuild switch`"
(interactive)
(ccr/run-in-vterm
"sudo nixos-rebuild switch --flake /home/ccr/fleet"
"*vterm-nixos-rebuild-switch*")))
(setup prog-mode (:hook display-line-numbers-mode hl-line-mode))
(setup which-key :option (which-key-mode))
(setup magit-mode (:hook magit-delta-mode))
(setup nix-mode (:hook eglot-ensure tree-sitter-hl-mode)
(global-nix-prettify-mode))
(setup haskell-mode (:hook eglot-ensure tree-sitter-hl-mode))
(setup terraform-mode (:hook eglot-ensure tree-sitter-hl-mode))
(setup yaml-mode (:hook tree-sitter-hl-mode))
(setup sh-mode (:hook tree-sitter-hl-mode))
(setup lisp
(:hook enable-paredit-mode)
(:with-mode emacs-lisp-mode (:hook enable-paredit-mode)))
(setup envrc (envrc-global-mode))
(setup windmove
(defcustom ccr/v-resize-amount 4
"How many rows move when calling `ccr/v-resize`"
:type 'integer)
(defcustom ccr/h-resize-amount 4
"How many columns move when calling `ccr/h-resize`"
:type 'integer) ;; (defcustom ccr/resize-rows 4)
(defun ccr/v-resize (key)
"Interactively vertically resize the window"
(interactive "cHit >/< to enlarge/shrink")
(cond ((eq key (string-to-char ">"))
(enlarge-window-horizontally ccr/v-resize-amount)
(call-interactively 'ccr/v-resize))
((eq key (string-to-char "<"))
(enlarge-window-horizontally (- ccr/v-resize-amount))
(call-interactively 'ccr/v-resize))
(t (push key unread-command-events))))
(defun ccr/h-resize (key)
"Interactively horizontally resize the window"
(interactive "cHit >/< to enlarge/shrink")
(cond ((eq key (string-to-char ">"))
(enlarge-window ccr/h-resize-amount)
(call-interactively 'ccr/h-resize))
((eq key (string-to-char "<"))
(enlarge-window (- ccr/h-resize-amount))
(call-interactively 'ccr/h-resize))
(t (push key unread-command-events))))
(:global "C-c w k" #'windmove-up
"C-c w l" #'windmove-right
"C-c w j" #'windmove-down
"C-c w h" #'windmove-left
"C-c w <up>" #'windmove-up
"C-c w <right>" #'windmove-right
"C-c w <down>" #'windmove-down
"C-c w <left>" #'windmove-left
"C-c w q" #'delete-window
"C-c w K" #'windmove-delete-up
"C-c w L" #'windmove-delete-right
"C-c w J" #'windmove-delete-down
"C-c w H" #'windmove-delete-left
"C-c w x" #'kill-buffer-and-window
"C-c w v" #'split-window-right
"C-c w s" #'split-window-below
"C-c w V" #'ccr/v-resize
"C-c w S" #'ccr/h-resize))
(setup (:package vertico marginalia consult orderless embark corfu)
;; Vertico
(:option vertico-mouse-mode t
vertico-reverse-mode t
vertico-count 8
vertico-resize t
vertico-cycle t
vertico-mode t)
(:bind-into vertico-map
"DEL" #'vertico-directory-delete-char
"C-DEL" #'vertico-directory-delete-word)
;; Marginalia
(:option marginalia-mode t
marginalia-aligh 'right)
(:bind-into minibuffer-local-map
"M-A" marginalia-cycle)
;; Consult
(:global [remap switch-to-buffer] #'consult-buffer
[remap goto-line] #'consult-goto-line
[remap imenu] #'consult-imenu
[remap project-switch-to-buffer] #'consult-project-buffer
"C-c b b" #'consult-project-buffer
"C-c b B" #'consult-buffer
"C-c g l" #'consult-goto-line
"C-c b i" #'consult-imenu
"C-c f f" #'consult-find
"C-c F" (if (executable-find "rg")
#'consult-ripgrep
#'consult-grep)
"C-c f" consult-find
"C-c l" consult-line
"C-c m" consult-mark
"C-c o o" consult-outline
"C-c e" #'consult-flycheck)
(:option xref-show-xrefs-function #'consult-xref
xref-show-definitions-function #'consult-xref)
;; Orderless
(:option completion-styles '(orderless))
;; Embark
(:global "C-'" #'embark-act
"C-=" #'embark-dwim)
;; Corfu
(global-corfu-mode)
(unless (display-graphic-p) (corfu-terminal-mode))
(:option completion-cycle-threshold 3
tab-always-indent 'complete
kind-icon-default-face 'corfu-default)
(add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter)
(:bind-into corfu-map
"M-d" #'corfu-doc-toggle
"M-l" #'corfu-show-location
"SPC" #'corfu-insert-separator)
;; Cape
(add-to-list 'completion-at-point-functions #'cape-dabbrev)
(add-to-list 'completion-at-point-functions #'cape-file)
;; All the icons completion
(all-the-icons-completion-mode)
)
;; TODO configure corfu, cape, dabbrev, kind-icons
;; Work in progress:
(defun ccr/ignore-elisp-keywords (cand)
(or (not (keywordp cand))
(eq (char-after (car completion-in-region--data)) ?:)))
(defun ccr/setup-elisp ()
(setq-local completion-at-point-functions
`(,(cape-super-capf
(cape-capf-predicate
#'elisp-completion-at-point
;; #'my/ignore-elisp-keywords
)
#'cape-dabbrev)
cape-file)
cape-dabbrev-min-length 5))
(setup eshell
(defun ccr/eshell-new ()
"Open a new instance of eshell"
(interactive)
(eshell 'N))
(defun ccr/vterm-new ()
"Open a new instance of vterm"
(interactive)
(vterm 'N))
(:global "C-c o e" ccr/eshell-new
"C-c o t" ccr/vterm-new))
(setup magit
(:global "C-c o g" magit))
(setup yaml-mode
(add-to-list 'auto-mode-alist '("\\.y(a?)ml\\'" . yaml-mode))
(add-hook 'yaml-mode-hook ;; TODO use a more idiomatic style according to setup.el
'(lambda ()
(define-key yaml-mode-map "\C-m" 'newline-and-indent))))
(setup hl-todo (global-hl-todo-mode))
(setup meow
(:require meow)
(:option meow-cheatsheet-layout meow-cheatsheet-layout-qwerty)
(meow-motion-overwrite-define-key
'("j" . meow-next)
'("k" . meow-prev)
'("<escape>" . ignore))
(meow-leader-define-key
;; SPC j/k will run the original command in MOTION state.
'("j" . "H-j")
'("k" . "H-k")
;; Use SPC (0-9) for digit arguments.
'("1" . meow-digit-argument)
'("2" . meow-digit-argument)
'("3" . meow-digit-argument)
'("4" . meow-digit-argument)
'("5" . meow-digit-argument)
'("6" . meow-digit-argument)
'("7" . meow-digit-argument)
'("8" . meow-digit-argument)
'("9" . meow-digit-argument)
'("0" . meow-digit-argument)
'("/" . meow-keypad-describe-key)
'("?" . meow-cheatsheet))
(meow-normal-define-key
'("0" . meow-expand-0)
'("9" . meow-expand-9)
'("8" . meow-expand-8)
'("7" . meow-expand-7)
'("6" . meow-expand-6)
'("5" . meow-expand-5)
'("4" . meow-expand-4)
'("3" . meow-expand-3)
'("2" . meow-expand-2)
'("1" . meow-expand-1)
'("-" . negative-argument)
'(";" . meow-reverse)
'("," . meow-inner-of-thing)
'("." . meow-bounds-of-thing)
'("[" . meow-beginning-of-thing)
'("]" . meow-end-of-thing)
'(">" . meow-indent)
'("<" . meow-back-to-indentation)
'("a" . meow-append)
'("A" . meow-open-below)
'("b" . meow-back-word)
'("B" . meow-back-symbol)
'("c" . meow-change)
'("d" . meow-delete)
'("D" . meow-backward-delete)
'("e" . meow-next-word)
'("E" . meow-next-symbol)
'("f" . meow-find)
'("g" . meow-cancel-selection)
'("G" . meow-grab)
'("h" . meow-left)
'("H" . meow-left-expand)
'("i" . meow-insert)
'("I" . meow-open-above)
'("j" . meow-next)
'("J" . meow-next-expand)
'("k" . meow-prev)
'("K" . meow-prev-expand)
'("l" . meow-right)
'("L" . meow-right-expand)
'("m" . meow-join)
'("n" . meow-search)
'("o" . meow-block)
'("O" . meow-to-block)
'("p" . meow-yank)
'("q" . meow-quit)
'("Q" . meow-goto-line)
'("r" . meow-replace)
'("R" . meow-swap-grab)
'("s" . meow-kill)
'("t" . meow-till)
'("u" . meow-undo)
'("U" . meow-undo-in-selection)
'("v" . meow-visit)
'("w" . meow-mark-word)
'("W" . meow-mark-symbol)
'("x" . meow-line)
'("X" . meow-goto-line)
'("y" . meow-save)
'("Y" . meow-sync-grab)
'("z" . meow-pop-selection)
'("'" . repeat)
'("<escape>" . ignore))
(meow-global-mode 1))
(setup popper
(:option
popper-reference-buffers '("\*Messages\*"
"Output\*$"
"\\*Async Shell Command\\*"
"\*nixos-rebuild-(test|switch)\*"
help-mode
compilation-mode
"^\\*eshell.*\\*$" eshell-mode ;eshell as a popup
"^\\*shell.*\\*$" shell-mode ;shell as a popup
"^\\*term.*\\*$" term-mode ;term as a popup
"^\\*vterm.*\\*$" vterm-mode ;vterm as a popup
)
popper-echo-lines 1
popper-mode-line nil
)
(popper-mode 1)
(popper-echo-mode 1)
(:global "C-c t t" popper-toggle-latest
"C-c t c" popper-cycle
"C-c t p" popper-toggle-type))
(setup org-roam
(:option org-roam-directory "~/roam/"
org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag)))
(:global "C-c n l" org-roam-buffer-toggle
"C-c n f" org-roam-node-find
"C-c n g" org-roam-graph
"C-c n i" org-roam-node-insert
"C-c n c" org-roam-capture
"C-c n j" org-roam-dailies-capture-today)
(org-roam-db-autosync-mode))
(setup diff-hl (global-diff-hl-mode))
(setup dirvish
(dirvish-override-dired-mode)
(diredfl-global-mode)
(dirvish-peek-mode)
(dirvish-side-follow-mode)
(pdf-tools-install)
(:option dirvish-use-header-line nil
dirvish-attributes '(all-the-icons
file-time
file-size
collapse
subtree-state
vc-state
git-msg)
delete-by-moving-to-trash t
dired-listing-switches "-l --almost-all --human-readable --group-directories-first --no-group")
(:with-mode dirvish-directory-view-mode (:hook diredfl-mode)))
(provide 'init)
;;; init.el ends here

21
packages/default.nix Normal file
View file

@ -0,0 +1,21 @@
{inputs, ...}: {
perSystem = {
self',
inputs',
pkgs,
...
}: {
packages = {
ccrEmacs =
(inputs'.emacs-overlay.packages.emacsPgtk.override {
treeSitterPlugins = builtins.attrValues (builtins.removeAttrs pkgs.tree-sitter-grammars ["recurseForDerivations"]);
})
.overrideAttrs (_: {
name = "ccr-emacs-${inputs.emacs-src.rev}";
src = inputs.emacs-src.outPath;
version = inputs.emacs-src.rev;
});
default = self'.packages.ccrEmacs;
};
};
}