Compare commits

..

9 Commits

2 changed files with 1036 additions and 514 deletions

View File

@ -1,4 +1,57 @@
;; -*- lexical-binding: t; -*-
;; For elpaca
;;; Code:
(setq package-enable-at-startup nil)
;; Package management setup
; Elpaca
(defvar elpaca-installer-version 0.12)
(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory))
(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory))
(defvar elpaca-sources-directory (expand-file-name "sources/" elpaca-directory))
(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git"
:ref nil :depth 1 :inherit ignore
:files (:defaults "elpaca-test.el" (:exclude "extensions"))
:build (:not elpaca-activate)))
(let* ((repo (expand-file-name "elpaca/" elpaca-sources-directory))
(build (expand-file-name "elpaca/" elpaca-builds-directory))
(order (cdr elpaca-order))
(default-directory repo))
(add-to-list 'load-path (if (file-exists-p build) build repo))
(unless (file-exists-p repo)
(make-directory repo t)
(when (<= emacs-major-version 28) (require 'subr-x))
(condition-case-unless-debug err
(if-let* ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*"))
((zerop (apply #'call-process `("git" nil ,buffer t "clone"
,@(when-let* ((depth (plist-get order :depth)))
(list (format "--depth=%d" depth) "--no-single-branch"))
,(plist-get order :repo) ,repo))))
((zerop (call-process "git" nil buffer t "checkout"
(or (plist-get order :ref) "--"))))
(emacs (concat invocation-directory invocation-name))
((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch"
"--eval" "(byte-recompile-directory \".\" 0 'force)")))
((require 'elpaca))
((elpaca-generate-autoloads "elpaca" repo)))
(progn (message "%s" (buffer-string)) (kill-buffer buffer))
(error "%s" (with-current-buffer buffer (buffer-string))))
((error) (warn "%s" err) (delete-directory repo 'recursive))))
(unless (require 'elpaca-autoloads nil t)
(require 'elpaca)
(elpaca-generate-autoloads "elpaca" repo)
(let ((load-source-file-function nil)) (load "./elpaca-autoloads"))))
(add-hook 'after-init-hook #'elpaca-process-queues)
(elpaca `(,@elpaca-order))
(setq elpaca-use-package-by-default t)
(setq use-package-always-ensure nil)
(add-hook 'after-init-hook #'elpaca-process-queues)
;(elpaca `(,@elpaca-order))
; Install use-package support
(elpaca elpaca-use-package
:depth nil
;; Enable use-package :ensure support for Elpaca.
(elpaca-use-package-mode))
(elpaca-wait)

743
init.el
View File

@ -1,10 +1,27 @@
;; -*- lexical-binding: t; -*-
(menu-bar-mode 0)
(tool-bar-mode 0)
(scroll-bar-mode 0)
(column-number-mode 1)
(setq package-native-compile t)
(setq use-package-verbose t)
(setq use-package-compute-statistics t)
;; Word wrapping
(global-visual-line-mode 1)
(setq-default visual-line-fringe-indicators '(left-curly-arrow right-curly-arrow))
;; Minibuffer key chord hints should show up instantly
(setq echo-keystrokes 0.01)
;; Auto delete trailing whitespace - Emacs 31+
(add-hook 'prog-mode-hook #'delete-trailing-whitespace-mode)
(add-hook 'text-mode-hook #'delete-trailing-whitespace-mode)
;; Set custom tab width here
(defvar custom-tab-width 8)
(defvar custom-tab-width 4)
;; Disable bell/messages sound on windows
(when (eq window-system 'w32)
@ -20,6 +37,10 @@
(setq frame-inhibit-implied-resize t)
(setq frame-resize-pixelwise t)
;; Paren matching
(setq show-paren-context-when-offscreen 'overlay)
(show-paren-mode 1)
;; Ensure that tabs are default over spaces
(setq-default tab-width custom-tab-width)
(setq tab-width custom-tab-width)
@ -43,20 +64,33 @@
;; Clipboard config
(setopt select-active-regions nil)
(setopt select-enable-clipboard 't)
(setopt select-enable-primary nil)
(setq select-enable-clipboard t) ; Syncs Emacs 'kill' with system clipboard
(setq select-enable-primary t) ; Syncs with the primary selection (middle-click)
(setq save-interprogram-paste-before-kill t) ; Save existing clipboard to kill ring before overwriting
(setopt interprogram-cut-function #'gui-select-text)
;; Midnight Mode
; Automatically clean up old unused buffers
; Automatically clean up old unused buffers
(midnight-mode 1)
;; Emacs client configuration
;; Font configuration
; Global font
(set-frame-font "MesloLGL Nerd Font 20")
(setq default-frame-alist '((font . "MesloLGL Nerd Font 20")))
(defun client-config ()
(scroll-bar-mode 0))
; Buffer fonts
(defun set-buffer-local-font ()
"Set font for normal buffers."
(face-remap-add-relative 'default :height 260))
(add-hook 'prog-mode-hook #'set-buffer-local-font)
(add-hook 'text-mode-hook #'set-buffer-local-font)
; Emacsclient new frame fonts
(setq default-frame-alist '((font . "MesloLGL Nerd Font 20")))
;; Emacsclient Configuration
(defun client-config ()
"Ran on new emacslient frame creations."
(scroll-bar-mode 0))
(add-hook 'after-make-frame-functions #'(lambda (frame)
(select-frame frame)
(client-config)))
@ -77,60 +111,12 @@
;; Stop weird C-9 keybindings causing conflicts on typo
(define-key global-map [remap digit-argument] "")
;; Package management setup
; Elpaca
;(unload-feature 'tramp t)
(defvar elpaca-installer-version 0.11)
(defvar elpaca-directory (expand-file-name "elpaca/" user-emacs-directory))
(defvar elpaca-builds-directory (expand-file-name "builds/" elpaca-directory))
(defvar elpaca-repos-directory (expand-file-name "repos/" elpaca-directory))
(defvar elpaca-order '(elpaca :repo "https://github.com/progfolio/elpaca.git"
:ref nil :depth 1 :inherit ignore
:files (:defaults "elpaca-test.el" (:exclude "extensions"))
:build (:not elpaca--activate-package)))
(let* ((repo (expand-file-name "elpaca/" elpaca-repos-directory))
(build (expand-file-name "elpaca/" elpaca-builds-directory))
(order (cdr elpaca-order))
(default-directory repo))
(add-to-list 'load-path (if (file-exists-p build) build repo))
(unless (file-exists-p repo)
(make-directory repo t)
(when (<= emacs-major-version 28) (require 'subr-x))
(condition-case-unless-debug err
(if-let* ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*"))
((zerop (apply #'call-process `("git" nil ,buffer t "clone"
,@(when-let* ((depth (plist-get order :depth)))
(list (format "--depth=%d" depth) "--no-single-branch"))
,(plist-get order :repo) ,repo))))
((zerop (call-process "git" nil buffer t "checkout"
(or (plist-get order :ref) "--"))))
(emacs (concat invocation-directory invocation-name))
((zerop (call-process emacs nil buffer nil "-Q" "-L" "." "--batch"
"--eval" "(byte-recompile-directory \".\" 0 'force)")))
((require 'elpaca))
((elpaca-generate-autoloads "elpaca" repo)))
(progn (message "%s" (buffer-string)) (kill-buffer buffer))
(error "%s" (with-current-buffer buffer (buffer-string))))
((error) (warn "%s" err) (delete-directory repo 'recursive))))
(unless (require 'elpaca-autoloads nil t)
(require 'elpaca)
(elpaca-generate-autoloads "elpaca" repo)
(let ((load-source-file-function nil)) (load "./elpaca-autoloads"))))
(add-hook 'after-init-hook #'elpaca-process-queues)
(elpaca `(,@elpaca-order))
; Install use-package support
(elpaca elpaca-use-package
;; Enable use-package :ensure support for Elpaca.
(elpaca-use-package-mode))
(elpaca-wait)
;; Optimisation
; GCMH
;Enforce a sneaky Garbage Collection strategy to minimize GC interference with user activity.
;During normal use a high GC threshold is set.
;When idling GC is triggered and a low threshold is set.
;This greatly improves performance/startup time of emacs.
; GCMH
;Enforce a sneaky Garbage Collection strategy to minimize GC interference with user activity.
;During normal use a high GC threshold is set.
;When idling GC is triggered and a low threshold is set.
;This greatly improves performance/startup time of emacs.
(use-package gcmh
:ensure t
:init
@ -146,7 +132,7 @@
(add-hook 'minibuffer-setup-hook 'gcmh-mode-optimisation-setup-hook)
(add-hook 'minibuffer-exit-hook 'gcmh-mode-optimisation-exit-hook))
; Fontification
; Fontification
(jit-lock-mode 1)
(jit-lock-debug-mode 1)
(setq jit-lock-stealth-time 1.25)
@ -164,7 +150,7 @@
;; TRAMP
;TRAMP edit files over SSH configuration
;TRAMP edit files over SSH configuration
(use-package tramp
:ensure t
:config
@ -183,7 +169,7 @@
(when (eq window-system 'w32)
(setq tramp-default-method "plink")))
; Tramp RPC - Alternate backend promising more speed
; Tramp RPC - Alternate backend promising more speed
(use-package tramp-rpc
:ensure (:host github :repo "ArthurHeymans/emacs-tramp-rpc")
:after tramp
@ -193,19 +179,31 @@
;; Org Mode Config
;Agenda
;For Org-Agenda, you can set a location of your Org Agenda file here. Set Agenda Directory:
; Agenda
(defun org-agenda-toggle-day-view ()
"Toggle between daily and weekly view in org agenda."
(interactive)
(if (eq org-agenda-current-span 'day)
(org-agenda-week-view)
(org-agenda-day-view)))
;For Org-Agenda, you can set a location of your Org Agenda file here. Set Agenda Directory:
(use-package org
:ensure (:wait t)
:demand t
:after evil
:hook
(org-agenda-mode . (lambda() (org-agenda-entry-text-mode 1)))
:bind
(:map org-agenda-mode-map
("C-j" . evil-next-line)
("C-k" . evil-previous-line))
:ensure nil
;:demand t ; Setting org mode to be deferred absolutely breaks everything, with org-agenda-mode-map error. Please switch to eval after load maybe instead.
:config
;Fold settings
;Org Mode historically used overlays to hide text, but newer versions moved toward text properties for better performance in large files. This change occasionally causes "stuck" visibility where sub-headers remain hidden until the parent is fully cycled.
(setq org-fold-core-style 'overlays)
(setq org-startup-folded t)
(setq org-hide-emphasis-markers nil))
(with-eval-after-load 'org
(with-eval-after-load 'evil
; Unbind stubborn org mode bindings
(define-key org-mode-map (kbd "M-h") nil)
(define-key org-mode-map (kbd "M-l") nil)
(evil-define-key* '(normal) org-mode-map (kbd "M-h") nil)
(evil-define-key* '(normal) org-mode-map (kbd "M-l") nil)))
(with-eval-after-load 'org-agenda
(setq org-agenda-files '("~/Nextcloud/Agenda"))
;This is will integrate the Calendar/Diary into Org-Agenda, so you can get access to dates on public holidays etc. Set diary to true:
(setq org-agenda-include-diary t)
@ -218,17 +216,36 @@
(setq org-agenda-skip-scheduled-if-done nil)
(setq agenda-skip-deadline-if-done nil)
(setq org-startup-folded t))
;Autostart in day view
(setq org-agenda-span 'day)
; For Org Pomodoro notification sound
(add-hook 'org-agenda-mode-hook #'(lambda ()
(org-agenda-entry-text-mode 1)))
(define-key org-agenda-mode-map (kbd "C-j") 'evil-next-line)
(define-key org-agenda-mode-map (kbd "C-k") 'evil-previous-line)
(define-key org-agenda-mode-map "d" 'org-agenda-toggle-day-view)
(define-key org-agenda-mode-map "p" 'org-pomodoro))
; For Org Pomodoro notification sound
(use-package sound-wav
:ensure t)
:ensure t
:demand t)
(with-eval-after-load 'sound-wav
(defun sound-alert (alert)
"Play a sound notification and show message ALERT."
(sound-wav-play (expand-file-name (concat user-emacs-directory "elpaca/builds/org-pomodoro/resources/bell.wav")))
(message alert))
; Org timer custom alert
(defun org-timer-sound-alert ()
"Sound notification on org timer finish."
(sound-alert "Timer done!"))
(add-hook 'org-timer-done-hook 'org-timer-sound-alert))
; Org Pomodoro
; Org Pomodoro
(use-package org-pomodoro
:ensure t
:after org
:defer t
:after (org org-agenda sound-wav)
:config
(setq org-pomodoro-manual-break t)
(setq org-pomodoro-keep-killed-pomodoro-time t)
@ -236,16 +253,6 @@
(setq org-pomodoro-ticking-sound-p nil)
(setq org-pomodoro-audio-player "mpv"))
(defun sound-alert (alert)
"Play a sound notification and show message ALERT."
(sound-wav-play (expand-file-name (concat user-emacs-directory "elpaca/builds/org-pomodoro/resources/bell.wav")))
(message alert))
; Org timer custom alert
(defun org-timer-sound-alert ()
"Sound notification on org timer finish."
(sound-alert "Timer done!"))
(add-hook 'org-timer-done-hook 'org-timer-sound-alert)
(use-package alert
:ensure t
:config
@ -262,10 +269,10 @@
(plist-get info :message)))))
(setq alert-default-style 'custom-org-alert-notification))
; System notifications of org agenda items
; System notifications of org agenda items
(use-package org-wild-notifier
:ensure t
:after org
:after org-agenda
:config
;; Notifications fire N minutes before an event
(setq org-wild-notifier-alert-time '(1 10 30))
@ -282,24 +289,24 @@
(setq org-wild-notifier-extra-alert-plist '(:persistent t))
(org-wild-notifier-mode))
; Upcoming agenda items in modeline
; Upcoming agenda items in modeline
(use-package org-upcoming-modeline
:ensure t
:after org ; if you don't want it to start until org has been loaded
:after org-agenda ; if you don't want it to start until org has been loaded
:config
(org-upcoming-modeline-mode))
; Org Mode Journalling
; Org Mode Journalling
(use-package org-journal
:ensure t
:after org
:after org-agenda
:config
(setq org-journal-dir "~/Nextcloud/Journal/")
(setq org-journal-file-type 'daily)
(setq org-journal-file-format "%Y%m%d.org"))
;; Org Latex Preview Scale
; Automatically toggle Org mode LaTeX fragment previews as the cursor enters and exits them
; Automatically toggle Org mode LaTeX fragment previews as the cursor enters and exits them
(use-package org-fragtog
:ensure t
:after org
@ -334,6 +341,9 @@
:ensure t
:config
;; Global settings (defaults)
(setcdr (assoc 'gnus-group-news-low-empty doom-themes-base-faces)
'(:inherit 'gnus-group-mail-1-empty :weight 'normal))
(setq
doom-themes-enable-bold t ; if nil, bold is universally disabled
doom-themes-enable-italic t) ; if nil, italics is universally disabled
@ -342,9 +352,9 @@
;; Autocompletion configuration
;(use-package ido-vertical-mode
; :ensure t
; :config (ido-vertical-mode 1))
;(use-package ido-vertical-mode
; :ensure t
; :config (ido-vertical-mode 1))
;; Enable Vertico.
(use-package vertico
@ -365,7 +375,7 @@
(use-package orderless
:ensure t
:custom
(completion-styles '(orderless basic))
(completion-styles '(orderless flex basic))
(completion-category-overrides '((file (styles partial-completion))))
(completion-pcm-leading-wildcard t)) ;; Emacs 31: partial-completion behaves like substring
@ -403,31 +413,49 @@
auto nil
corfu-preselect 'first))
;;(global-corfu-mode)
;;(global-corfu-mode)
;; Evil Config
; Vim Bindings
; Vim Bindings
(use-package evil
:ensure t
:bind (("<escape>" . keyboard-escape-quit))
:bind
(("<escape>" . keyboard-escape-quit)
:map evil-normal-state-map
("U" . undo-redo)
:map evil-insert-state-map
("C-g" . evil-force-normal-state)
:map evil-motion-state-map
([remap evil-search-forward] . 'consult-line))
:init
(setq evil-want-keybinding nil)
(evil-mode 1)
:config
(define-key evil-insert-state-map (kbd "C-g") 'evil-force-normal-state)
(define-key evil-motion-state-map [remap evil-search-forward] 'consult-line))
(evil-mode 1))
; Evil Collection, configs evil bindings for more packages
; Evil Collection, configs evil bindings for more packages
(use-package evil-collection
:after evil
:ensure t
:config
(setq evil-collection-setup-minibuffer t)
(evil-collection-init))
;; Proced config
(with-eval-after-load 'proced
(define-key proced-mode-map [remap proced-undo] 'proced-update))
;; Eshell config
; Like zoxide
(with-eval-after-load 'eshell-mode
(with-eval-after-load 'evil
; Unbind stubborn eshell bindings
(define-key eshell-mode-map (kbd "M-o") nil)
(define-key eshell-mode-map (kbd "M-p") nil)
(evil-define-key* '(normal) eshell-mode-map (kbd "M-o") nil)
(evil-define-key* '(normal) eshell-mode-map (kbd "M-p") nil)
(evil-define-key* '(normal) eshell-mode-map (kbd "M-h") nil)
(evil-define-key* '(normal) eshell-mode-map (kbd "M-l") nil)))
; Like zoxide
(use-package eshell-z
:ensure t
:after tramp
@ -436,7 +464,7 @@
(defun my-eshell-mode-hook ()
(require 'eshell-z))))
; Bash completion commands in eshell
; Bash completion commands in eshell
(use-package bash-completion
:ensure t
:init
@ -450,7 +478,7 @@
(add-hook 'completion-at-point-functions
'bash-completion-capf-nonexclusive nil t))))
; Import bash aliases to eshell
; Import bash aliases to eshell
(defun eshell-load-bash-aliases ()
"Read Bash aliases and add them to the list of eshell aliases."
;; Bash needs to be run - temporarily - interactively
@ -469,7 +497,7 @@
;; rather than every time `eshell-mode' is enabled.
(add-hook 'eshell-first-time-mode-hook 'eshell-load-bash-aliases t)
; Eat is a terminal emulator that can integrate nicely with eshell, allows us to run full ncurses applications inside eshell.
; Eat is a terminal emulator that can integrate nicely with eshell, allows us to run full ncurses applications inside eshell.
(use-package eat
:ensure t
:init
@ -479,7 +507,7 @@
;; For `eat-eshell-visual-command-mode'.
(add-hook 'eshell-load-hook #'eat-eshell-visual-command-mode))
; New create new eshell instance
; New create new eshell instance
(defun eshell/new ()
(interactive)
(eshell t))
@ -506,11 +534,13 @@
(auth-source-pass-enable))
;; Mu4e Mail Config
(if (executable-find "mu")
(when (executable-find "mu")
(use-package mu4e
:ensure nil
:after auth-source-pass
:after (auth-source-pass consult)
:config
(define-key global-map [remap mu4e-search-narrow] 'consult-line)
(setq mu4e-mu-binary (executable-find "mu"))
;; This is set to 't' to avoid mail syncing issues when using mbsync
@ -657,24 +687,180 @@
; ("/Gmail/[Gmail]/Drafts" . ?d)
; ("/Gmail/[Gmail]/All Mail" . ?a)))
; Elfeed RSS Reader
(use-package elfeed
:ensure t
:config
(define-key global-map [remap elfeed-search-untag-all-unread] 'elfeed-update)
(setq elfeed-feeds
'(("https://www.reddit.com/r/Clamworks.rss" reddit clamworks)
("https://www.reddit.com/r/Losercity.rss" reddit losercity)
("https://www.reddit.com/r/Shark_Park.rss" reddit sharkpark)
("https://www.reddit.com/r/emacs.rss" reddit emacs))))
(use-package elfeed-goodies
:ensure t
:after elfeed
:config
(elfeed-goodies/setup)
(setq elfeed-goodies/entry-pane-position 'bottom)
(setq elfeed-goodies/entry-pane-size 0.6))
;; empv - YouTube search frontend, media library manager
(use-package empv
:ensure t
:config
(add-to-list 'empv-mpv-args "--ytdl-format=bestvideo+bestaudio/best[ext=mp4]/best")
(setq empv-youtube-use-tabulated-results t)
(setq empv-invidious-instance 'ivjs)
(define-key empv-youtube-results-mode-map (kbd "<return>") 'empv-play-media-at-point))
;; EMMS - Emacs Music Player
(use-package emms
:ensure t
:after (evil evil-collection)
:bind*
(([remap emms-isearch-buffer] . consult-line)
:map emms-browser-mode-map
("g g" . evil-goto-first-line)
("G" . evil-goto-line)
("w" . evil-forward-word-begin)
("b" . evil-backward-word-begin)
("h" . evil-backward-char)
("j" . evil-next-line)
("k" . evil-previous-line)
("l" . evil-forward-char)
("x" . emms-pause))
:config
(setq emms-source-file-default-directory (expand-file-name "~/Spool2_Secret/Music/Flac"))
(setq emms-player-mpd-server-name "localhost")
(setq emms-player-mpd-server-port "6600")
(setq emms-player-mpd-music-directory "~/Spool2_Secret/Music/Flac")
(setq emms-source-file-directory-tree-function 'emms-source-file-directory-tree-find)
(setq emms-cache-set-all-from-mpd t)
(emms-all)
(emms-player-mpd-connect)
(add-hook 'emms-playlist-cleared-hook 'emms-player-mpd-clear)
(setq emms-player-list '(emms-player-mpd))
(setq emms-player-mpd-supported-regexp ".")
(add-to-list 'emms-info-functions 'emms-info-mpd)
(define-key emms-playlist-mode-map (kbd "d") nil)
(evil-define-key* '(normal) emms-playlist-mode-map (kbd "d") nil)
(evil-define-key* '(normal) emms-playlist-mode-map (kbd "d d") #'emms-playlist-mode-kill-track)
(evil-define-key* '(visual) emms-playlist-mode-map (kbd "d") #'emms-playlist-mode-kill)
(evil-define-key* '(normal) emms-playlist-mode-map (kbd "q") #'emms-browser-bury-buffer))
;; Embr.el Emacs web browser
;(use-package embr
; :defer t
; :after evil
; :ensure (:host github
; :repo "emacs-os/embr.el"
; :files ("*.el" "*.py" "*.sh" "native/*.c" "native/Makefile"))
; :hook (embr-mode . embr-vimium-mode)
; (evil-mode . (lambda () (turn-off-evil-mode)))
; :config
; (setq embr-hover-rate 30
; embr-default-width 1919
; embr-default-height 950
; embr-screen-width 1920
; embr-screen-height 1080
; embr-color-scheme 'dark
; embr-search-engine 'google
; embr-scroll-method 'instant
; embr-scroll-step 100
; embr-frame-source 'screencast
; embr-render-backend 'canvas
; embr-display-method 'headless
; embr-home-url "about:blank"
; embr-session-restore t
; embr-tab-bar t
; embr-proxy-rules nil))
;(with-eval-after-load 'embr
; (defun embr--start-daemon-overridden ()
; "Start the Python daemon process OVERRIDDEN for NixOS support.
; Respects `embr-display-method' for display modes."
; (when (and embr--process (process-live-p embr--process))
; (delete-process embr--process))
; (setq embr--response-buffer "")
; (let* ((inner (list embr-python embr-script))
; (xvfb (and (eq embr-display-method 'headed-offscreen)
; (executable-find "xvfb-run")))
; (command
; (if xvfb
; (append (list xvfb "--auto-servernum"
; "--server-args=-screen 0 1920x1080x24")
; inner)
; (when (and (eq embr-display-method 'headed-offscreen)
; (not (executable-find "xvfb-run")))
; (message "embr: xvfb-run not found, falling back to headless"))
; inner))
; (process-environment
; (append (list "LD_LIBRARY_PATH=/run/current-system/sw/share/nix-ld/lib"
; (format "EMBR_DISPLAY=%s"
; (if xvfb "headed-offscreen"
; (symbol-name embr-display-method))))
; process-environment)))
; (setq embr--process
; (make-process
; :name "embr"
; :command command
; :connection-type 'pipe
; :noquery t
; :stderr (get-buffer-create "*embr-stderr*")
; :filter #'embr--process-filter
; :sentinel #'embr--process-sentinel))
; (process-put embr--process 'embr-buffer (current-buffer))))
; (advice-add 'embr--start-daemon :override #'embr--start-daemon-overridden))
;; Emacs everywhere - Use emacs for any text input
(use-package emacs-everywhere
:ensure t)
;; Parinfer mode - We will use conventional 2 spaces instead of tabs for lisp
(use-package parinfer-rust-mode
:ensure (:host github :repo "justinbarclay/parinfer-rust-mode")
:hook
((emacs-lisp-mode . (lambda()
(setq-local tab-width 2)
; Causing issues so will switch
;(use-package parinfer-rust-mode
; :ensure (:host github :repo "justinbarclay/parinfer-rust-mode")
; :hook
; ((emacs-lisp-mode . (lambda()
; (setq-local tab-width 2)
; (indent-tabs-mode -1)
; (parinfer-rust-mode)))
; (common-lisp-mode . (lambda()
; (setq-local tab-width 2)
; (indent-tabs-mode -1)
; (parinfer-rust-mode)))))
;; Evil cleverparens - We will use conventional 2 spaces instead of tabs for lisp
;(use-package evil-cleverparens
; :ensure t
; :bind
; (:map evil-cleverparens-mode-map
; ("M-d" . nil))
; :hook
; ((emacs-lisp-mode . (lambda ()
; (setq-local tab-width 2)
; (indent-tabs-mode -1)
; (electric-indent-mode 1)
; (evil-cleverparens-mode)))
; (common-lisp-mode . (lambda ()
; (setq-local tab-width 2)
; (indent-tabs-mode -1)
; (electric-indent-mode 1)))))
;; Use puni-mode globally and disable it for term-mode.
(defun emacs-lisp-config-init ()
"My personal initial configuration for Emacs Lisp buffers."
(setq-local tab-width 4)
(setq-local lisp-indent-offset 4)
(setq-local lisp-body-indent 4)
(indent-tabs-mode -1)
(parinfer-rust-mode)))
(common-lisp-mode . (lambda()
(setq-local tab-width 2)
(indent-tabs-mode -1)
(parinfer-rust-mode)))))
(electric-indent-mode 1))
(add-hook 'emacs-lisp-mode-hook #'emacs-lisp-config-init)
;; Rainbow delimiters
(use-package rainbow-delimiters
@ -707,6 +893,8 @@
(tsx . ("https://github.com/tree-sitter/tree-sitter-typescript" "master" "tsx/src"))
(ruby . ("https://github.com/tree-sitter/tree-sitter-ruby"))
(rust . ("https://github.com/tree-sitter/tree-sitter-rust"))
(swift . ("https://github.com/tree-sitter/swift-tree-sitter"))
(nix . ("https://github.com/nix-community/tree-sitter-nix"))
(sql . ("https://github.com/m-novikov/tree-sitter-sql"))
(toml . ("https://github.com/tree-sitter/tree-sitter-toml"))
(zig . ("https://github.com/GrayJack/tree-sitter-zig"))))
@ -722,7 +910,7 @@
(sit-for 0.75)))))
(setq treesit-font-lock-level 4)
; Remap basic modes to treesit equivalent
; Remap basic modes to treesit equivalent
(use-package bash-ts-mode
:ensure nil
:mode "\\.sh\\'")
@ -736,7 +924,7 @@
:ensure t
:mode "\\.swift\\'")
(use-package nix-ts-mode
:ensure nil
:ensure t
:mode "\\.nix\\'")
(use-package html-ts-mode
:ensure nil
@ -753,15 +941,16 @@
(use-package tsx-ts-mode
:ensure nil
:mode "\\.tsx\\'")
;(use-package emacs-lisp-ts-mode
; :ensure t)
; Remap base modes to their treesitter counterpart
;(use-package emacs-lisp-ts-mode
; :ensure t)
; Remap base modes to their treesitter counterpart
(setq major-mode-remap-alist
'(
;(emacs-lisp-mode . emacs-lisp-ts-mode)
(c-mode . c-ts-mode)
(rust-mode . rust-ts-mode)
(nix-mode . nix-ts-mode)
(rustic-mode . rust-ts-mode)
(python-mode . python-ts-mode)
(html-mode . html-ts-mode)
@ -772,7 +961,7 @@
;; Programming treesit style config
; Enforcing tabs as programming style
; Enforcing tabs as programming style
(add-hook 'prog-mode-hook
(lambda ()
(setq-local tab-width custom-tab-width)
@ -796,7 +985,7 @@
(prog-mode . flymake-mode)
(emacs-lisp-mode . flymake-mode))
; Flyover for nice in buffer flymake error/warning messages.
; Flyover for nice in buffer flymake error/warning messages.
(use-package flyover
:ensure t
:hook
@ -814,6 +1003,7 @@
;; LSP Configuration
(use-package eglot
:ensure nil
:hook
(((
bash-ts-mode
@ -853,6 +1043,277 @@
:config
(setq prettier-js-use-modules-bin t))
;; Emacs desktop environment
; Emacs Wayland Manager (EWM)
(when (and (executable-find "ewm-launch") (string= (getenv "XDG_SESSION_DESKTOP") "ewm"))
; Dynamic Tab (Workspace) Setup
(use-package tab-line
:ensure nil)
(tab-bar-mode)
(setq tab-bar-show 1) ; Hide the bar if only 1 tab exists
(setq tab-bar-new-tab-choice "*scratch*")
(defun dynamic-tab-ensure-scratch-tab (&rest _)
"Ensure dynamic scratch tab available if there are active buffers."
(let* ((tabs (funcall tab-bar-tabs-function))
(tab-names (mapcar (lambda (tab) (alist-get 'name tab)) tabs))
(spare-exists (car (member "dynamic *scratch*" tab-names)))
(is-child-buffer (frame-parent))
(is-mini-buffer (minibufferp))
(is-dynamic-tab-focused (string= (alist-get 'name (tab-bar--current-tab)) "dynamic *scratch*"))
(is-scratch-buffer-focused (string= (buffer-name) "*scratch*"))
(is-new-tab-needed
(cond
(is-child-buffer nil)
(is-mini-buffer nil)
((not spare-exists) t)
((and is-dynamic-tab-focused (not is-scratch-buffer-focused)) t)
((and (not is-dynamic-tab-focused) is-scratch-buffer-focused) (tab-close))
(t nil))))
(when is-new-tab-needed
(tab-bar-rename-tab "")
(let ((current-tab (tab-bar--current-tab-index)))
(tab-bar-new-tab 999)
(tab-bar-rename-tab "dynamic *scratch*")
;; Return to original tab if we were just initializing
(tab-bar-select-tab (1+ current-tab))))))
(defvar dynamic-tab-is-already-redirecting-p nil
"Whether we are already redirecting to scratch tab or not.")
(defun dynamic-tab-redirect-to-scratch-tab ()
"Redirect to dedicated scratch tab if scratch buffer accessed on other tab."
(when (and (not dynamic-tab-is-already-redirecting-p)
(string= (buffer-name) "*scratch*")
(string= (buffer-name) "dynamic *scratch*"))
(setq dynamic-tab-is-already-redirecting-p t)
(unwind-protect
(switch-to-buffer nil)
(tab-bar-select-tab-by-name "dynamic *scratch*")
(setq dynamic-tab-is-already-redirecting-p nil))))
(defvar dynamic-tab-soft-kill-p nil
"When t, do not kill buffers only send them to background unless one tab open.")
(defun dynamic-tab-handle-buffer-check-and-close-tab ()
"Check if we need to close the tab and action accordingly."
(let* ((is-last-tab (<= (length (tab-bar-tabs)) 2))
(is-last-buffer (<= (length (tab-line-tabs-window-buffers)) 1)))
(when (and (not is-last-tab) is-last-buffer)
(tab-close))))
(defun dynamic-tab-handle-tab-cleanup-kill ()
"Check if we can kill buffer and free tab if no more reserved buffers in tab."
(let* ((is-last-tab (<= (length (tab-bar-tabs)) 2))
(is-last-buffer (<= (length (tab-line-tabs-window-buffers)) 2))
(is-marked-to-kill (cond
;((and is-last-tab is-last-buffer) t)
;((and is-last-tab (not is-last-buffer)) t)
;((and is-last-tab (not is-last-buffer) (bury-buffer)))
((and (not is-last-tab) (not is-last-buffer) dynamic-tab-soft-kill-p) (bury-buffer))
(t t))))
(dynamic-tab-handle-buffer-check-and-close-tab)
is-marked-to-kill))
(defun dynamic-tab-block-buffer-kill ()
"Block buffer from being killed."
(message "You cannot kill the dynamic buffer")
nil)
(defun dynamic-tab-mark-buffer-unkillable ()
"Mark buffer as unkillable."
(add-hook 'kill-buffer-query-functions #'dynamic-tab-block-buffer-kill nil t))
(defun dynamic-tab-mark-buffer-reserved ()
"Mark buffer as reserved."
(add-hook 'kill-buffer-query-functions #'dynamic-tab-handle-tab-cleanup-kill nil t))
(defun dynamic-tab-unmark-buffer-reserved ()
"Unmark buffer as reserved."
(remove-hook 'kill-buffer-query-functions #'dynamic-tab-handle-tab-cleanup-kill t))
(defun dynamic-tab-refresh-listeners ()
"Refresh hooks to listen on reserved buffers."
(dolist (buf (tab-line-tabs-window-buffers))
(with-current-buffer buf
(let* ((is-child-buffer (frame-parent))
(is-mini-buffer (minibufferp))
(is-dynamic-buffer (string= (buffer-name) "dynamic *scratch*"))
(is-scratch-buffer (string= (buffer-name) "*scratch*")))
(cond
(is-child-buffer nil)
(is-mini-buffer nil)
(is-dynamic-buffer (dynamic-tab-mark-buffer-unkillable))
(is-scratch-buffer (dynamic-tab-mark-buffer-unkillable))
(t (dynamic-tab-mark-buffer-reserved)))))))
(defun dynamic-tab-remove-listeners ()
"Remove all hooks on reserved buffers."
(dolist (buf (buffer-list))
(with-current-buffer buf
(dynamic-tab-unmark-buffer-reserved))))
(defvar dynamic-tab-last-buffer nil)
(defun dynamic-tab-handle-buffer-switch (&rest _)
"Checks to run when buffer is switched."
(unless (eq (current-buffer) dynamic-tab-last-buffer)
(setq dynamic-tab-last-buffer (current-buffer))
;; Put your "on switch" logic here
(dynamic-tab-ensure-scratch-tab)
(dynamic-tab-redirect-to-scratch-tab)))
(defun dynamic-tab-handle-buffer-create (&rest _)
"Checks to run when buffer is created."
(dynamic-tab-ensure-scratch-tab)
(dynamic-tab-refresh-listeners))
(defun dynamic-tab-init ()
"Initialise dynamic tabs."
(add-hook 'window-buffer-change-functions #'dynamic-tab-handle-buffer-switch)
(add-hook 'after-change-major-mode-hook #'dynamic-tab-handle-buffer-create))
;; Helper functions for EWM
; Switch monitor
(defun ewm-switch-to-monitor (target)
"Switch focus to target monitor."
(interactive)
(select-frame-set-input-focus (car (last (seq-filter (lambda (f)
(string= target
(cdr (assq 'name (frame-monitor-attributes f)))))
(frame-list))))))
; Autostart
(defun ewm-autostart-application (target &optional args)
"Autostart application if not already started."
(unless (zerop (shell-command (concat "pidof " target)))
(start-process-shell-command (concat target "-autostart") nil (concat target " " args))))
; EWM - Emacs Wayland Manager
(use-package ewm
:ensure nil
:after evil
:custom
(ewm-output-config
'(("DP-1"
:width 1920
:height 1080
:scale 1.0
:x 0
:y 0
:refresh 240)
("HDMI-A-1"
:width 1920
:height 1080
:scale 1.0
:x 1920
:y 0
:transform 3
:refresh 75)))
(ewm-input-config
'((touchpad :natural-scroll t :tap t :dwt t)
(mouse :accel-profile "flat")
(keyboard :repeat-delay 150 :repeat-rate 35
:xkb-layouts "gb")))
;; Per-device override (exact name from libinput)
;("ELAN0676:00 04F3:3195 Touchpad" :tap nil :accel-speed -0.2)))
; Main bindings
:bind*
(:map ewm-mode-map
("M-d" . ewm-launch-app)
("s-l" . ewm-lock-session)
("M-<return>" . eshell)
("<print>" . (lambda ()
(interactive)
(start-process-shell-command
"screenshot-process"
nil
"grim -g \"$(slurp)\" - | wl-copy")))
("M-w" . (lambda ()
(interactive)
(setq dynamic-tab-soft-kill-p t)
(kill-buffer)
(setq dynamic-tab-soft-kill-p nil)))
("C-x k" . (lambda ()
(interactive)
(setq dynamic-tab-soft-kill-p nil)
(call-interactively 'kill-buffer)))
; Monitor switching, find current focused monitor name via
;(cdr (assq 'name (frame-monitor-attributes))
("M-o" . (lambda ()
(interactive)
(ewm-switch-to-monitor "XG2431")))
("M-p" . (lambda ()
(interactive)
(ewm-switch-to-monitor "24B2W1G5")))
;;("M-f" . (lambda ()
;; (interactive)
;; (start-process-shell-command
;; "wlkbptr-process"
;; nil
;; "wl-kbptr -o modes=floating,click -o mode_floating.source=detect"))
("M-h" . tab-bar-switch-to-prev-tab)
("M-l" . tab-bar-switch-to-next-tab)
("M-k" . windmove-up)
("M-j" . windmove-down))
:config
(add-to-list 'ewm-intercept-prefixes '("<Print>" :fullscreen))
(add-to-list 'ewm-intercept-prefixes ?\M-d)
(add-to-list 'ewm-intercept-prefixes ?\M-w)
(add-to-list 'ewm-intercept-prefixes ?\M-o)
(add-to-list 'ewm-intercept-prefixes ?\M-p)
(add-to-list 'ewm-intercept-prefixes ?\M-h)
(add-to-list 'ewm-intercept-prefixes ?\M-j)
(add-to-list 'ewm-intercept-prefixes ?\M-k)
(add-to-list 'ewm-intercept-prefixes ?\M-l)
(ewm--send-intercept-keys)
:init
;; Dynamic Tabs
(dynamic-tab-init)
;; Autostart
(ewm-autostart-application "qpwgraph")
(ewm-autostart-application "kdeconnect-indicator")
(ewm-autostart-application "udiskie")
(ewm-autostart-application "nextcloud")
(ewm-autostart-application "wlsunset" "-l 51.5 -L 0.1"))
; Desktop notifications in Emacs
(use-package posframe
:ensure t)
(use-package ednc
:ensure t
:after posframe
:init
(defun simple-notification-popup (old-notification new-notification)
(unless (eq old-notification new-notification)
(posframe-show
" *simple-notification-popup-alert*"
:string (concat
(ednc-notification-summary new-notification)
"\n"
(ednc-notification-body new-notification))
:position (point)
:poshandler #'posframe-poshandler-frame-top-right-corner
:background-color "gold"
:foreground-color "black"
:timeout 5)))
(add-hook 'ednc-notification-presentation-functions
#'simple-notification-popup)
(ednc-mode))
;(use-package ednc-popup
; :ensure (:host git :repo "https://codeberg.org/akib/emacs-ednc-popup.git")
; :after ednc
; :config
; (add-hook 'ednc-notification-presentation-functions
; #'ednc-popup-presentation-function))
(use-package kdeconnect
:ensure t
:config
(setq kdeconnect-devices '(("My Phone" . "378230a2e3c24b9a9904e7ffb0dfeb07")))
(setq kdeconnect-active-device '("My Phone" . "378230a2e3c24b9a9904e7ffb0dfeb07"))))
(custom-set-variables
;; custom-set-variables was added by Custom.
@ -860,12 +1321,20 @@
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(auth-source-save-behavior nil)
'(package-selected-packages nil)
'(elfeed-feeds
'(#("Not found!" 0 10 (face error))
("https://www.reddit.com/r/Clamworks.rss" reddit clamworks)
("https://www.reddit.com/r/Losercity.rss" reddit losercity)
("https://www.reddit.com/r/Shark_Park.rss" reddit sharkpark)
("https://www.reddit.com/r/emacs.rss" reddit emacs)))
'(package-selected-packages
'(bash-completion consult corfu eat evil gcmh magit mu4e orderless
org-journal paredit rainbow-delimiters vertico))
'(smtpmail-smtp-server "smtp.cspark.dev")
'(smtpmail-smtp-service 25))
(custom-set-faces)
(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.
)