diff options
| author | cashmere <cashmere@autistici.org> | 2025-10-22 02:58:12 +0200 |
|---|---|---|
| committer | cashmere <cashmere@autistici.org> | 2025-10-22 02:58:12 +0200 |
| commit | f6eaffedacb5d3d845723ed2fdd0192bed544d99 (patch) | |
| tree | b90a975a5de820761e7dd3b70792718ef54bbb6a | |
| parent | faa446b92dc47140d5b01f9e9c0b8baecf614f3f (diff) | |
| download | emacs-f6eaffedacb5d3d845723ed2fdd0192bed544d99.tar.gz | |
switch again to config.org setup
| -rw-r--r-- | config.org | 2001 | ||||
| -rw-r--r-- | init.el | 4 |
2 files changed, 1089 insertions, 916 deletions
@@ -1,26 +1,25 @@ -#+title: My Emacs configuration +#+title: config.org +#+date: [2025-10-20 Mon 08:33] +#+filetags: :fleet: +#+identifier: 20251020T083323 #+PROPERTY: header-args :tangle yes -#+startup: content +#+STARTUP: content * early-init #+begin_src emacs-lisp - ;;; config.el --- Emacs-Kick --- A feature rich Emacs config for (neo)vi(m)mers -*- lexical-binding: t; -*- ;; (setenv "LSP_USE_PLISTS" "true") -(setq gc-cons-threshold #x40000000) - -;; (setq read-process-output-max (* 1024 1024 4)) - -;; (setq package-enable-at-startup nil) - -(prefer-coding-system 'utf-8-unix) -(set-default-coding-systems 'utf-8-unix) -(set-terminal-coding-system 'utf-8-unix) -(set-keyboard-coding-system 'utf-8-unix) -(setq default-buffer-file-coding-system 'utf-8-unix) -(setq-default buffer-file-coding-system 'utf-8-unix) +;; (setq debug-on-error '(wrong-type-argument)) +;; (setq gc-cons-threshold #x40000000) +;; (setq gc-cons-threshold 50000000) +;; (setenv "LSP_USE_PLISTS" "true") +(setq lsp-use-plists t) +(setq default-frame-alist '((undecorated . t))) +(setq gc-cons-threshold 100000000) +(add-hook 'emacs-startup-hook + (lambda () (setq gc-cons-threshold (* 50 1024 1024)))) (setq create-lockfiles nil) (setq make-backup-files nil) @@ -36,20 +35,14 @@ (setq kept-old-versions 5) #+end_src -* Visual Optimizations - -Let's define some visual optimizations to change the appearnce of Emacs. - * emacs #+begin_src emacs-lisp - - ;;; EMACS -;; This is biggest one. Keep going, plugins (oops, I mean packages) will be shorter :) (use-package emacs :straight nil :ensure nil :custom ;; Set custom variables to configure Emacs behavior. + (setq modify-coding-system-alist 'file "" 'utf-8) (column-number-mode t) ;; Display the column number in the mode line. (auto-save-default nil) ;; Disable automatic saving of buffers. (create-lockfiles nil) ;; Prevent the creation of lock files when editing. @@ -81,8 +74,7 @@ Let's define some visual optimizations to change the appearnce of Emacs. :config (add-to-list 'custom-theme-load-path user-emacs-directory) -(setq catppuccin-flavor 'frappe) ;; or 'latte, 'macchiato, or 'mocha -(catppuccin-reload) + ;; (load-theme 'rose-pine t) ;; By default emacs gives you access to a lot of *special* buffers, while navigating with [b and ]b, ;; this might be confusing for newcomers. This settings make sure ]b and [b will always load a @@ -96,7 +88,7 @@ Let's define some visual optimizations to change the appearnce of Emacs. ;; Configure font settings based on the operating system. ;; Ok, this kickstart is meant to be used on the terminal, not on GUI. ;; But without this, I fear you could start Graphical Emacs and be sad :( - (set-face-attribute 'default nil :family "Maple Mono NF" :height 160) + (set-face-attribute 'default nil :family "MonoLisa" :height 150) ;; (when (eq system-type 'darwin) ;; Check if the system is macOS. ;; (setq mac-command-modifier 'meta) ;; Set the Command key to act as the Meta key. ;; (set-face-attribute 'default nil :family "Fragment Mono" :height 130)) @@ -117,7 +109,8 @@ Let's define some visual optimizations to change the appearnce of Emacs. (scroll-bar-mode -1) (add-to-list 'default-frame-alist '(vertical-scroll-bars . nil)) (add-to-list 'default-frame-alist '(horizontal-scroll-bars . nil)) - + (set-frame-parameter (selected-frame) 'alpha-background 60) + (add-to-list 'default-frame-alist '(alpha-background . 60)) (global-hl-line-mode -1) ;; Disable highlight of the current line (global-auto-revert-mode 1) ;; Enable global auto-revert mode to keep buffers up to date with their corresponding files. (indent-tabs-mode -1) ;; Disable the use of tabs for indentation (use spaces instead). @@ -146,103 +139,87 @@ Let's define some visual optimizations to change the appearnce of Emacs. " (emacs-init-time) (length (hash-table-keys straight--recipe-cache)))))))) -#+end_src - -* emacs-kickstart font -#+begin_src emacs-lisp (defcustom ek-use-nerd-fonts t - "Configuration for using Nerd Fonts Symbols." - :type 'boolean - :group 'appearance) + "Configuration for using Nerd Fonts Symbols." + :type 'boolean + :group 'appearance) #+end_src -* Window +* window #+begin_src emacs-lisp +(use-package window + :straight nil + :ensure nil ;; This is built-in, no need to fetch it. + :custom + (display-buffer-alist + '( + ;; ("\\*.*e?shell\\*" + ;; (display-buffer-in-side-window) + ;; (window-height . 0.25) + ;; (side . bottom) + ;; (slot . -1)) - ;;; WINDOW - ;; This section configures window management in Emacs, enhancing the way buffers - ;; are displayed for a more efficient workflow. The `window' use-package helps - ;; streamline how various buffers are shown, especially those related to help, - ;; diagnostics, and completion. - ;; - ;; Note: I have left some commented-out code below that may facilitate your - ;; Emacs journey later on. These configurations can be useful for displaying - ;; other types of buffers in side windows, allowing for a more organized workspace. - (use-package window - :straight nil - :ensure nil ;; This is built-in, no need to fetch it. - :custom - (display-buffer-alist - '( - ;; ("\\*.*e?shell\\*" - ;; (display-buffer-in-side-window) - ;; (window-height . 0.25) - ;; (side . bottom) - ;; (slot . -1)) - - ("\\*\\(Backtrace\\|Warnings\\|Compile-Log\\|[Hh]elp\\|Messages\\|Bookmark List\\|Ibuffer\\|Occur\\|eldoc.*\\)\\*" - (display-buffer-in-side-window) - (window-height . 0.25) - (side . bottom) - (slot . 0)) + ("\\*\\(Backtrace\\|Warnings\\|Compile-Log\\|[Hh]elp\\|Messages\\|Bookmark List\\|Ibuffer\\|Occur\\|eldoc.*\\)\\*" + (display-buffer-in-side-window) + (window-height . 0.25) + (side . bottom) + (slot . 0)) - ;; Example configuration for the LSP help buffer, - ;; keeps it always on bottom using 25% of the available space: - ("\\*\\(lsp-help\\)\\*" - (display-buffer-in-side-window) - (window-height . 0.25) - (side . bottom) - (slot . 0)) + ;; Example configuration for the LSP help buffer, + ;; keeps it always on bottom using 25% of the available space: + ("\\*\\(lsp-help\\)\\*" + (display-buffer-in-side-window) + (window-height . 0.25) + (side . bottom) + (slot . 0)) - ;; Configuration for displaying various diagnostic buffers on - ;; bottom 25%: - ("\\*\\(Flymake diagnostics\\|xref\\|ivy\\|Swiper\\|Completions\\)" - (display-buffer-in-side-window) - (window-height . 0.25) - (side . bottom) - (slot . 1)) - ))) + ;; Configuration for displaying various diagnostic buffers on + ;; bottom 25%: + ("\\*\\(Flymake diagnostics\\|xref\\|ivy\\|Swiper\\|Completions\\)" + (display-buffer-in-side-window) + (window-height . 0.25) + (side . bottom) + (slot . 1))))) #+end_src * dired #+begin_src emacs-lisp (use-package dired -:straight nil - :ensure nil ;; This is built-in, no need to fetch it. - :custom - (dired-listing-switches "-lah --group-directories-first") ;; Display files in a human-readable format and group directories first. - (dired-dwim-target t) ;; Enable "do what I mean" for target directories. - (dired-guess-shell-alist-user - '(("\\.\\(png\\|jpe?g\\|tiff\\)" "feh" "xdg-open" "open") ;; Open image files with `feh' or the default viewer. -("\\.\\(mp[34]\\|m4a\\|ogg\\|flac\\|webm\\|mkv\\)" "mpv" "xdg-open" "open") ;; Open audio and video files with `mpv'. -(".*" "open" "xdg-open"))) ;; Default opening command for other files. - (dired-kill-when-opening-new-dired-buffer t) ;; Close the previous buffer when opening a new `dired' instance. - :config - (when (eq system-type 'darwin) - (let ((gls (executable-find "gls"))) ;; Use GNU ls on macOS if available. -(when gls -(setq insert-directory-program gls))))) + :straight nil + :ensure nil + :custom + (dired-listing-switches "-lah --group-directories-first") + (dired-dwim-target t) + (dired-guess-shell-alist-user + '(("\\.\\(png\\|jpe?g\\|tiff\\)" "feh" "xdg-open" "open") + ("\\.\\(mp[34]\\|m4a\\|ogg\\|flac\\|webm\\|mkv\\)" "mpv" "xdg-open" "open") + (".*" "open" "xdg-open"))) + (dired-kill-when-opening-new-dired-buffer t) + :config + ;; (dired-async-mode 1) + (when (eq system-type 'darwin) + (let ((gls (executable-find "gls"))) + (when gls + (setq insert-directory-program gls))))) #+end_src * erc #+begin_src emacs-lisp (use-package erc -:straight nil - :defer t ;; Load ERC when needed rather than at startup. (Load it with `M-x erc RET') - :custom - (erc-join-buffer 'window) ;; Open a new window for joining channels. - (erc-hide-list '("JOIN" "PART" "QUIT")) ;; Hide messages for joins, parts, and quits to reduce clutter. - (erc-timestamp-format "[%H:%M]") ;; Format for timestamps in messages. - (erc-autojoin-channels-alist '((".*\\.libera\\.chat" "#emacs"))));; Automatically join the #emacs channel on Libera.Chat. + :straight nil + :defer t ;; Load ERC when needed rather than at startup. (Load it with `M-x erc RET') + :custom + (erc-join-buffer 'window) ;; Open a new window for joining channels. + (erc-hide-list '("JOIN" "PART" "QUIT")) ;; Hide messages for joins, parts, and quits to reduce clutter. + (erc-timestamp-format "[%H:%M]") ;; Format for timestamps in messages. + (erc-autojoin-channels-alist '((".*\\.libera\\.chat" "#emacs"))));; Automatically join the #emacs channel on Libera.Chat. #+end_src -* centered-cursor - -[[https://entropicthoughts.com/centered-cursor-mode-in-vanilla-emacs][Centered Cursor Mode in Vanilla Emacs]] +* TODO centered cursor #+begin_src emacs-lisp (defvar my/centered-cursor-enabled nil) @@ -270,15 +247,15 @@ Let's define some visual optimizations to change the appearnce of Emacs. #+begin_src emacs-lisp (use-package isearch -:straight nil - :ensure nil ;; This is built-in, no need to fetch it. - :config - (setq isearch-lazy-count t) ;; Enable lazy counting to show current match information. - (setq lazy-count-prefix-format "(%s/%s) ") ;; Format for displaying current match count. - (setq lazy-count-suffix-format nil) ;; Disable suffix formatting for match count. - (setq search-whitespace-regexp ".*?") ;; Allow searching across whitespace. - :bind (("C-s" . isearch-forward) ;; Bind C-s to forward isearch. - ("C-r" . isearch-backward))) ;; Bind C-r to backward isearch. + :straight nil + :ensure nil ;; This is built-in, no need to fetch it. + :config + (setq isearch-lazy-count t) ;; Enable lazy counting to show current match information. + (setq lazy-count-prefix-format "(%s/%s) ") ;; Format for displaying current match count. + (setq lazy-count-suffix-format nil) ;; Disable suffix formatting for match count. + (setq search-whitespace-regexp ".*?") ;; Allow searching across whitespace. + :bind (("C-s" . isearch-forward) ;; Bind C-s to forward isearch. + ("C-r" . isearch-backward))) ;; Bind C-r to backward isearch. #+end_src * vc @@ -296,51 +273,51 @@ Let's define some visual optimizations to change the appearnce of Emacs. :config ;; Better colors for <leader> g b (blame file) (setq vc-annotate-color-map - '((20 . "#f5e0dc") - (40 . "#f2cdcd") - (60 . "#f5c2e7") - (80 . "#cba6f7") - (100 . "#f38ba8") - (120 . "#eba0ac") - (140 . "#fab387") - (160 . "#f9e2af") - (180 . "#a6e3a1") - (200 . "#94e2d5") - (220 . "#89dceb") - (240 . "#74c7ec") - (260 . "#89b4fa") - (280 . "#b4befe")))) + '((20 . "#f5e0dc") + (40 . "#f2cdcd") + (60 . "#f5c2e7") + (80 . "#cba6f7") + (100 . "#f38ba8") + (120 . "#eba0ac") + (140 . "#fab387") + (160 . "#f9e2af") + (180 . "#a6e3a1") + (200 . "#94e2d5") + (220 . "#89dceb") + (240 . "#74c7ec") + (260 . "#89b4fa") + (280 . "#b4befe")))) #+end_src -* smerge +* smerge-mode #+begin_src emacs-lisp (use-package smerge-mode -:straight nil - :ensure nil ;; This is built-in, no need to fetch it. - :defer t - :bind (:map smerge-mode-map -("C-c ^ u" . smerge-keep-upper) ;; Keep the changes from the upper version. -("C-c ^ l" . smerge-keep-lower) ;; Keep the changes from the lower version. -("C-c ^ n" . smerge-next) ;; Move to the next conflict. -("C-c ^ p" . smerge-previous))) ;; Move to the previous conflict. + :straight nil + :ensure nil ;; This is built-in, no need to fetch it. + :defer t + :bind (:map smerge-mode-map + ("C-c ^ u" . smerge-keep-upper) ;; Keep the changes from the upper version. + ("C-c ^ l" . smerge-keep-lower) ;; Keep the changes from the lower version. + ("C-c ^ n" . smerge-next) ;; Move to the next conflict. + ("C-c ^ p" . smerge-previous))) ;; Move to the previous conflict. #+end_src * eldoc #+begin_src emacs-lisp (use-package eldoc -:straight nil - :ensure nil ;; This is built-in, no need to fetch it. - :after eglot - :config - (setq eldoc-idle-delay 0.0001) ;; Automatically fetch doc help - (setq eldoc-echo-area-use-multiline-p t) ;; We use the "K" floating help instead -;; set to t if you want docs on the echo area -(setq eldoc-help-at-pt t) -(setq eldoc-echo-area-display-truncation-message nil) - :init - (global-eldoc-mode)) + :straight nil + :ensure nil ;; This is built-in, no need to fetch it. + :after lspce-mode + :config + (setq eldoc-idle-delay 0.001) ;; Automatically fetch doc help + (setq eldoc-echo-area-use-multiline-p t) ;; We use the "K" floating help instead + ;; set to t if you want docs on the echo area + (setq eldoc-help-at-pt t) + (setq eldoc-echo-area-display-truncation-message nil) + :init + (global-eldoc-mode)) #+end_src ** eldoc-box @@ -348,12 +325,10 @@ Let's define some visual optimizations to change the appearnce of Emacs. #+begin_src emacs-lisp (use-package eldoc-box :ensure t - :straight t - :defer t :config - (setq eldoc-box-clear-with-C-g t) - (setq eldoc-box-only-multiline-doc nil) - (setq eldoc-box-frame-parameters + (eldoc-box-clear-with-C-g t) + (eldoc-box-only-multiline-doc nil) + (eldoc-box-frame-parameters '((internal-border-width . 2) (border-width . 1) (left-fringe . 8) @@ -362,35 +337,37 @@ Let's define some visual optimizations to change the appearnce of Emacs. * flymake -Disabled because nix is managing the flymake configuration. - #+begin_src emacs-lisp (use-package flymake :straight nil - :ensure nil ;; This is built-in, no need to fetch it. - :defer t - :hook (prog-mode . flymake-mode) - :custom - (flymake-margin-indicators-string - '((error "!»" compilation-error) (warning "»" compilation-warning) -(note "»" compilation-info)))) + :ensure nil ;; This is built-in, no need to fetch it. + :defer t + :hook (prog-mode . flymake-mode) + :custom + (flymake-margin-indicators-string + '((error "!»" compilation-error) (warning "»" compilation-warning) + (note "»" compilation-info)))) + +(setq trusted-content + '("~/.emacs.d/config.el" + "~/.emacs.d/init.el")) #+end_src * xref #+begin_src emacs-lisp - (use-package xref - :straight nil - :ensure nil) +(use-package xref + :straight nil + :ensure nil) #+end_src * project - #+begin_src emacs-lisp - (use-package project - :straight nil - :ensure nil) - #+end_src +#+begin_src emacs-lisp +(use-package project + :straight nil + :ensure nil) +#+end_src * org mode @@ -460,20 +437,18 @@ Disabled because nix is managing the flymake configuration. ** org-modern #+begin_src emacs-lisp - (use-package org-modern - :ensure t - ) - (with-eval-after-load 'org (global-org-modern-mode)) +(use-package org-modern + :ensure t) - (setq org-modern-star 'fold) - (setq org-modern-fold-stars '(("◉" . "○"))) - (setq org-modern-star 'replace) - (setq org-modern-replace-stars "◉○◉○◉") -#+end_src +(with-eval-after-load 'org (global-org-modern-mode)) -** org agenda +(setq org-modern-star 'fold) +(setq org-modern-fold-stars '(("◉" . "○"))) +(setq org-modern-star 'replace) +(setq org-modern-replace-stars "◉○◉○◉") +#+end_src -We will start of with setting some sane configuration for org agenda. +** TODO org-agenda settings #+begin_src emacs-lisp (setq org-agenda-start-on-weekday nil @@ -481,105 +456,153 @@ We will start of with setting some sane configuration for org agenda. org-agenda-remove-tags t) #+end_src -*** org super agenda +** org-super-agenda #+begin_src emacs-lisp (use-package org-super-agenda - :defer t + :after org-agenda + :init + (setq org-agenda-skip-scheduled-if-done t + org-agenda-skip-deadline-if-done t + org-agenda-include-deadlines t + org-agenda-block-separator nil + org-agenda-compact-blocks t + org-agenda-start-day nil + org-agenda-span 1 + org-agenda-start-on-weekday nil + org-agenda-hide-tags-regexp "task" + org-agenda-prefix-format + '((agenda . " %i %?-12t% s") + (todo . " %i ") + (tags . " %i ") + (search . " %i "))) + (setq org-agenda-custom-commands + '(("c" "Super view" + ((agenda "" ((org-agenda-overriding-header "") + (org-super-agenda-groups + '((:name "Today" + :time-grid t + :date t + :deadline today + :scheduled future + :order 1))))) + (alltodo "" ((org-agenda-overriding-header "") + (org-super-agenda-groups + '((:discard (:todo "FUN")) ; <- HIER ist die korrekte Position + (:log t) + (:name "ACTIVE" + :todo "ACTIVE") + (:name "NEXT" + :todo "NEXT") + (:name "TODO" + :todo "TODO") + (:name "WAIT" + :todo "WAIT")))))) + ((org-agenda-exporter-settings + '((ps-number-of-columns 2) + (ps-landscape-mode t) + (org-agenda-add-entry-text-maxlines 5) + (htmlize-output-type 'css))))))) :config - (setq org-super-agenda-header-prefix "\n ") - ;; Hide the thin width char glyph - (add-hook 'org-agenda-mode-hook - #'(lambda () (setq-local nobreak-char-display nil))) (org-super-agenda-mode)) #+end_src -*** org-ql +** TODO org-todo-keywords #+begin_src emacs-lisp - (use-package org-ql - :ensure t - :after org) +(setq org-todo-keywords + '((sequence "WAIT(w@/!)" "HABIT(h)" "TODO(t)" "NEXT(n)" "|" "DONE(d!)") + (sequence "BACKLOG(b)" "PLAN(p)" "READY(r)" "ACTIVE(a)" "REVIEW(v)" + "FUN(f)" "|" "COMPLETED(c)" "CANC(k@)"))) #+end_src -*** agenda views +** ox-typst -let us disable the predefined org agenda commands. +Org Backend exporter for typst templates written and configured in org mode. #+begin_src emacs-lisp -(add-to-list 'org-agenda-custom-commands - '("d" "Day View" - ((agenda "" ((org-agenda-overriding-header "Day View") - (org-agenda-span 'day) - (org-super-agenda-groups regular-view-groups))) - (org-ql-block '(todo "PROG") ((org-ql-block-header "\n In Progress"))) - (org-ql-block '(todo "NEXT") ((org-ql-block-header "\n Next Up"))) - (org-ql-block '(todo "WAIT") ((org-ql-block-header "\n Backlog"))) - (org-ql-block '(priority "A") ((org-ql-block-header "\n Important")))))) - -(add-to-list 'org-agenda-custom-commands -'("e" "Three-Day View" - ((agenda "" ((org-agenda-span 3) - (org-agenda-start-on-weekday nil) - (org-deadline-warning-days 0)))))) -#+end_src - -** exporter - -*** typst - - #+begin_src emacs-lisp (use-package ox-typst :straight (:host github :repo "jmpunkt/ox-typst") :after org) - #+end_src +#+end_src -** denote +* denote Denote is objectively the best note taking extension, which you could install. It has a very easy to parse file naming scheme and suports not only org files. It has also transclusion inclusive! if you are interested, then check it out yourself. #+begin_src emacs-lisp - (use-package denote - :ensure t - :hook (dired-mode . denote-dired-mode) - :config - (setq denote-rename-buffer-mode 1 -denote-directory (expand-file-name "~/org/"))) +(use-package denote + :ensure t + :hook (dired-mode . denote-dired-mode) + :config + (setq denote-rename-buffer-mode 1 + denote-directory (expand-file-name "~/org/"))) #+end_src -*** denote-agenda +** denote-agenda Denote fitself focused on the last versions to have a core for note taking and to be independent of org. But of course you may extend it with your own extensions, functions and helper or even extensions by its developer. One of these extesions is =denote-agenda=, which allows you to dynamically add and remove org-agendas files based on a denote keyword. I set it to =task=, very simple. When we compare it with org-roam, It took me several days to achieve almost the same workflow, one or two external packages and around of 200 extra lines of code. #+begin_src emacs-lisp - (use-package denote-agenda - :ensure t - :config - (setq denote-agenda-include-regexp "task") - (denote-agenda-insinuate)) +(use-package denote-agenda + :ensure t + :after org + :config + (setq denote-agenda-include-regexp "task") + (denote-agenda-insinuate)) #+end_src -*** denote-menu +** denote-menu #+begin_src emacs-lisp (use-package denote-menu :ensure t + :defer t :config (setq denote-menu-title-column-width 40 - denote-menu-show-file-type nil)) + denote-menu-show-file-type nil)) #+end_src -*** denote-org +** denote-org + +Some goodies for better integration with org files. #+begin_src emacs-lisp (use-package denote-org :ensure t) #+end_src -* which-key +** my/functions #+begin_src emacs-lisp +(defun my/convert-all-denote-links-in-directory (directory) + "Converts all denote: links to file: links in a specific directory." + (interactive "DDirectory: ") + (let ((org-files (directory-files directory t "\\.org$"))) + (dolist (file org-files) + (with-current-buffer (find-file-noselect file) + (save-excursion + (goto-char (point-min)) + (while (re-search-forward "\\[\\[denote:\\([0-9T]+\\)\\]\\(?:\\[\\([^]]*\\)\\]\\)?\\]" nil t) + (let* ((id (match-string 1)) + (description (match-string 2)) + (target-file (seq-find + (lambda (f) + (string-match-p (regexp-quote id) (file-name-nondirectory f))) + org-files))) + (when target-file + (let* ((target-filename (file-name-nondirectory target-file)) + (new-link (if description + (format "[[file:./%s][%s]]" target-filename description) + (format "[[file:./%s]]" target-filename)))) + (replace-match new-link t t)))))) + (save-buffer) + (kill-buffer))))) +#+end_src +* which-key + +#+begin_src emacs-lisp (use-package which-key :ensure t :defer t @@ -593,53 +616,31 @@ Denote fitself focused on the last versions to have a core for note taking and t #+begin_src emacs-lisp (use-package vertico - :ensure t - :straight t - :hook - (after-init . vertico-mode) - :custom - (vertico-count 10) - (vertico-resize nil) - (vertico-cycle nil) - :bind (:map vertico-map - ("C-j" . vertico-next) - ("C-k" . vertico-previous)) - :config - (advice-add #'vertico--format-candidate :around -(lambda (orig cand prefix suffix index _start) -(setq cand (funcall orig cand prefix suffix index _start)) -(concat - (if (= vertico--index index) -(propertize "» " 'face '(:foreground "#80adf0" :weight bold)) - " ") - cand)))) -#+end_src - -** vertico-posframe - -#+begin_src emacs-lisp -;; (use-package vertico-posframe -;; :init -;; (setq vertico-posframe-parameters '((left-fringe . 12) ;; Fringes -;; (right-fringe . 12) -;; (undecorated . nil))) ;; Rounded frame -;; :config -;; (vertico-posframe-mode 1) -;; (setq vertico-posframe-width 96 ;; Narrow frame -;; vertico-posframe-height vertico-count ;; Default height -;; ;; Don't create posframe for these commands -;; vertico-multiform-commands '((consult-line (:not posframe)) -;; (consult-ripgrep (:not posframe))))) + :ensure t + :straight t + :hook + (after-init . vertico-mode) + :custom + (vertico-count 10) + (vertico-resize nil) + (vertico-cycle nil) + :bind (:map vertico-map + ("C-j" . vertico-next) + ("C-k" . vertico-previous)) + :config + (advice-add #'vertico--format-candidate :around + (lambda (orig cand prefix suffix index _start) + (setq cand (funcall orig cand prefix suffix index _start)) + (concat + (if (= vertico--index index) + (propertize "» " 'face '(:foreground "#80adf0" :weight bold)) + " ") + cand)))) #+end_src * consult #+begin_src emacs-lisp -;;; CONSULT -;; Consult provides powerful completion and narrowing commands for Emacs. -;; It integrates well with other completion frameworks like Vertico, enabling -;; features like previews and enhanced register management. It's useful for -;; navigating buffers, files, and xrefs with ease. (use-package consult :ensure t :straight t @@ -671,46 +672,18 @@ Denote fitself focused on the last versions to have a core for note taking and t * markdown-mode #+begin_src emacs-lisp -;;; MARKDOWN-MODE -;; Markdown Mode provides support for editing Markdown files in Emacs, -;; enabling features like syntax highlighting, previews, and more. -;; It’s particularly useful for README files, as it can be set -;; to use GitHub Flavored Markdown for enhanced compatibility. (use-package markdown-mode :defer t :straight t :ensure t :mode ("README\\.md\\'" . gfm-mode) ;; Use gfm-mode for README.md files. - :init (setq markdown-command "multimarkdown")) ;; Set the Markdown processing command. + :init + (setq markdown-command "multimarkdown")) ;; Set the Markdown processing command. #+end_src -* consult - -#+begin_src emacs-lisp -(use-package corfu - :ensure t - :straight t - :defer t - :custom - (corfu-auto t) ;; Only completes when hitting TAB - (corfu-cycle t) - (text-mode-ispell-word-completion nil) - (corfu-auto-delay 0.08) ;; Delay before popup (enable if corfu-auto is t) - (corfu-auto-prefix 1) ;; Trigger completion after typing 1 character - (corfu-quit-no-match t) ;; Quit popup if no match - (corfu-scroll-margin 5) ;; Margin when scrolling completions - (corfu-max-width 50) ;; Maximum width of completion popup - (corfu-min-width 50) ;; Minimum width of completion popup - (corfu-popupinfo-delay 0.12) ;; Delay before showing documentation popup - :config - (if ek-use-nerd-fonts - (add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter)) - :init - (global-corfu-mode) - (corfu-popupinfo-mode t)) -#+end_src +* treesit-auto -* treesitter auto +ensures that every available tree sitter is downloaded and set up for you. #+begin_src emacs-lisp (use-package treesit-auto @@ -727,34 +700,15 @@ Denote fitself focused on the last versions to have a core for note taking and t * embark #+begin_src emacs-lisp -;;; EMBARK -;; Embark provides a powerful contextual action menu for Emacs, allowing -;; you to perform various operations on completion candidates and other items. -;; It extends the capabilities of completion frameworks by offering direct -;; actions on the candidates. -;; Just `<leader> .' over any text, explore it :) (use-package embark :ensure t :straight t :defer t) - - -;;; NERD-ICONS-CORFU -;; Provides Nerd Icons to be used with CORFU. -(use-package nerd-icons-corfu - :if ek-use-nerd-fonts - :ensure t - :straight t - :defer t - :after (:all corfu)) #+end_src -* embark consult +** embark-consult #+begin_src emacs-lisp -;;; EMBARK-CONSULT -;; Embark-Consult provides a bridge between Embark and Consult, ensuring -;; that Consult commands, like previews, are available when using Embark. (use-package embark-consult :ensure t :straight t @@ -762,10 +716,9 @@ Denote fitself focused on the last versions to have a core for note taking and t (embark-collect-mode . consult-preview-at-point-mode)) ;; Enable preview in Embark collect mode. #+end_src -* orderless +** orderless #+begin_src emacs-lisp - (use-package orderless :ensure t :straight t @@ -777,13 +730,9 @@ completion-category-defaults nil ;; Clear default category settings. completion-category-overrides '((file (styles partial-completion))))) ;; Customize file completion styles. #+end_src -* marginalia +** marginalia #+begin_src emacs-lisp -;; Marginalia enhances the completion experience in Emacs by adding -;; additional context to the completion candidates. This includes -;; helpful annotations such as documentation and other relevant -;; information, making it easier to choose the right option. (use-package marginalia :ensure t :straight t @@ -791,142 +740,193 @@ completion-category-overrides '((file (styles partial-completion))))) ;; Customi (after-init . marginalia-mode)) #+end_src -* nerd corfu icons +* programming + +** typst-mode #+begin_src emacs-lisp -(use-package nerd-icons-corfu - :if ek-use-nerd-fonts - :ensure t - :straight t - :defer t - :after (:all corfu)) +(use-package typst-ts-mode + :straight t + :mode "\\.typ\\'" + ;; :hook (typst-ts-mode . eglot-ensure) + :config + :defer t + ;; (with-eval-after-load 'eglot + ;; (add-to-list 'eglot-server-programs + ;; `(typst-ts-mode . ,(eglot-alternatives '("tinymist" "typst-lsp"))))) + ) #+end_src -* programming modes +** lspce -** nix-mode +*** prerequisites - #+begin_src emacs-lisp - (use-package nix-mode - :ensure t - :defer t - :mode "\\.nix\\'") - #+end_src +#+begin_src emacs-lisp +(use-package f + :ensure t) -** typst-mode +(use-package yasnippet + :ensure t + :config + (yas-global-mode 1)) + +(use-package yasnippet-snippets + :ensure t + :after yasnippet) +#+end_src - #+begin_src emacs-lisp - (use-package typst-ts-mode - :straight t - :mode "\\.typ\\'" - :hook (typst-ts-mode . eglot-ensure) - :config - ;; :defer t - (with-eval-after-load 'eglot - (add-to-list 'eglot-server-programs - `(typst-ts-mode . ,(eglot-alternatives '("tinymist" "typst-lsp")))))) - #+end_src - -** rust mode - #+begin_src emacs-lisp - (use-package rustic - :ensure t - :defer t - :custom - (rustic-lsp-client 'eglot)) - #+end_src -*** org babel integration +*** initial installation #+begin_src emacs-lisp -;; Make sure rustic gets activated in the org-src block and add the original file's source code. -(defun my-read-file-to-string (file) -(with-temp-buffer -(insert-file-contents file) -(buffer-string))) +(straight-use-package + `(lspce :type git :host github :repo "zbelial/lspce" + :files (:defaults ,(pcase system-type + ('gnu/linux "lspce-module.so") + ('darwin "lspce-module.dylib"))) + :pre-build ,(pcase system-type + ('gnu/linux '(("cargo" "build" "--release") + ("cp" "./target/release/liblspce_module.so" "./lspce-module.so"))) + ('darwin '(("cargo" "build" "--release") + ("cp" "./target/release/liblspce_module.dylib" "./lspce-module.dylib")))))) +#+end_src + +*** company -(defun org-babel-edit-prep:rust (babel-info) -(setq-local src-code (nth 1 babel-info)) -(setq-local buffer-file-name (expand-file-name (->> babel-info caddr (alist-get :tangle)))) -(setq-local buffer-src-code (replace-regexp-in-string src-code "" (my-read-file-to-string (buffer-file-name)))) -(goto-char (point-max)) -(insert buffer-src-code) -(narrow-to-region (point-min) (+ (point-min) (length src-code))) -(rustic-mode) -(org-src-mode)) +company is also required as an completion backend. besides that i really enjoy using company. -(defun my-delete-hidden-text () -(-let [p-start (point-max)] -(widen) -(delete-region p-start (point-max)))) +#+begin_src emacs-lisp +(use-package company + :straight t + :hook (after-init . global-company-mode) + :bind (:map company-active-map + ("C-n" . company-select-next) + ("C-p" . company-select-previous) + ("C-j" . company-select-next-or-abort) + ("C-k" . company-select-previous-or-abort) + ("M-j" . company-select-next) + ("M-k" . company-select-previous) + ("<tab>" . company-complete-selection) + ("TAB" . company-complete-selection)) + :config + (setq company-minimum-prefix-length 1) + (setq company-idle-delay 0.1) + (setq company-show-numbers t) + (setq company-tooltip-align-annotations t) + (setq company-require-match nil) + (setq company-backends '((company-capf :with company-yasnippet) + company-files + company-dabbrev-code)) + (setq company-dabbrev-code-everywhere t) + (setq company-dabbrev-code-ignore-case t)) +#+end_src -(define-advice org-edit-src-exit -(:before (&rest _args) remove-src-block) -(when (eq major-mode 'rustic-mode) -(my-delete-hidden-text))) +*** major config -(define-advice org-edit-src-save -(:before (&rest _args) remove-src-block) -(when (eq major-mode 'rustic-mode) -(my-delete-hidden-text))) +#+begin_src emacs-lisp +(use-package lspce + :after (f yasnippet markdown-mode envrc) + :config + (setq lspce-send-changes-idle-time 0.05) + (setq lspce-idle-delay 0.05) + (setq lspce-show-log-level-in-modeline t) + (setq lspce-enable-eldoc t) + (setq lspce-eldoc-enable-hover t) + (setq lspce-eldoc-enable-signature t) + (setq lspce--doc-max-height 10) + (setq eldoc-echo-area-use-multiline-p 2) + (setq eldoc-echo-area-display-truncation-message nil) + (setq lspce-log-level 5) + + (setq lspce-envs-pass-to-subprocess '("PATH" "PYTHON_PATH" "NIX_PATH" "NIX_PROFILES")) + + (setq lspce-server-programs + `(("rust" "rust-analyzer" "" lspce-ra-initializationOptions) + ("python" "pylsp" "" ) + ("nix" "nixd" "" lspce-nixd-initializationOptions) + ("nushell" "nu" "--lsp" "")))) #+end_src - -*** yasnippet + +** nix mode #+begin_src emacs-lisp -(use-package yasnippet +(use-package nix-mode :ensure t - :after eglot - :hook ((prog-mode . yas-minor-mode) - (org-mode . yas-minor-mode))) + :mode "\\.nix\\'" + :hook (nix-mode . lspce-mode)) +#+end_src -(use-package yasnippet-snippets - :ensure t - :after yasnippet) +*** nix flake function for more completion + +#+begin_src emacs-lisp +(defun lspce-nixd-initializationOptions () + (let ((flake-path "/home/cashmere/nix") + (config-name "x12")) + `(:nixpkgs (:expr ,(format "import (builtins.getFlake \"%s\").inputs.nixpkgs { }" flake-path)) + :formatting (:command ["nixfmt"]) + :options (:nixos (:expr ,(format "(builtins.getFlake \"%s\").nixosConfigurations.%s.options" flake-path config-name)) + :home-manager (:expr ,(format "(builtins.getFlake \"%s\").nixosConfigurations.%s.config.home-manager.users.cashmere.options" flake-path config-name)))))) #+end_src -* eglot +*** envrc + +for automatic flake devshells. #+begin_src emacs-lisp -(use-package eglot - :ensure nil - :straight nil - :hook ((rustic-mode . eglot-ensure) - (nix-mode . eglot-ensure) - (python-mode . eglot-ensure) - (eglot-managed-mode . (lambda () (eglot-inlay-hints-mode -1))) - ) - :bind (:map eglot-mode-map - ("M-<return>" . eglot-code-actions) - ("C-M-." . xref-find-references) - ("C-c r" . eglot-rename)) +(use-package envrc + :ensure t :config - (add-to-list 'eglot-server-programs - `(python-mode - . ,(eglot-alternatives '(("basedpyright-langserver" "--stdio") - ("pyright-langserver" "--stdio") - "jedi-language-server" - "pylsp")))) - (setq eldoc-echo-area-use-multiline-p nil) - (add-to-list 'eglot-server-programs '(nix-mode . ("nixd")))) + (envrc-global-mode)) #+end_src -** eglot-booster +** python mode + +Because I have to and not want to. + +#+begin_src emacs-lisp +(use-package python-mode + :ensure t + :mode "\\.py\\'" + :hook ((python-mode python-ts-mode) . lspce-mode)) + +(use-package flymake-pyrefly + :ensure t + :hook (python-base-mode . pyrefly-setup-flymake-backend)) + +(use-package python-black + :ensure t + :demand t + :after python) +#+end_src + +** Rust mode + +ily <3. + +#+begin_src emacs-lisp +(use-package rust-mode + :ensure t + :mode "\\.rs\\'" + :hook (rust-mode . lspce-mode)) +#+end_src + +** Nushell #+begin_src emacs-lisp -(use-package eglot-booster -:straight ( eglot-booster :type git :host nil :repo "https://github.com/jdtsmith/eglot-booster") -:after eglot -:config (eglot-booster-mode)) +(use-package nushell-mode + :ensure t + :mode "\\.nu\\'" + :hook (nushell-mode . lspce-mode)) #+end_src -** consult-eglot integration +* vterm #+begin_src emacs-lisp -(use-package consult-eglot - :straight t - :after (consult eglot)) +(use-package vterm + :ensure t + :defer t) +(setq vterm-shell "nu") #+end_src * olivetti @@ -940,39 +940,37 @@ completion-category-overrides '((file (styles partial-completion))))) ;; Customi * diff-hl #+begin_src emacs-lisp - (use-package diff-hl :defer t :straight t :ensure t :hook (find-file . (lambda () - (global-diff-hl-mode) ;; Enable Diff-HL mode for all files. - (diff-hl-flydiff-mode) ;; Automatically refresh diffs. - (diff-hl-margin-mode))) ;; Show diff indicators in the margin. + (global-diff-hl-mode) ;; Enable Diff-HL mode for all files. + (diff-hl-flydiff-mode) ;; Automatically refresh diffs. + (diff-hl-margin-mode))) ;; Show diff indicators in the margin. :custom (diff-hl-side 'left) ;; Set the side for diff indicators. (diff-hl-margin-symbols-alist '((insert . "┃") ;; Customize symbols for each change type. - (delete . "-") - (change . "┃") - (unknown . "┆") - (ignored . "i")))) + (delete . "-") + (change . "┃") + (unknown . "┆") + (ignored . "i")))) #+end_src * magit #+begin_src emacs-lisp - (use-package magit :ensure t :straight t :config (if ek-use-nerd-fonts ;; Check if nerd fonts are being used - (setopt magit-format-file-function #'magit-format-file-nerd-icons)) ;; Turns on magit nerd-icons + (setopt magit-format-file-function #'magit-format-file-nerd-icons)) ;; Turns on magit nerd-icons :defer t) #+end_src -* indent guide +* indent-guide #+begin_src emacs-lisp (use-package indent-guide @@ -985,7 +983,9 @@ completion-category-overrides '((file (styles partial-completion))))) ;; Customi (setq indent-guide-char "│")) ;; Set the character used for the indent guide. #+end_src -* general +* keybindings + +** general #+begin_src emacs-lisp (use-package general @@ -1006,7 +1006,7 @@ completion-category-overrides '((file (styles partial-completion))))) ;; Customi :prefix ",")) #+end_src -* evil +** evil-mode #+begin_src emacs-lisp (use-package evil @@ -1023,69 +1023,69 @@ completion-category-overrides '((file (styles partial-completion))))) ;; Customi (define-key evil-normal-state-map (kbd "C-r") 'undo-tree-redo)) #+end_src -** smart pairs - - #+begin_src emacs-lisp - (use-package smartparens - :ensure t - :init - (smartparens-global-mode 1) - :config - (require 'smartparens-config)) - (use-package evil-smartparens - :ensure t - :after evil-collection - :hook (smartparens-global-mode . evil-smartparens-mode)) - #+end_src +** smart-parens -** evil packages +#+begin_src emacs-lisp +(use-package smartparens + :ensure t + :init + (smartparens-global-mode 1) + :config + (require 'smartparens-config)) +(use-package evil-smartparens + :ensure t + :after evil-collection + :hook (smartparens-global-mode . evil-smartparens-mode)) +#+end_src - #+begin_src emacs-lisp - (use-package evil-collection - :after evil - :ensure t - :config - (evil-collection-init)) +** evil-collection +#+begin_src emacs-lisp +(use-package evil-collection + :after evil + :ensure t + :config + (evil-collection-init)) +#+end_src - (use-package evil-surround - :ensure t - :straight t - :after evil-collection - :config - (global-evil-surround-mode 1)) +** evil-surround - (use-package evil-matchit - :ensure t - :straight t - :after evil-collection - :config - (global-evil-matchit-mode 1)) - #+end_src +#+begin_src emacs-lisp +(use-package evil-surround + :ensure t + :straight t + :after evil-collection + :config + (global-evil-surround-mode 1)) +#+end_src -** textobject +** evil-matchit - #+begin_src emacs-lisp - (use-package evil-textobj-anyblock - :ensure t - :after evil - :config - (define-key evil-inner-text-objects-map "b" 'evil-textobj-anyblock-inner-block) - (define-key evil-outer-text-objects-map "b" 'evil-textobj-anyblock-a-block) - - ;; (define-key evil-inner-text-objects-map "q" 'evil-textobj-anyblock-inner-quote) - ;; (define-key evil-outer-text-objects-map "q" 'evil-textobj-anyblock-a-quote) - - (setq evil-textobj-anyblock-blocks - '(("(" . ")") - ("{" . "}") - ("\\[" . "\\]") - ("<" . ">")))) - #+end_src +#+begin_src emacs-lisp +(use-package evil-matchit + :ensure t + :straight t + :after evil-collection + :config + (global-evil-matchit-mode 1)) +#+end_src -** add quotes +** evil-textobjects #+begin_src emacs-lisp +(use-package evil-textobj-anyblock + :ensure t + :after evil + :config + (define-key evil-inner-text-objects-map "b" 'evil-textobj-anyblock-inner-block) + (define-key evil-outer-text-objects-map "b" 'evil-textobj-anyblock-a-block) + + (setq evil-textobj-anyblock-blocks + '(("(" . ")") + ("{" . "}") + ("\\[" . "\\]") + ("<" . ">")))) + (evil-define-text-object my-evil-textobj-anyblock-inner-quote (count &optional beg end type) "Select the closest outer quote." @@ -1113,24 +1113,24 @@ completion-category-overrides '((file (styles partial-completion))))) ;; Customi * avy #+begin_src emacs-lisp - (use-package avy - :ensure t - :straight t - :after evil - :general - ;; (general-nmap "s" 'avy-goto-char-timer) - ;; (general-omap "s" 'evil-avy-goto-char-timer) +(use-package avy + :ensure t + :straight t + :after evil + :general + ;; (general-nmap "s" 'avy-goto-char-timer) + ;; (general-omap "s" 'evil-avy-goto-char-timer) - :config - (setq avy-all-windows t - avy-all-windows-alt t - avy-background t - avy-case-fold-search t - avy-timeout-seconds 0.3 - avy-style 'at-full - avy-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)) + :config + (setq avy-all-windows t + avy-all-windows-alt t + avy-background t + avy-case-fold-search t + avy-timeout-seconds 0.3 + avy-style 'at-full + avy-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)) - (evil-define-avy-motion evil-avy-goto-char-timer inclusive)) + (evil-define-avy-motion evil-avy-goto-char-timer inclusive)) #+end_src * undo-tree @@ -1150,203 +1150,164 @@ completion-category-overrides '((file (styles partial-completion))))) ;; Customi undo-strong-limit 12000000 undo-outer-limit 120000000) :config - (setq undo-tree-mode-lighter "")) + (setq undo-tree-mode-lighter "")) #+end_src -* Rainbow Delimiter +* rainbow-delimiters #+begin_src emacs-lisp - (use-package rainbow-delimiters - :defer t - :straight t - :ensure t - :hook - (prog-mode . rainbow-delimiters-mode)) +(use-package rainbow-delimiters + :defer t + :straight t + :ensure t + :hook + (prog-mode . rainbow-delimiters-mode)) #+end_src -* dotenv-mode +* env-modes + +** dotenv #+begin_src emacs-lisp - (use-package dotenv-mode - :defer t - :straight t - :ensure t - :config) +(use-package dotenv-mode + :defer t + :straight t + :ensure t + :config) #+end_src -* envrc +** envrc #+begin_src emacs-lisp (use-package envrc :hook (after-init . envrc-global-mode)) #+end_src -* pulsar +* pulsar #+begin_src emacs-lisp - (use-package pulsar - :defer t - :straight t - :ensure t - :hook - (after-init . pulsar-global-mode) - :config - (setq pulsar-pulse t) - (setq pulsar-delay 0.025) - (setq pulsar-iterations 10) - (setq pulsar-face 'evil-ex-lazy-highlight) +(use-package pulsar + :defer t + :straight t + :ensure t + :hook + (after-init . pulsar-global-mode) + :config + (setq pulsar-pulse t) + (setq pulsar-delay 0.025) + (setq pulsar-iterations 10) + (setq pulsar-face 'evil-ex-lazy-highlight) - (add-to-list 'pulsar-pulse-functions 'evil-scroll-down) - (add-to-list 'pulsar-pulse-functions 'flymake-goto-next-error) - (add-to-list 'pulsar-pulse-functions 'flymake-goto-prev-error) - (add-to-list 'pulsar-pulse-functions 'evil-yank) - (add-to-list 'pulsar-pulse-functions 'evil-yank-line) - (add-to-list 'pulsar-pulse-functions 'evil-delete) - (add-to-list 'pulsar-pulse-functions 'evil-delete-line) - (add-to-list 'pulsar-pulse-functions 'evil-jump-item) - (add-to-list 'pulsar-pulse-functions 'diff-hl-next-hunk) - (add-to-list 'pulsar-pulse-functions 'diff-hl-previous-hunk)) + (add-to-list 'pulsar-pulse-functions 'evil-scroll-down) + (add-to-list 'pulsar-pulse-functions 'flymake-goto-next-error) + (add-to-list 'pulsar-pulse-functions 'flymake-goto-prev-error) + (add-to-list 'pulsar-pulse-functions 'evil-yank) + (add-to-list 'pulsar-pulse-functions 'evil-yank-line) + (add-to-list 'pulsar-pulse-functions 'evil-delete) + (add-to-list 'pulsar-pulse-functions 'evil-delete-line) + (add-to-list 'pulsar-pulse-functions 'evil-jump-item) + (add-to-list 'pulsar-pulse-functions 'diff-hl-next-hunk) + (add-to-list 'pulsar-pulse-functions 'diff-hl-previous-hunk)) #+end_src * evil-org #+begin_src emacs-lisp - (use-package evil-org - :ensure t - :straight t - :after org - :hook (org-mode . (lambda () evil-org-mode)) - :config - (require 'evil-org-agenda) - (evil-org-agenda-set-keys)) +(use-package evil-org + :ensure t + :straight t + :after org + :hook (org-mode . (lambda () evil-org-mode)) + :config + (require 'evil-org-agenda) + (evil-org-agenda-set-keys)) #+end_src -* nerd-icons +* nerd icons #+begin_src emacs-lisp - ;;; NERD ICONS - ;; The `nerd-icons' package provides a set of icons for use in Emacs. These icons can - ;; enhance the visual appearance of various modes and packages, making it easier to - ;; distinguish between different file types and functionalities. - (use-package nerd-icons - :if ek-use-nerd-fonts ;; Load the package only if the user has configured to use nerd fonts. - :ensure t ;; Ensure the package is installed. - :straight t - :defer t) ;; Load the package only when needed to improve startup time. - - ;;; NERD ICONS Dired - ;; The `nerd-icons-dired' package integrates nerd icons into the Dired mode, - ;; providing visual icons for files and directories. This enhances the Dired - ;; interface by making it easier to identify file types at a glance. - (use-package nerd-icons-dired - :if ek-use-nerd-fonts ;; Load the package only if the user has configured to use nerd fonts. - :ensure t ;; Ensure the package is installed. - :straight t - :defer t ;; Load the package only when needed to improve startup time. - :hook - (dired-mode . nerd-icons-dired-mode)) - - (use-package nerd-icons-completion - :if ek-use-nerd-fonts ;; Load the package only if the user has configured to use nerd fonts. - :ensure t ;; Ensure the package is installed. - :straight t - :after (:all nerd-icons marginalia) ;; Load after `nerd-icons' and `marginalia' to ensure proper integration. - :config - (nerd-icons-completion-mode) ;; Activate nerd icons for completion interfaces. - (add-hook 'marginalia-mode-hook #'nerd-icons-completion-marginalia-setup)) ;; Setup icons in the marginalia mode for enhanced completion display. +(use-package nerd-icons + :if ek-use-nerd-fonts ;; Load the package only if the user has configured to use nerd fonts. + :ensure t ;; Ensure the package is installed. + :straight t + :defer t) ;; Load the package only when needed to improve startup time. #+end_src -* catppuccin theme +** nerd icons dired #+begin_src emacs-lisp - ;;; CATPPUCCIN THEME - ;; The `catppuccin-theme' package provides a visually pleasing color theme - ;; for Emacs that is inspired by the popular Catppuccin color palette. - ;; This theme aims to create a comfortable and aesthetic coding environment - ;; with soft colors that are easy on the eyes. - ;; (use-package catppuccin-theme - ;; :ensure t - ;; :straight t - ;; :config - ;; (custom-set-faces - ;; ;; Set the color for changes in the diff highlighting to blue. - ;; `(diff-hl-change ((t (:background unspecified :foreground ,(catppuccin-get-color 'blue)))))) - - ;; (custom-set-faces - ;; ;; Set the color for deletions in the diff highlighting to red. - ;; `(diff-hl-delete ((t (:background unspecified :foreground ,(catppuccin-get-color 'red)))))) - - ;; (custom-set-faces - ;; ;; Set the color for insertions in the diff highlighting to green. - ;; `(diff-hl-insert ((t (:background unspecified :foreground ,(catppuccin-get-color 'green)))))) - - ;; ;; Load the Catppuccin theme without prompting for confirmation. - ;; (load-theme 'catppuccin :no-confirm)) +(use-package nerd-icons-dired + :if ek-use-nerd-fonts ;; Load the package only if the user has configured to use nerd fonts. + :ensure t ;; Ensure the package is installed. + :straight t + :defer t ;; Load the package only when needed to improve startup time. + :hook + (dired-mode . nerd-icons-dired-mode)) #+end_src -#+begin_src emacs-lisp - ;;; UTILITARY FUNCTION TO INSTALL EMACS-KICK - (defun ek/first-install () - "dired" - (interactive) ;; Allow this function to be called interactively. - (switch-to-buffer "*Messages*") ;; Switch to the *Messages* buffer to display installation messages. - (message ">>> All required packages installed.") - (message ">>> Configuring Emacs-Kick...") - (message ">>> Configuring Tree Sitter parsers...") - (require 'treesit-auto) - (treesit-auto-install-all) ;; Install all available Tree Sitter grammars. - (message ">>> Configuring Nerd Fonts...") - (require 'nerd-icons) - (nerd-icons-install-fonts) ;; Install all available nerd-fonts - (message ">>> Emacs-Kick installed! Press any key to close the installer and open Emacs normally. First boot will compile some extra stuff :)") - (read-key) ;; Wait for the user to press any key. - (kill-emacs)) ;; Close Emacs after installation is complete. +** nerd icons bla - ;;; init.el ends here +#+begin_src emacs-lisp +(use-package nerd-icons-completion + :if ek-use-nerd-fonts ;; Load the package only if the user has configured to use nerd fonts. + :ensure t ;; Ensure the package is installed. + :straight t + :after (:all nerd-icons marginalia) ;; Load after `nerd-icons' and `marginalia' to ensure proper integration. + :config + (nerd-icons-completion-mode) ;; Activate nerd icons for completion interfaces. + (add-hook 'marginalia-mode-hook #'nerd-icons-completion-marginalia-setup)) ;; Setup icons in the marginalia mode for enhanced completion display. #+end_src -* configuration/soph - -** soph-modeline - -*** Battery Faces - -Extracted from doom modeline +* TODO efs install fn #+begin_src emacs-lisp - (require 'battery) - (require 'nerd-icons) +(defun ek/first-install () + "dired" + (interactive) ;; Allow this function to be called interactively. + (switch-to-buffer "*Messages*") ;; Switch to the *Messages* buffer to display installation messages. + (message ">>> All required packages installed.") + (message ">>> Configuring Emacs-Kick...") + (message ">>> Configuring Tree Sitter parsers...") + (require 'treesit-auto) + (treesit-auto-install-all) ;; Install all available Tree Sitter grammars. + (message ">>> Configuring Nerd Fonts...") + (require 'nerd-icons) + (nerd-icons-install-fonts) ;; Install all available nerd-fonts + (message ">>> Emacs-Kick installed! Press any key to close the installer and open Emacs normally. First boot will compile some extra stuff :)") + (read-key) ;; Wait for the user to press any key. + (kill-emacs)) ;; Close Emacs after installation is complete. +#+end_src - (defface my-battery-charging - '((t :inherit success)) - "Face for charging battery.") +* headerline - (defface my-battery-full - '((t :inherit success)) - "Face for full battery.") +#+begin_src emacs-lisp +(require 'battery) +(require 'nerd-icons) - (defface my-battery-normal - '((t :inherit mode-line)) - "Face for normal battery.") +(defface my-battery-charging + '((t :inherit success)) + "Face for charging battery.") - (defface my-battery-warning - '((t :inherit warning)) - "Face for low battery.") +(defface my-battery-full + '((t :inherit success)) + "Face for full battery.") - (defface my-battery-critical - '((t :inherit error)) - "Face for critical battery.") +(defface my-battery-normal + '((t :inherit mode-line)) + "Face for normal battery.") - (defface my-battery-error - '((t :inherit error)) - "Face for battery error.") -#+end_src +(defface my-battery-warning + '((t :inherit warning)) + "Face for low battery.") -*** Battery Update Function +(defface my-battery-critical + '((t :inherit error)) + "Face for critical battery.") -Function that updates the battery string with nerd icons. +(defface my-battery-error + '((t :inherit error)) + "Face for battery error.") -#+begin_src emacs-lisp (defvar my-battery-string nil) (defun my-update-battery () @@ -1421,13 +1382,7 @@ Function that updates the battery string with nerd icons. "Battery status not available"))) (concat (propertize icon 'help-echo help-echo) (propertize text 'face face 'help-echo help-echo)))))) -#+end_src - -*** Battery Override -Replaces the default battery display with the custom version. - -#+begin_src emacs-lisp (defun my-override-battery () (when (bound-and-true-p display-battery-mode) (advice-add #'battery-update :after #'my-update-battery) @@ -1435,60 +1390,113 @@ Replaces the default battery display with the custom version. (my-update-battery))) (add-hook 'display-battery-mode-hook #'my-override-battery) -#+end_src -*** Header Line Format - -The Modeline itself with Battery and Time on the right, Line:Column after VC on the left. - -#+begin_src emacs-lisp (display-time-mode 1) (display-battery-mode 1) -(defvar lsp-modeline--code-actions-string nil) +(defun my-lspce-diagnostics-string () + (when (and (bound-and-true-p lspce-mode) + (bound-and-true-p flymake-mode)) + (let* ((diags (flymake-diagnostics)) + (error-count 0) + (warning-count 0) + (note-count 0)) + (dolist (diag diags) + (let ((severity (flymake-diagnostic-type diag))) + (cond + ((eq severity :error) (setq error-count (1+ error-count))) + ((eq severity :warning) (setq warning-count (1+ warning-count))) + ((eq severity :note) (setq note-count (1+ note-count)))))) + (when (or (> error-count 0) (> warning-count 0) (> note-count 0)) + (concat + (when (> error-count 0) + (propertize (format " %d" error-count) + 'face 'error + 'help-echo (format "%d error(s)" error-count))) + (when (> warning-count 0) + (propertize (format " %d" warning-count) + 'face 'warning + 'help-echo (format "%d warning(s)" warning-count))) + (when (> note-count 0) + (propertize (format " %d" note-count) + 'face 'success + 'help-echo (format "%d note(s)" note-count)))))))) (setq-default header-line-format - '("%e" -(:propertize " " display (raise +0.4)) -(:propertize " " display (raise -0.4)) - -(:propertize "λ " face font-lock-comment-face) -mode-line-frame-identification -mode-line-buffer-identification - -(:eval (when-let (vc vc-mode) - (list (propertize " " 'face 'font-lock-comment-face) - (propertize (truncate-string-to-width - (substring vc 5) 50) - 'face 'font-lock-comment-face)))) - -(:propertize " %4l:%c" face mode-line-buffer-id) - -(:eval (propertize - " " 'display - `((space :align-to - (- (+ right right-fringe right-margin) - ,(+ 3 - (string-width (or my-battery-string "")) - (string-width (or display-time-string "")))))))) - - (:eval my-battery-string) -" " -(:eval display-time-string))) + '("%e" + (:propertize " " display (raise +0.4)) + (:propertize " " display (raise -0.4)) + + (:propertize "λ " face font-lock-comment-face) + mode-line-frame-identification + mode-line-buffer-identification + + (:eval (when-let (vc vc-mode) + (list (propertize " " 'face 'font-lock-comment-face) + (propertize (truncate-string-to-width + (substring vc 5) 50) + 'face 'font-lock-comment-face)))) + + (:eval (my-lspce-diagnostics-string)) + + (:propertize " %4l:%c" face mode-line-buffer-id) + + (:eval (propertize + " " 'display + `((space :align-to + (- (+ right right-fringe right-margin) + ,(+ 3 + (string-width (or my-battery-string "")) + (string-width (or display-time-string "")))))))) + + (:eval my-battery-string) + " " + (:eval display-time-string))) (setq-default mode-line-format nil) -#+end_src -** hide modeline +(defun my-lspce-diagnostics-string () + (when (and (bound-and-true-p lspce-mode) + (bound-and-true-p flymake-mode)) + (let* ((diags (flymake-diagnostics)) + (error-count 0) + (warning-count 0) + (note-count 0)) + (dolist (diag diags) + (let ((severity (flymake-diagnostic-type diag))) + (cond + ((eq severity :error) (setq error-count (1+ error-count))) + ((eq severity :warning) (setq warning-count (1+ warning-count))) + ((eq severity :note) (setq note-count (1+ note-count)))))) + (when (or (> error-count 0) (> warning-count 0) (> note-count 0)) + (concat + " " + (when (> error-count 0) + (concat + (nerd-icons-mdicon "nf-md-close_circle" :face 'error) + (propertize (format " %d " error-count) + 'face 'error + 'help-echo (format "%d error(s)" error-count)))) + (when (> warning-count 0) + (concat + (nerd-icons-mdicon "nf-md-alert" :face 'warning) + (propertize (format " %d " warning-count) + 'face 'warning + 'help-echo (format "%d warning(s)" warning-count)))) + (when (> note-count 0) + (concat + (nerd-icons-mdicon "nf-md-information" :face 'success) + (propertize (format " %d" note-count) + 'face 'success + 'help-echo (format "%d note(s)" note-count))))))))) -#+begin_src emacs-lisp - (use-package hide-mode-line - :straight t - :defer t - :bind (:map custom-bindings-map ("C-c h m" . hide-mode-line-mode))) +(use-package hide-mode-line + :straight t + :defer t + :bind (:map custom-bindings-map ("C-c h m" . hide-mode-line-mode))) #+end_src -** adaptive wrap +* soph #+begin_src emacs-lisp (use-package adaptive-wrap @@ -1496,40 +1504,28 @@ mode-line-buffer-identification :hook ((text-mode . adaptive-wrap-prefix-mode)) :config (add-hook 'org-mode-hook - (lambda () - (when (bound-and-true-p adaptive-wrap-prefix-mode) - (adaptive-wrap-prefix-mode -1))))) -#+end_src + (lambda () + (when (bound-and-true-p adaptive-wrap-prefix-mode) + (adaptive-wrap-prefix-mode -1))))) -** gpg home - -#+begin_src emacs-lisp (setq package-gnupghome-dir "~/.gnupg") -#+end_src - -** cursor -#+begin_src emacs-lisp (blink-cursor-mode 0) (setq-default cursor-type 'bar) -#+end_src - -** default fixed, variable fonts -#+begin_src emacs-lisp -(defvar cashmere/font-height 170) +(defvar cashmere/font-height 150) -(when (member "Fragment Mono" (font-family-list)) - (set-face-attribute 'default nil :font "Fragment Mono" :height cashmere/font-height) - (set-face-attribute 'fixed-pitch nil :family "Fragment Mono" :height cashmere/font-height)) +;; (when (member "Fragment Mono" (font-family-list)) +;; (set-face-attribute 'default nil :font "Fragment Mono" :height cashmere/font-height) +;; (set-face-attribute 'fixed-pitch nil :family "Fragment Mono" :height cashmere/font-height)) -(when (member "Maple Mono NF" (font-family-list)) - (set-face-attribute 'variable-pitch nil :family "Maple Mono NF" :height cashmere/font-height)) -#+end_src +;; (when (member "Maple Mono NF" (font-family-list)) +;; (set-face-attribute 'variable-pitch nil :family "Maple Mono NF" :height cashmere/font-height)) -** mixed pitch fonts (package) +(set-face-attribute 'default nil :family "MonoLisa" :weight 'semi-bold :height cashmere/font-height) +(set-face-attribute 'fixed-pitch nil :family "MonoLisa" :weight 'regular) +(set-face-attribute 'variable-pitch nil :family "MonoLisa" :weight 'regular :height 1.1) -#+begin_src emacs-lisp (use-package mixed-pitch :straight t :defer t @@ -1537,35 +1533,31 @@ mode-line-buffer-identification (LaTeX-mode . mixed-pitch-mode))) #+end_src -* autothemer - -#+begin_src emacs-lisp - (use-package autothemer - :straight t - :defer t) -#+end_src -* doom-themes +* theme #+begin_src emacs-lisp -;; (use-package doom-themes -;; :straight t -;; :ensure t -;; :custom -;; ;; Global settings (defaults) -;; (doom-themes-enable-bold t) ; if nil, bold is universally disabled -;; (doom-themes-enable-italic t) ; if nil, italics is universally disabled -;; ;; for treemacs users -;; (doom-themes-treemacs-theme "doom-nord-light") ; use "doom-colors" for less minimal icon theme -;; :config -;; ;; (load-theme 'doom-nord-light t) +(use-package autothemer + :straight t + :defer t) +(use-package doom-themes + :straight t + :ensure t + :custom + ;; Global settings (defaults) + (doom-themes-enable-bold t) ; if nil, bold is universally disabled + (doom-themes-enable-italic t) ; if nil, italics is universally disabled + ;; for treemacs users + (doom-themes-treemacs-theme "doom-nord-light") ; use "doom-colors" for less minimal icon theme + :config + (load-theme 'doom-nord-light t) -;; ;; Enable flashing mode-line on errors -;; (doom-themes-visual-bell-config) -;; ;; Enable custom neotree theme (nerd-icons must be installed!) -;; ;; or for treemacs users -;; (doom-themes-treemacs-config) -;; ;; Corrects (and improves) org-mode's native fontification. -;; (doom-themes-org-config)) + ;; Enable flashing mode-line on errors + (doom-themes-visual-bell-config) + ;; Enable custom neotree theme (nerd-icons must be installed!) + ;; or for treemacs users + (doom-themes-treemacs-config) + ;; Corrects (and improves) org-mode's native fontification. + (doom-themes-org-config)) #+end_src * dirvish @@ -1599,17 +1591,16 @@ mode-line-buffer-identification (setq dired-mouse-drag-files t)) #+end_src -* olivetti global mode +* my/fns -#+begin_src emacs-lisp :tangle yes +#+begin_src emacs-lisp (setq-default olivetti-body-width 100) -(define-globalized-minor-mode my-global-olivetti-mode olivetti-mode +(define-globalized-minor-mode my/global-olivetti-mode olivetti-mode (lambda () (olivetti-mode 1))) (my/centered-cursor) -(my-global-olivetti-mode) #+end_src -* org modern indent +* TODO org-modern-indent #+begin_src emacs-lisp (use-package org-modern-indent @@ -1617,12 +1608,9 @@ mode-line-buffer-identification :hook (org-mode . org-modern-indent-mode)) #+end_src -* declutter - -** ibuffer +* ibuffer hide #+begin_src emacs-lisp - (setq ibuffer-never-show-predicates '(;; System buffers "^\\*Messages\\*$" @@ -1641,23 +1629,6 @@ mode-line-buffer-identification "^\\*ts-ls::stderr\\*$")) #+end_src -* eat - -#+begin_src emacs-lisp -(use-package eat - :ensure t - :defer t - :init - (defun my/eat-reset-key () - (when (boundp 'eat-emacs-mode-map) - (define-key eat-emacs-mode-map (kbd "C-l") #'eat-reset))) - :hook (eat-mode . my/eat-reset-key) - :config - (when (fboundp 'eat-global-mode) - (eat-global-mode) - (setq eat-kill-buffer-on-exit t))) -#+end_src - * projectile #+begin_src emacs-lisp @@ -1673,7 +1644,7 @@ mode-line-buffer-identification projectile-require-project-root nil)) #+end_src -** consult-projectile +** consult projectile #+begin_src emacs-lisp (use-package consult-projectile @@ -1691,44 +1662,67 @@ mode-line-buffer-identification (use-package pass :ensure t :defer t) -#+end_src +#+end_src * zoom - #+begin_src emacs-lisp - (use-package zoom - :ensure t - :defer t) - #+end_src +#+begin_src emacs-lisp +(use-package zoom + :ensure t + :defer t) +#+end_src * pdf-tools - #+begin_src emacs-lisp - (use-package pdf-tools +#+begin_src emacs-lisp +(use-package pdf-tools :ensure t :magic ("%PDF" . pdf-view-mode) :config (pdf-tools-install :no-query) :hook (pdf-view-mode . (lambda () (display-line-numbers-mode -1)))) - #+end_src - +#+end_src + * keybindings - -** global leader #+begin_src emacs-lisp +(defun my/eldoc-box-describe-and-jump () + (interactive) + (eldoc-box-help-at-point) + (let ((eldoc-buffer "*eldoc-box*")) + (when (get-buffer eldoc-buffer) + (switch-to-buffer-other-window eldoc-buffer)))) + + +(defun my/format-buffer () + "Format buffer based on major mode" + (interactive) + (cond + ((eq major-mode 'rust-mode) (rust-format-buffer)) + ((eq major-mode 'nix-mode) (nix-format-buffer)) + ((or (eq major-mode 'python-mode) + (eq major-mode 'python-ts-mode)) (python-black-buffer)) + ((eq major-mode 'c-mode) (c-indent-region (point-min) (point-max))) + (t (message "No formatter for %s" major-mode)))) + (my-leader + "SPC" '((lambda () + (interactive) + (if (projectile-project-p) + (projectile-find-file) + (projectile-switch-project))) + :wk "find file/switch project") "sp" '(consult-ripgrep :wk "search project") - "/" '(consult-line :wk "search buffer") + "/" '(consult-ripgrep :wk "search project") "." '(find-file :wk "find file") "," '(consult-buffer :wk "switch buffer") ":" (lambda () (interactive) (execute-extended-command nil)) -"d" '(:ignore t :wk "denote") -"dd" '(denote-menu-list-notes t :wk "List all notes") -"dg" '(denote-grep t :wk "Search") -"dn" '(denote t :wk "Create a new note") -"dr" '(denote-rename-file t :wk "Rename Note") + "d" '(:ignore t :wk "denote") + "dd" '(denote-menu-list-notes t :wk "List all notes") + "dg" '(denote-grep t :wk "Search") + "dn" '(denote t :wk "Create a new note") + "dr" '(denote-rename-file t :wk "Rename Note") "f" '(:ignore t :wk "files") "fd" '(dired :wk "dired") @@ -1748,9 +1742,7 @@ mode-line-buffer-identification "pp" '(projectile-switch-project :wk "switch project") "pf" '(projectile-find-file :wk "find file") "ps" '(consult-ripgrep :wk "search") - "pb" '(consult-projectile-buffer :wk "buffers") - "pk" '(projectile-kill-buffers :wk "kill buffers") - "pd" '(projectile-dired :wk "root dir") + "pb" '(consult-projectile-buffer :wk "buffers") "pk" '(projectile-kill-buffers :wk "kill buffers") "pd" '(projectile-dired :wk "root dir") "pr" '(projectile-recentf :wk "recent files") "pa" '(projectile-add-known-project :wk "add project") "pc" '(projectile-compile-project :wk "compile") @@ -1758,16 +1750,17 @@ mode-line-buffer-identification "pi" '(projectile-invalidate-cache :wk "invalidate cache") "g" '(:ignore t :wk "git/goto") + "gc" '(magit-clone :wk "clone") "gg" '(magit-status :wk "status") "gl" '(magit-log-current :wk "log") - "gd" '(xref-find-definitions :wk "go to definition") ; sowohl hier als auch unter code - "gs" '(magit-status :wk "status") + "gd" '(xref-find-definitions :wk "go to definition") + "gs" '(magit-file-stage :wk "stage file") "gb" '(vc-annotate :wk "blame") "o" '(:ignore t :wk "open") - "op" '(neotree-toggle :wk "neotree") - "oP" '(dired-jump :wk "dired") - "od" '(dirvish :wk "dirvish") + ;; "op" '(neotree-toggle :wk "neotree") + ;; "oP" '(dired-jump :wk "dired") + ;; "od" '(dirvish :wk "dirvish") "h" '(:ignore t :wk "help") "hm" '(describe-mode :wk "mode") @@ -1775,30 +1768,33 @@ mode-line-buffer-identification "hv" '(describe-variable :wk "variable") "hk" '(describe-key :wk "key") - "w" '(:ignore t :wk "windows") - "wv" '(split-window-right :wk "split right") - "ws" '(split-window-below :wk "split below") - "wd" '(delete-window :wk "delete") - "wo" '(delete-other-windows :wk "delete others") + "w c" '(evil-window-delete :wk "Close window") + "w n" '(evil-window-new :wk "New window") + "w s" '(evil-window-split :wk "Horizontal split window") + "w v" '(evil-window-vsplit :wk "Vertical split window") + ;; Window motions + "w h" '(evil-window-left :wk "Window left") + "w j" '(evil-window-down :wk "Window down") + "w k" '(evil-window-up :wk "Window up") + "w l" '(evil-window-right :wk "Window right") + "w w" '(evil-window-next :wk "Goto next window") + ;; Move Windows + "w H" '(buf-move-left :wk "Buffer move left") + "w J" '(buf-move-down :wk "Buffer move down") + "w K" '(buf-move-up :wk "Buffer move up") + "w L" '(buf-move-right :wk "Buffer move right") "c" '(:ignore t :wk "code") - "ca" '(eglot-code-actions :wk "code actions") - "cd" '(xref-find-definitions :wk "go to definition") ; sowohl hier als auch unter g - "cD" '(xref-find-references :wk "find references") - "cr" '(eglot-rename :wk "lsp rename") - "ch" '(eglot-help-at-point :wk "help at point") - "cf" '(eglot-format :wk "format") - "ci" '(eglot-find-implementation :wk "implementation") - "ct" '(eglot-find-typeDefinition :wk "type definition") - "cs" '(consult-eglot-symbols :wk "workspace symbols") - "cS" '(eglot-shutdown :wk "shutdown lsp") - "cR" '(eglot-reconnect :wk "restart lsp") + "ca" '(lspce-code-actions :wk "code actions") + "cx" '(consult-flymake :wk "code actions") + "cr" '(lspce-rename :wk "lsp rename") + "cf" '(my/format-buffer :wk "format buffer") "m" '(:ignore t :wk "mode") "mp" (list (lambda () (interactive) (shell-command (concat "prettier --write " - (shell-quote-argument (buffer-file-name)))) + (shell-quote-argument (buffer-file-name)))) (revert-buffer t t t)) :wk "format prettier") @@ -1809,27 +1805,159 @@ mode-line-buffer-identification "a" '(embark-act :wk "embark") "u" '(undo-tree-visualize :wk "undo tree") "P" '(consult-yank-from-kill-ring :wk "paste history")) -#+end_src -** evil lookup +(defun my/avy-enabled-p () + (and (not (derived-mode-p 'magit-mode 'dired-mode 'ibuffer-mode)) + (not (eq major-mode 'dirvish-mode)))) + +(general-def '(normal visual) 'override + "s" (lambda () + (interactive) + (when (my/avy-enabled-p) + (let ((avy-all-windows t) + (avy-background t) + (scroll-margin 0) + (maximum-scroll-margin 0)) + (call-interactively 'evil-avy-goto-char-2))))) +#+end_src #+begin_src emacs-lisp -(defun my/evil-eldoc-box-lookup () - "Show documentation using eldoc-box." +(defun my/eldoc-box-describe-and-jump () + (interactive) + (eldoc-box-help-at-point) + (let ((eldoc-buffer "*eldoc-box*")) + (when (get-buffer eldoc-buffer) + (switch-to-buffer-other-window eldoc-buffer)))) + + +(defun my/format-buffer () + "Format buffer based on major mode" (interactive) (cond - ((and (fboundp 'eglot-managed-p) (eglot-managed-p)) - (eldoc-box-help-at-point)) - (t - (call-interactively 'describe-symbol)))) + ((eq major-mode 'rust-mode) (rust-format-buffer)) + ((eq major-mode 'nix-mode) (nix-format-buffer)) + ((or (eq major-mode 'python-mode) + (eq major-mode 'python-ts-mode)) (python-black-buffer)) + ((eq major-mode 'c-mode) (c-indent-region (point-min) (point-max))) + (t (message "No formatter for %s" major-mode)))) -(general-def 'normal 'override - "K" 'my/evil-eldoc-box-lookup) -#+end_src +(my-leader + "SPC" '((lambda () + (interactive) + (if (projectile-project-p) + (projectile-find-file) + (projectile-switch-project))) + :wk "find file/switch project") + "sp" '(consult-ripgrep :wk "search project") + "/" '(consult-ripgrep :wk "search project") + "." '(find-file :wk "find file") + "," '(consult-buffer :wk "switch buffer") + ":" (lambda () (interactive) (execute-extended-command nil)) -** ibuffer + "d" '(:ignore t :wk "denote") + "dd" '(denote-menu-list-notes t :wk "List all notes") + "dg" '(denote-grep t :wk "Search") + "dn" '(denote t :wk "Create a new note") + "dr" '(denote-rename-file t :wk "Rename Note") + + "f" '(:ignore t :wk "files") + "fd" '(dired :wk "dired") + "fD" '(dired-jump :wk "dired jump") + "fr" '(consult-recent-file :wk "recent files") + "ff" '(find-file :wk "find file") + "fs" '(save-buffer :wk "save file") + + "b" '(:ignore t :wk "buffers") + "bb" '(consult-buffer :wk "switch buffer") + "bi" '(ibuffer :wk "ibuffer") + "bd" '(kill-current-buffer :wk "kill buffer") + "bk" '(kill-current-buffer :wk "kill buffer") + "bs" '(save-buffer :wk "save buffer") + + "p" '(:ignore t :wk "project") + "pp" '(projectile-switch-project :wk "switch project") + "pf" '(projectile-find-file :wk "find file") + "ps" '(consult-ripgrep :wk "search") + "pb" '(consult-projectile-buffer :wk "buffers") "pk" '(projectile-kill-buffers :wk "kill buffers") "pd" '(projectile-dired :wk "root dir") + "pr" '(projectile-recentf :wk "recent files") + "pa" '(projectile-add-known-project :wk "add project") + "pc" '(projectile-compile-project :wk "compile") + "pt" '(projectile-test-project :wk "test") + "pi" '(projectile-invalidate-cache :wk "invalidate cache") + + "g" '(:ignore t :wk "git/goto") + "gc" '(magit-clone :wk "clone") + "gg" '(magit-status :wk "status") + "gl" '(magit-log-current :wk "log") + "gd" '(xref-find-definitions :wk "go to definition") + "gs" '(magit-file-stage :wk "stage file") + "gb" '(vc-annotate :wk "blame") + + "o" '(:ignore t :wk "open") + ;; "op" '(neotree-toggle :wk "neotree") + ;; "oP" '(dired-jump :wk "dired") + ;; "od" '(dirvish :wk "dirvish") + + "h" '(:ignore t :wk "help") + "hm" '(describe-mode :wk "mode") + "hf" '(describe-function :wk "function") + "hv" '(describe-variable :wk "variable") + "hk" '(describe-key :wk "key") + + "w c" '(evil-window-delete :wk "Close window") + "w n" '(evil-window-new :wk "New window") + "w s" '(evil-window-split :wk "Horizontal split window") + "w v" '(evil-window-vsplit :wk "Vertical split window") + ;; Window motions + "w h" '(evil-window-left :wk "Window left") + "w j" '(evil-window-down :wk "Window down") + "w k" '(evil-window-up :wk "Window up") + "w l" '(evil-window-right :wk "Window right") + "w w" '(evil-window-next :wk "Goto next window") + ;; Move Windows + "w H" '(buf-move-left :wk "Buffer move left") + "w J" '(buf-move-down :wk "Buffer move down") + "w K" '(buf-move-up :wk "Buffer move up") + "w L" '(buf-move-right :wk "Buffer move right") + + "c" '(:ignore t :wk "code") + "ca" '(lspce-code-actions :wk "code actions") + "cx" '(consult-flymake :wk "code actions") + "cr" '(lspce-rename :wk "lsp rename") + "cf" '(my/format-buffer :wk "format buffer") + + "m" '(:ignore t :wk "mode") + "mp" (list (lambda () + (interactive) + (shell-command (concat "prettier --write " + (shell-quote-argument (buffer-file-name)))) + (revert-buffer t t t)) + :wk "format prettier") + + "q" '(:ignore t :wk "quit") + "qq" '(save-buffers-kill-terminal :wk "quit emacs") + "qr" '(restart-emacs :wk "restart") + + "a" '(embark-act :wk "embark") + "u" '(undo-tree-visualize :wk "undo tree") + "P" '(consult-yank-from-kill-ring :wk "paste history")) + +(defun my/avy-enabled-p () + (and (not (derived-mode-p 'magit-mode 'dired-mode 'ibuffer-mode)) + (not (eq major-mode 'dirvish-mode)))) + +(general-def '(normal visual) 'override + "s" (lambda () + (interactive) + (when (my/avy-enabled-p) + (let ((avy-all-windows t) + (avy-background t) + (scroll-margin 0) + (maximum-scroll-margin 0)) + (call-interactively 'evil-avy-goto-char-2))))) +(general-def 'normal 'override + "K" 'my/eldoc-box-describe-and-jump) -#+begin_src emacs-lisp (defun my/ibuffer-smart () (interactive) (ibuffer) @@ -1845,34 +1973,14 @@ mode-line-buffer-identification (my-leader "bi" 'my/ibuffer-smart) -#+end_src - -*** better display buffer - -#+begin_src -(add-to-list 'display-buffer-alist - '("\\*Ibuffer\\*" - (display-buffer-same-window) - (inhibit-same-window . nil))) -#+end_src - -** local leader (,) -This is my own personal local leader configuration. - -#+begin_src emacs-lisp (my-local-leader "a" '(org-agenda :wk "org agenda") - "t" '(eat :wk "terminal") + "t" '(vterm :wk "terminal") "c" '(my/centered-cursor :wk "center cursor") - "d" '(dirvish :wk "dired")) -#+end_src + "d" '(dirvish :wk "dired") + "z" '(zoom-mode :wk "zoom/golden ratio")) -** normal state - -Here we configure the keymaps for keymaps in normal state. - -#+begin_src emacs-lisp (general-def 'normal 'override "]d" 'flymake-goto-next-error "[d" 'flymake-goto-prev-error @@ -1890,12 +1998,6 @@ Here we configure the keymaps for keymaps in normal state. (line-beginning-position) (line-end-position))))) -;; Global K binding für alle Modi mit eglot -#+end_src - -** visual state - -#+begin_src emacs-lisp (general-def 'visual 'override "gc" (lambda () (interactive) @@ -1903,24 +2005,7 @@ Here we configure the keymaps for keymaps in normal state. (comment-or-uncomment-region (region-beginning) (region-end))))) -#+end_src - -** avy - -#+begin_src emacs-lisp -(general-def '(normal visual) 'override - "s" (lambda () - (interactive) - (let ((avy-all-windows t) - (avy-background t) - (scroll-margin 0) - (maximum-scroll-margin 0)) - (call-interactively 'evil-avy-goto-char-2 )))) -#+end_src - -** dirvish -#+begin_src emacs-lisp (general-def 'normal dirvish-mode-map "?" 'dirvish-dispatch "q" 'dirvish-quit @@ -1950,45 +2035,131 @@ Here we configure the keymaps for keymaps in normal state. "s" 'dirvish-symlink "S" 'dirvish-relative-symlink "h" 'dirvish-hardlink) -#+end_src - -** org-mode - -#+begin_src emacs-lisp (my-local-leader :keymaps 'org-mode-map "h" '(consult-org-heading :wk "search headings") "n" '(my-toggle-org-tree-indirect-buffer :wk "toggle narrow")) -#+end_src - -** eat - - #+begin_src emacs-lisp - (general-def 'normal eat-mode-map - "C-l" 'eat-reset) - #+end_src +(general-def 'normal eat-mode-map + "C-l" 'eat-reset) -** minibuffer - -#+begin_src emacs-lisp (define-key minibuffer-local-map [escape] 'abort-recursive-edit) (define-key minibuffer-local-ns-map [escape] 'abort-recursive-edit) (define-key minibuffer-local-completion-map [escape] 'abort-recursive-edit) (define-key minibuffer-local-must-match-map [escape] 'abort-recursive-edit) (define-key minibuffer-local-isearch-map [escape] 'abort-recursive-edit) + +(defun delete-word (arg) + (interactive "p") + (delete-region (point) (progn (forward-word arg) (point)))) + +(defun backward-delete-word (arg) + (interactive "p") + (delete-word (- arg))) + +(global-set-key (kbd "M-<delete>") 'delete-word) +(global-set-key (kbd "M-<backspace>") 'backward-delete-word) +(global-set-key (kbd "C-<delete>") 'delete-word) +(global-set-key (kbd "C-<backspace>") 'backward-delete-word) +(global-set-key (kbd "C-=") 'text-scale-increase) +(global-set-key (kbd "C--") 'text-scale-decrease) +#+end_src + +* elfeed + +#+begin_src emacs-lisp +(use-package elfeed + :ensure t + :defer t + :custom + (elfeed-db-directory "~/.emacs.d/elfeed") + :config + (setq elfeed-search-filter "@2-weeks-ago +unread" + elfeed-search-title-max-width 110)) + + +(use-package elfeed-org + :ensure t + :after elfeed + :custom + (rmh-elfeed-org-files (list "~/org/rss.org")) + :config + (elfeed-org)) #+end_src -** text scaling +* mu4e - #+begin_src emacs-lisp - (global-set-key (kbd "C-=") 'text-scale-increase) - (global-set-key (kbd "C--") 'text-scale-decrease) - #+end_src - -** provide init +#+begin_src emacs-lisp +(use-package mu4e + :straight nil + :ensure nil + :config + + (setq mu4e-mu-binary (executable-find "mu")) + (setq mu4e-maildir "~/Mails") + (setq mu4e-get-mail-command (concat (executable-find "mbsync") " -a")) + (setq mu4e-update-interval 300) + (setq mu4e-attachment-dir "~/Downloads") + (setq mu4e-change-filenames-when-moving t) + + (setq mu4e-user-mail-address-list + '("cashmeresamurai@autistici.org" + "cashmere@cashmere.rs")) + + (setq mu4e-contexts + `(,(make-mu4e-context + :name "autistici" + :match-func + (lambda (msg) + (when msg + (string-prefix-p "/autistici" (mu4e-message-field msg :maildir)))) + :vars '((user-mail-address . "cashmeresamurai@autistici.org") + (user-full-name . "cashmere") + (mu4e-drafts-folder . "/autistici/Drafts") + (mu4e-sent-folder . "/autistici/Sent") + (mu4e-trash-folder . "/autistici/Trash") + (mu4e-refile-folder . "/autistici/Archive"))) + + ,(make-mu4e-context + :name "cashmere" + :match-func + (lambda (msg) + (when msg + (string-prefix-p "/cashmere/cashmere" (mu4e-message-field msg :maildir)))) + :vars '((user-mail-address . "cashmere@cashmere.rs") + (user-full-name . "cashmere") + (mu4e-drafts-folder . "/cashmere/cashmere/Drafts") + (mu4e-sent-folder . "/cashmere/cashmere/Sent") + (mu4e-trash-folder . "/cashmere/cashmere/Trash") + (mu4e-refile-folder . "/cashmere/cashmere/Archive"))))) + + (setq mu4e-context-policy 'pick-first) + (setq mu4e-compose-context-policy 'ask) + + (setq sendmail-program (executable-find "msmtp")) + (setq send-mail-function 'sendmail-send-it) + (setq message-send-mail-function 'sendmail-send-it) + (setq message-sendmail-envelope-from 'header) + (setq message-kill-buffer-on-exit t) + + (defun mu4e-set-msmtp-account () + (if (message-mail-p) + (save-excursion + (let* ((from (save-restriction + (message-narrow-to-headers) + (message-fetch-field "from"))) + (account + (cond + ((string-match "cashmeresamurai@autistici.org" from) "autistici") + ((string-match "cashmere@cashmere.rs" from) "cashmere/cashmere")))) + (setq message-sendmail-extra-arguments (list '"-a" account)))))) + + (add-hook 'message-send-mail-hook 'mu4e-set-msmtp-account)) +#+end_src - #+begin_src emacs-lisp - (provide 'init) - #+end_src +* provide init + +#+begin_src emacs-lisp +(provide 'init) +#+end_src @@ -23,4 +23,6 @@ (setq straight-use-package-by-default t) -(load (expand-file-name "config.el" user-emacs-directory)) +(straight-use-package 'org) + +(org-babel-load-file (expand-file-name "config.org" user-emacs-directory)) |
