[WIP] Things

This commit is contained in:
Andrea Ciceri 2023-07-19 19:06:53 +02:00
parent 47dfe6ddb4
commit 07fe428594
Signed by: aciceri
SSH key fingerprint: SHA256:/AagBweyV4Hlfg9u092n8hbHwD5fcB6A3qhDiDA65Rg
4 changed files with 106 additions and 154 deletions

36
flake.lock generated
View file

@ -7,11 +7,11 @@
"nixpkgs-stable": "nixpkgs-stable" "nixpkgs-stable": "nixpkgs-stable"
}, },
"locked": { "locked": {
"lastModified": 1688812108, "lastModified": 1689306175,
"narHash": "sha256-PeS1KXQ7nXg3ZOmMsgoKzgMJyxNwW3r296EFKcgr6O0=", "narHash": "sha256-8A9V2m8SsHMmn2F7SAwsbwu5QVTRR9MkX9kF48T+Qsk=",
"owner": "nix-community", "owner": "nix-community",
"repo": "emacs-overlay", "repo": "emacs-overlay",
"rev": "ec12f6d5131ea43b2023547b93ad28d1b6c00b57", "rev": "a44ec998f6c8f04973f8e8630847157efec2bbfb",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -25,11 +25,11 @@
"nixpkgs-lib": "nixpkgs-lib" "nixpkgs-lib": "nixpkgs-lib"
}, },
"locked": { "locked": {
"lastModified": 1675933616, "lastModified": 1688466019,
"narHash": "sha256-/rczJkJHtx16IFxMmAWu5nNYcSXNg1YYXTHoGjLrLUA=", "narHash": "sha256-VeM2akYrBYMsb4W/MmBo1zmaMfgbL4cH3Pu8PGyIwJ0=",
"owner": "hercules-ci", "owner": "hercules-ci",
"repo": "flake-parts", "repo": "flake-parts",
"rev": "47478a4a003e745402acf63be7f9a092d51b83d7", "rev": "8e8d955c22df93dbe24f19ea04f47a74adbdc5ec",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -43,11 +43,11 @@
"systems": "systems" "systems": "systems"
}, },
"locked": { "locked": {
"lastModified": 1687709756, "lastModified": 1689068808,
"narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=", "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7", "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -58,11 +58,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1688679045, "lastModified": 1689192006,
"narHash": "sha256-t3xGEfYIwhaLTPU8FLtN/pLPytNeDwbLI6a7XFFBlGo=", "narHash": "sha256-QM0f0d8oPphOTYJebsHioR9+FzJcy1QNIzREyubB91U=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "3c7487575d9445185249a159046cc02ff364bff8", "rev": "2de8efefb6ce7f5e4e75bdf57376a96555986841",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -75,11 +75,11 @@
"nixpkgs-lib": { "nixpkgs-lib": {
"locked": { "locked": {
"dir": "lib", "dir": "lib",
"lastModified": 1675183161, "lastModified": 1688049487,
"narHash": "sha256-Zq8sNgAxDckpn7tJo7V1afRSk2eoVbu3OjI1QklGLNg=", "narHash": "sha256-100g4iaKC9MalDjUW9iN6Jl/OocTDtXdeAj7pEGIRh4=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "e1e1b192c1a5aab2960bf0a0bd53a2e8124fa18e", "rev": "4bc72cae107788bf3f24f30db2e2f685c9298dc9",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -92,11 +92,11 @@
}, },
"nixpkgs-stable": { "nixpkgs-stable": {
"locked": { "locked": {
"lastModified": 1688594934, "lastModified": 1689209875,
"narHash": "sha256-3dUo20PsmUd57jVZRx5vgKyIN1tv+v/JQweZsve5q/A=", "narHash": "sha256-8AVcBV1DiszaZzHFd5iLc8HSLfxRAuqcU0QdfBEF3Ag=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "e11142026e2cef35ea52c9205703823df225c947", "rev": "fcc147b1e9358a8386b2c4368bd928e1f63a7df2",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -6,12 +6,11 @@
emacs-overlay.url = "github:nix-community/emacs-overlay"; emacs-overlay.url = "github:nix-community/emacs-overlay";
nixpkgs.follows = "emacs-overlay/nixpkgs"; nixpkgs.follows = "emacs-overlay/nixpkgs";
}; };
outputs = inputs @ { outputs = inputs @ {
flake-parts, flake-parts,
nixpkgs,
... ...
}: } :
flake-parts.lib.mkFlake {inherit inputs;} { flake-parts.lib.mkFlake {inherit inputs;} {
systems = ["x86_64-linux"]; systems = ["x86_64-linux"];
imports = [ imports = [
@ -22,7 +21,6 @@
./hydra ./hydra
]; ];
}; };
nixConfig = { nixConfig = {
extra-substituters = [ extra-substituters = [
"https://aciceri-emacs.cachix.org" "https://aciceri-emacs.cachix.org"
@ -34,3 +32,6 @@
]; ];
}; };
} }

199
init.el
View file

@ -1,8 +1,8 @@
;; package --- Summary ;; package --- Summary
;;; Commentary: ;;; Commentary:
;; TODO ;; TODO
;; - org-roam ;; - use-package is part of vim now, let's use it instead of setup.el!
;; - org goodies ;; - org-roam;; - org goodies
;; - persp-mode ;; - persp-mode
;; - understand how cape works ;; - understand how cape works
;; - dirvish ;; - dirvish
@ -13,38 +13,22 @@
(require 'setup) (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 current feature after FEATURES.")
(setup ligatures
(ligature-set-ligatures 't '("www"))
(ligature-set-ligatures 'prog-mode '("www" "**" "***" "**/" "*>" "*/" "\\\\" "\\\\\\" "{-" "::"
":::" ":=" "!!" "!=" "!==" "-}" "----" "-->" "->" "->>"
"-<" "-<<" "-~" "#{" "#[" "##" "###" "####" "#(" "#?" "#_"
"#_(" ".-" ".=" ".." "..<" "..." "?=" "??" ";;" "/*" "/**"
"/=" "/==" "/>" "//" "///" "&&" "||" "||=" "|=" "|>" "^=" "$>"
"++" "+++" "+>" "=:=" "==" "===" "==>" "=>" "=>>" "<="
"=<<" "=/=" ">-" ">=" ">=>" ">>" ">>-" ">>=" ">>>" "<*"
"<*>" "<|" "<|>" "<$" "<$>" "<!--" "<-" "<--" "<->" "<+"
"<+>" "<=" "<==" "<=>" "<=<" "<>" "<<" "<<-" "<<=" "<<<"
"<~" "<~~" "</" "</>" "~@" "~-" "~>" "~~" "~~>" "%%"))
(global-ligature-mode 't)
)
(setup flycheck
(:require flycheck)
(:hook-into prog-mode)
(if (display-graphic-p) (:hook flycheck-posframe-mode) (:hook flycheck-inline-mode)))
(setup eglot (setup eglot
(:with-mode eglot--managed-mode (:hook (lambda () (flymake-mode -1))))) (:with-mode eglot--managed-mode (:hook flymake-mode)))
(setup flymake
(push `(before-string . ,(propertize "E" 'display '((margin left-margin) "E"))) (get :error 'flymake-overlay-control))
(push `(before-string . ,(propertize "W" 'display '((margin left-margin) "W"))) (get :warning 'flymake-overlay-control))
(push `(before-string . ,(propertize "N" 'display '((margin left-margin) "N"))) (get :note 'flymake-overlay-control))
(push '(priority . 1098) (get :error 'flymake-overlay-control))
(push '(priority . 1099) (get :warning 'flymake-overlay-control))
(push '(priority . 1100) (get :note 'flymake-overlay-control))
(:hook-into prog-mode))
(setup sideline
(:with-mode flymake-mode (:hook sideline-mode))
(:option sideline-flymake-display-mode 'line
sideline-backends-right '(sideline-flymake)))
(setup emacs (setup emacs
(:option use-dialog-box nil (:option use-dialog-box nil
@ -58,45 +42,38 @@
backup-directory-alist `(("." . ,temporary-file-directory)) backup-directory-alist `(("." . ,temporary-file-directory))
auto-save-files-name-transforms `((".*" ,temporary-file-directory t)) auto-save-files-name-transforms `((".*" ,temporary-file-directory t))
backup-by-copying t) backup-by-copying t)
(defun ccr/set-faces () (set-face-background 'vertical-border (face-background 'default))
(set-face-attribute 'default nil :font "Fira Code 12") ;;(meow--prepare-face)
(set-face-background 'vertical-border (face-background 'default)) (set-display-table-slot standard-display-table 'vertical-border (make-glyph-code ?┃))
(meow--prepare-face)
(set-display-table-slot standard-display-table 'vertical-border (make-glyph-code ?┃)))
(if (daemonp)
(add-hook 'server-after-make-frame-hook #'ccr/set-faces)
(ccr/set-faces))
(menu-bar-mode -1) (menu-bar-mode -1)
(scroll-bar-mode -1) (xterm-mouse-mode 1)
;;(scroll-bar-mode -1)
(tool-bar-mode -1) (tool-bar-mode -1)
(global-hl-line-mode -1) (global-hl-line-mode -1)
(global-auto-revert-mode t) (global-auto-revert-mode t)
(show-paren-mode 1) (show-paren-mode 1)
(column-number-mode 1) (column-number-mode 1)
(set-frame-parameter (selected-frame) 'alpha '(98 98))
(add-to-list 'default-frame-alist '(alpha 98 98)) ;; (defun reset-terminal () (send-string-to-terminal "\033c"))
;; FIXME when running running Emacs as daemon ;; (add-hook 'kill-emacs-hook #'reset-terminal)
;; (advice-add 'enable-theme
;; :after
;; #'(lambda (&rest rest)
;; (set-face-background 'vertical-border (face-background 'default))
;; (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)
(global-set-key (kbd "<mouse-4>") 'scroll-down-line)
(global-set-key (kbd "<mouse-5>") 'scroll-up-line)
(add-hook 'server-after-make-frame-hook #'meow--prepare-face)
(load-theme 'dracula t)
(defun ccr/reload-emacs () (defun ccr/reload-emacs ()
(interactive) (interactive)
(load-file "~/.config/emacs/init.el")) (load-file "~/.config/emacs/init.el"))
(defun ccr/run-in-vterm-kill (process event) (defun ccr/run-in-vterm-kill (process event)
"A process sentinel. Kills PROCESS's buffer if it is live." "A process sentinel. Kills PROCESS's buffer if it is live."
(let ((b (process-buffer process))) (let ((b (process-buffer process)))
(and (buffer-live-p b) (and (buffer-live-p b)
(kill-buffer b)))) (kill-buffer b))))
(defun ccr/run-in-vterm (command &optional buffer-name) (defun ccr/run-in-vterm (command &optional buffer-name)
"Run command in vterm" "Run command in vterm"
@ -119,14 +96,33 @@
(ccr/run-in-vterm (ccr/run-in-vterm
"sudo nixos-rebuild switch --flake /home/ccr/fleet" "sudo nixos-rebuild switch --flake /home/ccr/fleet"
"*vterm-nixos-rebuild-switch*"))) "*vterm-nixos-rebuild-switch*")))
(setup nerd-icons
(:require treemacs)
(:require treemacs-nerd-icons)
(nerd-icons-completion-mode)
(nerd-icons-ibuffer-mode)
(nerd-icons-dired-mode)
(add-hook 'dired-mode-hook #'nerd-icons-dired-mode)
(add-hook 'marginalia-mode-hook #'nerd-icons-completion-marginalia-setup)
(add-hook 'ibuffer-mode-hook #'nerd-icons-ibuffer-mode)
(:option treemacs-show-cursor nil
treemacs-display-current-project-exclusively t
treemacs-project-follow-into-home nil)
(treemacs-load-theme "nerd-icons")
(treemacs-git-mode 'simple)
(setq treemacs-display-current-project-exclusively t)
)
(setup prog-mode (:hook display-line-numbers-mode hl-line-mode)) (setup prog-mode (:hook display-line-numbers-mode hl-line-mode))
(setup which-key :option (which-key-mode)) (setup which-key :option (which-key-mode))
(setup magit-mode (:hook magit-delta-mode)) (setup magit-mode (:hook magit-delta-mode))
(setup nix-mode (:hook eglot-ensure tree-sitter-hl-mode) (setup nix-mode (:hook
eglot-ensure
tree-sitter-hl-mode)
(global-nix-prettify-mode)) (global-nix-prettify-mode))
(setup haskell-mode (:hook eglot-ensure tree-sitter-hl-mode)) (setup haskell-mode (:hook eglot-ensure tree-sitter-hl-mode))
@ -135,7 +131,7 @@
(setup rustic-mode (setup rustic-mode
(:hook eglot-ensure tree-sitter-hl-mode) (:hook eglot-ensure tree-sitter-hl-mode)
(push 'rustic-clippy flycheck-checkers) ;;(push 'rustic-clippy flycheck-checkers)
(:option rustic-lsp-client 'eglot)) (:option rustic-lsp-client 'eglot))
(setup terraform-mode (:hook eglot-ensure tree-sitter-hl-mode)) (setup terraform-mode (:hook eglot-ensure tree-sitter-hl-mode))
@ -148,6 +144,10 @@
(:hook enable-paredit-mode) (:hook enable-paredit-mode)
(:with-mode emacs-lisp-mode (:hook enable-paredit-mode))) (:with-mode emacs-lisp-mode (:hook enable-paredit-mode)))
(setup diff-hl
(global-diff-hl-mode 1)
(diff-hl-margin-mode 1))
(setup envrc (setup envrc
(require 'inheritenv) (require 'inheritenv)
(envrc-global-mode)) (envrc-global-mode))
@ -158,7 +158,7 @@
:type 'integer) :type 'integer)
(defcustom ccr/h-resize-amount 4 (defcustom ccr/h-resize-amount 4
"How many columns move when calling `ccr/h-resize`" "How many columns move when calling `ccr/h-resize`"
:type 'integer) ;; (defcustom ccr/resize-rows 4) :type 'integer) ;; (defcustom ccr/resize-rows 4)
(defun ccr/v-resize (key) (defun ccr/v-resize (key)
"Interactively vertically resize the window" "Interactively vertically resize the window"
(interactive "cHit >/< to enlarge/shrink") (interactive "cHit >/< to enlarge/shrink")
@ -234,8 +234,9 @@
"C-c f" consult-find "C-c f" consult-find
"C-c l" consult-line "C-c l" consult-line
"C-c m" consult-mark "C-c m" consult-mark
"C-c o T" treemacs
"C-c o o" consult-outline "C-c o o" consult-outline
"C-c e" #'consult-flycheck) "C-c e" #'consult-flymake)
(:option xref-show-xrefs-function #'consult-xref (:option xref-show-xrefs-function #'consult-xref
xref-show-definitions-function #'consult-xref) xref-show-definitions-function #'consult-xref)
;; Orderless ;; Orderless
@ -257,8 +258,6 @@
;; Cape ;; Cape
(add-to-list 'completion-at-point-functions #'cape-dabbrev) (add-to-list 'completion-at-point-functions #'cape-dabbrev)
(add-to-list 'completion-at-point-functions #'cape-file) (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 ;; TODO configure corfu, cape, dabbrev, kind-icons
@ -294,8 +293,8 @@
"C-c o t" #'ccr/projectile-run-eat "C-c o t" #'ccr/projectile-run-eat
"C-c o v" #'projectile-run-vterm)) "C-c o v" #'projectile-run-vterm))
(setup vterm (setup eat
(:option vterm-timer-delay 0.01)) (:option eat-kill-buffer-on-exit t))
(setup magit (setup magit
(:global "C-c o g" magit)) (:global "C-c o g" magit))
@ -392,6 +391,7 @@
'("t" . meow-till) '("t" . meow-till)
'("u" . meow-undo) '("u" . meow-undo)
'("U" . meow-undo-in-selection) '("U" . meow-undo-in-selection)
'("/" . meow-visit)
'("v" . meow-visit) '("v" . meow-visit)
'("w" . meow-mark-word) '("w" . meow-mark-word)
'("W" . meow-mark-symbol) '("W" . meow-mark-symbol)
@ -412,10 +412,10 @@
help-mode help-mode
compilation-mode compilation-mode
"^\\*eshell.*\\*$" eshell-mode ;eshell as a popup "^\\*eshell.*\\*$" eshell-mode ;eshell as a popup
"^\\*shell.*\\*$" shell-mode ;shell as a popup "^\\*shell.*\\*$" shell-mode ;shell as a popup
"^\\*term.*\\*$" term-mode ;term as a popup "^\\*term.*\\*$" term-mode ;term as a popup
"^\\*eat.*\\*$" term-mode ;eat as a popup "^\\*eat.*\\*$" term-mode ;eat as a popup
"^\\*vterm.*\\*$" vterm-mode ;vterm as a popup "^\\*vterm.*\\*$" vterm-mode ;vterm as a popup
) )
popper-echo-lines 1 popper-echo-lines 1
popper-mode-line nil popper-mode-line nil
@ -423,8 +423,8 @@
(popper-mode 1) (popper-mode 1)
(popper-echo-mode 1) (popper-echo-mode 1)
(:global "C-c t t" popper-toggle-latest (:global "C-c t t" popper-toggle-latest
"C-c t c" popper-cycle "C-c t c" popper-cycle
"C-c t p" popper-toggle-type)) "C-c t p" popper-toggle-type))
(setup org-roam (setup org-roam
(:option org-roam-directory "~/roam/" (:option org-roam-directory "~/roam/"
@ -438,16 +438,6 @@
(org-roam-db-autosync-mode)) (org-roam-db-autosync-mode))
(setup diff-hl
(global-diff-hl-mode 1)
(defun maybe-diff-hl-margin-mode ()
(unless (display-graphic-p) (diff-hl-margin-mode)))
(when (daemonp)
;; FIXME not optimal, after the first time that a client creates a frame all the other frames
;; will use `diff-hl-margin-mode`, even if they are graphical
(add-hook 'server-after-make-frame-hook #'maybe-diff-hl-margin-mode)))
(setup dirvish (setup dirvish
(dirvish-override-dired-mode) (dirvish-override-dired-mode)
(diredfl-global-mode) (diredfl-global-mode)
@ -466,44 +456,5 @@
dired-listing-switches "-l --almost-all --human-readable --group-directories-first --no-group") dired-listing-switches "-l --almost-all --human-readable --group-directories-first --no-group")
(:with-mode dirvish-directory-view-mode (:hook diredfl-mode))) (:with-mode dirvish-directory-view-mode (:hook diredfl-mode)))
;; TODO play with skacle/sway.el
;; (setq shackle-default-rule '(:frame t)
;; shackle-display-buffer-frame-function 'sway-shackle-display-buffer-frame)
;; (sway-socket-tracker-mode)
;; (sway-undertaker-mode) ;; If you want to use :dedicate, read below.
;; (sway-x-focus-through-sway-mode) ;; Temporary workaround for Sway bug 6216
;; ;; To use with pgtk Emacs, you *must* ensure that frame names are
;; ;; unique. This is a way to achieve this:
;; (setq frame-title-format '("%b — GNU Emacs [" (:eval (frame-parameter (selected-frame) 'window-id)) "]"))
;; ;; You may want to make this nicer, feel free to improve. The only
;; ;; requirement is that each frame must have a strictly unique name on
;; ;; that Emacs instance (name collisions with other programs, including
;; ;; other Emacs processes, are not an issue )
;; (setq shackle-rules
;; `(("*Help*" :select t :frame t :dedicate t))
;; shackle-default-rule '(:frame t)
;; shackle-default-size 0.4
;; shackle-inhibit-window-quit-on-same-windows t
;; shackle-display-buffer-frame-function 'sway-shackle-display-buffer-frame)
(provide 'init) (provide 'init)
;;; init.el ends here ;;; init.el ends here
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages
'(lsp-mode diff-hl org-roam-ui consult-flycheck dirvish flycheck-inline orderless diredfl rustic ef-themes corfu-doc which-key popper envrc flycheck-posframe pdf-tools embark-consult vertico tree-sitter-langs paredit ligature hl-todo vterm yaml-mode eat kind-icon terraform-mode sway corfu-terminal shackle consult-projectile magit-delta nix-mode code-review haskell-mode delight marginalia meow eshell-syntax-highlighting all-the-icons-completion esh-autosuggest cape setup)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)

View file

@ -1,12 +1,17 @@
pkgs: epkgs: pkgs: epkgs:
with epkgs; [ with epkgs; [
meow meow
ef-themes dracula-theme
nerd-icons
nerd-icons-completion
nerd-icons-ibuffer
nerd-icons-dired
treemacs-nerd-icons
sideline
sideline-flymake
delight delight
vertico vertico
marginalia marginalia
all-the-icons
all-the-icons-completion
consult consult
orderless orderless
embark embark
@ -20,17 +25,12 @@ with epkgs; [
diff-hl diff-hl
corfu corfu
corfu-terminal corfu-terminal
# corfu-doc
kind-icon kind-icon
cape cape
which-key which-key
nix-mode nix-mode
envrc envrc
inheritenv inheritenv
flycheck
flycheck-posframe
flycheck-inline
consult-flycheck
popper popper
paredit paredit
tree-sitter tree-sitter