mirror of
https://gitlab.com/dwt1/dotfiles.git
synced 2026-04-24 12:00:24 +10:00
Restructuring the Emacs config so its not such a massive beast.
This commit is contained in:
@@ -1,64 +1,74 @@
|
||||
(defvar elpaca-installer-version 0.4)
|
||||
(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
|
||||
:files (:defaults (: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 (call-process "git" nil buffer t "clone"
|
||||
(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)))
|
||||
(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)
|
||||
(load "./elpaca-autoloads")))
|
||||
(add-hook 'after-init-hook #'elpaca-process-queues)
|
||||
(elpaca `(,@elpaca-order))
|
||||
(add-to-list 'load-path "~/.config/emacs/scripts/")
|
||||
|
||||
;; Install use-package support
|
||||
(elpaca elpaca-use-package
|
||||
;; Enable :elpaca use-package keyword.
|
||||
(elpaca-use-package-mode)
|
||||
;; Assume :elpaca t unless otherwise specified.
|
||||
(setq elpaca-use-package-by-default t))
|
||||
(require 'elpaca-setup) ;; The Elpaca Package Manager
|
||||
(require 'buffer-move) ;; Buffer-move for better window management
|
||||
(require 'app-launchers) ;; Use emacs as a run launcher like dmenu (experimental)
|
||||
|
||||
;; Block until current queue processed.
|
||||
(elpaca-wait)
|
||||
(use-package all-the-icons
|
||||
:ensure t
|
||||
:if (display-graphic-p))
|
||||
|
||||
;;When installing a package which modifies a form used at the top-level
|
||||
;;(e.g. a package which adds a use-package key word),
|
||||
;;use `elpaca-wait' to block until that package has been installed/configured.
|
||||
;;For example:
|
||||
;;(use-package general :demand t)
|
||||
;;(elpaca-wait)
|
||||
(use-package all-the-icons-dired
|
||||
:hook (dired-mode . (lambda () (all-the-icons-dired-mode t))))
|
||||
|
||||
;;Turns off elpaca-use-package-mode current declartion
|
||||
;;Note this will cause the declaration to be interpreted immediately (not deferred).
|
||||
;;Useful for configuring built-in emacs features.
|
||||
;;(use-package emacs :elpaca nil :config (setq ring-bell-function #'ignore))
|
||||
(setq backup-directory-alist '((".*" . "~/.Trash")))
|
||||
|
||||
;; Don't install anything. Defer execution of BODY
|
||||
;;(elpaca nil (message "deferred"))
|
||||
(use-package company
|
||||
:defer 2
|
||||
:diminish
|
||||
:custom
|
||||
(company-begin-commands '(self-insert-command))
|
||||
(company-idle-delay .1)
|
||||
(company-minimum-prefix-length 2)
|
||||
(company-show-numbers t)
|
||||
(company-tooltip-align-annotations 't)
|
||||
(global-company-mode t))
|
||||
|
||||
(use-package company-box
|
||||
:after company
|
||||
:diminish
|
||||
:hook (company-mode . company-box-mode))
|
||||
|
||||
(use-package dashboard
|
||||
:ensure t
|
||||
:init
|
||||
(setq initial-buffer-choice 'dashboard-open)
|
||||
(setq dashboard-set-heading-icons t)
|
||||
(setq dashboard-set-file-icons t)
|
||||
(setq dashboard-banner-logo-title "Emacs Is More Than A Text Editor!")
|
||||
;;(setq dashboard-startup-banner 'logo) ;; use standard emacs logo as banner
|
||||
(setq dashboard-startup-banner "/home/dt/.config/emacs/images/dtmacs-logo.png") ;; use custom image as banner
|
||||
(setq dashboard-center-content nil) ;; set to 't' for centered content
|
||||
(setq dashboard-items '((recents . 5)
|
||||
(agenda . 5 )
|
||||
(bookmarks . 3)
|
||||
(projects . 3)
|
||||
(registers . 3)))
|
||||
:custom
|
||||
(dashboard-modify-heading-icons '((recents . "file-text")
|
||||
(bookmarks . "book")))
|
||||
:config
|
||||
(dashboard-setup-startup-hook))
|
||||
|
||||
(use-package diminish)
|
||||
|
||||
(use-package dired-open
|
||||
:config
|
||||
(setq dired-open-extensions '(("gif" . "sxiv")
|
||||
("jpg" . "sxiv")
|
||||
("png" . "sxiv")
|
||||
("mkv" . "mpv")
|
||||
("mp4" . "mpv"))))
|
||||
|
||||
(use-package peep-dired
|
||||
:after dired
|
||||
:hook (evil-normalize-keymaps . peep-dired-hook)
|
||||
:config
|
||||
(evil-define-key 'normal dired-mode-map (kbd "h") 'dired-up-directory)
|
||||
(evil-define-key 'normal dired-mode-map (kbd "l") 'dired-open-file) ; use dired-find-file instead if not using dired-open package
|
||||
(evil-define-key 'normal peep-dired-mode-map (kbd "j") 'peep-dired-next-file)
|
||||
(evil-define-key 'normal peep-dired-mode-map (kbd "k") 'peep-dired-prev-file)
|
||||
)
|
||||
|
||||
;; Expands to: (elpaca evil (use-package evil :demand t))
|
||||
(use-package evil
|
||||
@@ -75,6 +85,45 @@
|
||||
(evil-collection-init))
|
||||
(use-package evil-tutor)
|
||||
|
||||
(use-package flycheck
|
||||
:ensure t
|
||||
:defer t
|
||||
:diminish
|
||||
:init (global-flycheck-mode))
|
||||
|
||||
(set-face-attribute 'default nil
|
||||
:font "JetBrains Mono"
|
||||
:height 110
|
||||
:weight 'medium)
|
||||
(set-face-attribute 'variable-pitch nil
|
||||
:font "Ubuntu"
|
||||
:height 120
|
||||
:weight 'medium)
|
||||
(set-face-attribute 'fixed-pitch nil
|
||||
:font "JetBrains Mono"
|
||||
:height 110
|
||||
:weight 'medium)
|
||||
;; Makes commented text and keywords italics.
|
||||
;; This is working in emacsclient but not emacs.
|
||||
;; Your font must have an italic face available.
|
||||
(set-face-attribute 'font-lock-comment-face nil
|
||||
:slant 'italic)
|
||||
(set-face-attribute 'font-lock-keyword-face nil
|
||||
:slant 'italic)
|
||||
|
||||
;; This sets the default font on all graphical frames created after restarting Emacs.
|
||||
;; Does the same thing as 'set-face-attribute default' above, but emacsclient fonts
|
||||
;; are not right unless I also add this method of setting the default font.
|
||||
(add-to-list 'default-frame-alist '(font . "JetBrains Mono-11"))
|
||||
|
||||
;; Uncomment the following line if line spacing needs adjusting.
|
||||
(setq-default line-spacing 0.12)
|
||||
|
||||
(global-set-key (kbd "C-=") 'text-scale-increase)
|
||||
(global-set-key (kbd "C--") 'text-scale-decrease)
|
||||
(global-set-key (kbd "<C-wheel-up>") 'text-scale-increase)
|
||||
(global-set-key (kbd "<C-wheel-down>") 'text-scale-decrease)
|
||||
|
||||
(use-package general
|
||||
:config
|
||||
(general-evil-setup)
|
||||
@@ -178,219 +227,6 @@
|
||||
"w L" '(buf-move-right :wk "Buffer move right"))
|
||||
)
|
||||
|
||||
(defun emacs-counsel-launcher ()
|
||||
"Create and select a frame called emacs-counsel-launcher which consists only of a minibuffer and has specific dimensions. Runs counsel-linux-app on that frame, which is an emacs command that prompts you to select an app and open it in a dmenu like behaviour. Delete the frame after that command has exited"
|
||||
(interactive)
|
||||
(with-selected-frame
|
||||
(make-frame '((name . "emacs-run-launcher")
|
||||
(minibuffer . only)
|
||||
(fullscreen . 0) ; no fullscreen
|
||||
(undecorated . t) ; remove title bar
|
||||
;;(auto-raise . t) ; focus on this frame
|
||||
;;(tool-bar-lines . 0)
|
||||
;;(menu-bar-lines . 0)
|
||||
(internal-border-width . 10)
|
||||
(width . 80)
|
||||
(height . 11)))
|
||||
(unwind-protect
|
||||
(counsel-linux-app)
|
||||
(delete-frame))))
|
||||
|
||||
(use-package app-launcher
|
||||
:elpaca '(app-launcher :host github :repo "SebastienWae/app-launcher"))
|
||||
;; create a global keyboard shortcut with the following code
|
||||
;; emacsclient -cF "((visibility . nil))" -e "(emacs-run-launcher)"
|
||||
|
||||
(defun emacs-run-launcher ()
|
||||
"Create and select a frame called emacs-run-launcher which consists only of a minibuffer and has specific dimensions. Runs app-launcher-run-app on that frame, which is an emacs command that prompts you to select an app and open it in a dmenu like behaviour. Delete the frame after that command has exited"
|
||||
(interactive)
|
||||
(with-selected-frame
|
||||
(make-frame '((name . "emacs-run-launcher")
|
||||
(minibuffer . only)
|
||||
(fullscreen . 0) ; no fullscreen
|
||||
(undecorated . t) ; remove title bar
|
||||
;;(auto-raise . t) ; focus on this frame
|
||||
;;(tool-bar-lines . 0)
|
||||
;;(menu-bar-lines . 0)
|
||||
(internal-border-width . 10)
|
||||
(width . 80)
|
||||
(height . 11)))
|
||||
(unwind-protect
|
||||
(app-launcher-run-app)
|
||||
(delete-frame))))
|
||||
|
||||
(use-package all-the-icons
|
||||
:ensure t
|
||||
:if (display-graphic-p))
|
||||
|
||||
(use-package all-the-icons-dired
|
||||
:hook (dired-mode . (lambda () (all-the-icons-dired-mode t))))
|
||||
|
||||
(require 'windmove)
|
||||
|
||||
;;;###autoload
|
||||
(defun buf-move-up ()
|
||||
"Swap the current buffer and the buffer above the split.
|
||||
If there is no split, ie now window above the current one, an
|
||||
error is signaled."
|
||||
;; "Switches between the current buffer, and the buffer above the
|
||||
;; split, if possible."
|
||||
(interactive)
|
||||
(let* ((other-win (windmove-find-other-window 'up))
|
||||
(buf-this-buf (window-buffer (selected-window))))
|
||||
(if (null other-win)
|
||||
(error "No window above this one")
|
||||
;; swap top with this one
|
||||
(set-window-buffer (selected-window) (window-buffer other-win))
|
||||
;; move this one to top
|
||||
(set-window-buffer other-win buf-this-buf)
|
||||
(select-window other-win))))
|
||||
|
||||
;;;###autoload
|
||||
(defun buf-move-down ()
|
||||
"Swap the current buffer and the buffer under the split.
|
||||
If there is no split, ie now window under the current one, an
|
||||
error is signaled."
|
||||
(interactive)
|
||||
(let* ((other-win (windmove-find-other-window 'down))
|
||||
(buf-this-buf (window-buffer (selected-window))))
|
||||
(if (or (null other-win)
|
||||
(string-match "^ \\*Minibuf" (buffer-name (window-buffer other-win))))
|
||||
(error "No window under this one")
|
||||
;; swap top with this one
|
||||
(set-window-buffer (selected-window) (window-buffer other-win))
|
||||
;; move this one to top
|
||||
(set-window-buffer other-win buf-this-buf)
|
||||
(select-window other-win))))
|
||||
|
||||
;;;###autoload
|
||||
(defun buf-move-left ()
|
||||
"Swap the current buffer and the buffer on the left of the split.
|
||||
If there is no split, ie now window on the left of the current
|
||||
one, an error is signaled."
|
||||
(interactive)
|
||||
(let* ((other-win (windmove-find-other-window 'left))
|
||||
(buf-this-buf (window-buffer (selected-window))))
|
||||
(if (null other-win)
|
||||
(error "No left split")
|
||||
;; swap top with this one
|
||||
(set-window-buffer (selected-window) (window-buffer other-win))
|
||||
;; move this one to top
|
||||
(set-window-buffer other-win buf-this-buf)
|
||||
(select-window other-win))))
|
||||
|
||||
;;;###autoload
|
||||
(defun buf-move-right ()
|
||||
"Swap the current buffer and the buffer on the right of the split.
|
||||
If there is no split, ie now window on the right of the current
|
||||
one, an error is signaled."
|
||||
(interactive)
|
||||
(let* ((other-win (windmove-find-other-window 'right))
|
||||
(buf-this-buf (window-buffer (selected-window))))
|
||||
(if (null other-win)
|
||||
(error "No right split")
|
||||
;; swap top with this one
|
||||
(set-window-buffer (selected-window) (window-buffer other-win))
|
||||
;; move this one to top
|
||||
(set-window-buffer other-win buf-this-buf)
|
||||
(select-window other-win))))
|
||||
|
||||
(use-package company
|
||||
:defer 2
|
||||
:diminish
|
||||
:custom
|
||||
(company-begin-commands '(self-insert-command))
|
||||
(company-idle-delay .1)
|
||||
(company-minimum-prefix-length 2)
|
||||
(company-show-numbers t)
|
||||
(company-tooltip-align-annotations 't)
|
||||
(global-company-mode t))
|
||||
|
||||
(use-package company-box
|
||||
:after company
|
||||
:diminish
|
||||
:hook (company-mode . company-box-mode))
|
||||
|
||||
(use-package dashboard
|
||||
:ensure t
|
||||
:init
|
||||
(setq initial-buffer-choice 'dashboard-open)
|
||||
(setq dashboard-set-heading-icons t)
|
||||
(setq dashboard-set-file-icons t)
|
||||
(setq dashboard-banner-logo-title "Emacs Is More Than A Text Editor!")
|
||||
;;(setq dashboard-startup-banner 'logo) ;; use standard emacs logo as banner
|
||||
(setq dashboard-startup-banner "/home/dt/.config/emacs/images/dtmacs-logo.png") ;; use custom image as banner
|
||||
(setq dashboard-center-content nil) ;; set to 't' for centered content
|
||||
(setq dashboard-items '((recents . 5)
|
||||
(agenda . 5 )
|
||||
(bookmarks . 3)
|
||||
(projects . 3)
|
||||
(registers . 3)))
|
||||
:custom
|
||||
(dashboard-modify-heading-icons '((recents . "file-text")
|
||||
(bookmarks . "book")))
|
||||
:config
|
||||
(dashboard-setup-startup-hook))
|
||||
|
||||
(use-package diminish)
|
||||
|
||||
(use-package dired-open
|
||||
:config
|
||||
(setq dired-open-extensions '(("gif" . "sxiv")
|
||||
("jpg" . "sxiv")
|
||||
("png" . "sxiv")
|
||||
("mkv" . "mpv")
|
||||
("mp4" . "mpv"))))
|
||||
|
||||
(use-package peep-dired
|
||||
:after dired
|
||||
:hook (evil-normalize-keymaps . peep-dired-hook)
|
||||
:config
|
||||
(evil-define-key 'normal dired-mode-map (kbd "h") 'dired-up-directory)
|
||||
(evil-define-key 'normal dired-mode-map (kbd "l") 'dired-open-file) ; use dired-find-file instead if not using dired-open package
|
||||
(evil-define-key 'normal peep-dired-mode-map (kbd "j") 'peep-dired-next-file)
|
||||
(evil-define-key 'normal peep-dired-mode-map (kbd "k") 'peep-dired-prev-file)
|
||||
)
|
||||
|
||||
(use-package flycheck
|
||||
:ensure t
|
||||
:defer t
|
||||
:diminish
|
||||
:init (global-flycheck-mode))
|
||||
|
||||
(set-face-attribute 'default nil
|
||||
:font "JetBrains Mono"
|
||||
:height 110
|
||||
:weight 'medium)
|
||||
(set-face-attribute 'variable-pitch nil
|
||||
:font "Ubuntu"
|
||||
:height 120
|
||||
:weight 'medium)
|
||||
(set-face-attribute 'fixed-pitch nil
|
||||
:font "JetBrains Mono"
|
||||
:height 110
|
||||
:weight 'medium)
|
||||
;; Makes commented text and keywords italics.
|
||||
;; This is working in emacsclient but not emacs.
|
||||
;; Your font must have an italic face available.
|
||||
(set-face-attribute 'font-lock-comment-face nil
|
||||
:slant 'italic)
|
||||
(set-face-attribute 'font-lock-keyword-face nil
|
||||
:slant 'italic)
|
||||
|
||||
;; This sets the default font on all graphical frames created after restarting Emacs.
|
||||
;; Does the same thing as 'set-face-attribute default' above, but emacsclient fonts
|
||||
;; are not right unless I also add this method of setting the default font.
|
||||
(add-to-list 'default-frame-alist '(font . "JetBrains Mono-11"))
|
||||
|
||||
;; Uncomment the following line if line spacing needs adjusting.
|
||||
(setq-default line-spacing 0.12)
|
||||
|
||||
(global-set-key (kbd "C-=") 'text-scale-increase)
|
||||
(global-set-key (kbd "C--") 'text-scale-decrease)
|
||||
(global-set-key (kbd "<C-wheel-up>") 'text-scale-increase)
|
||||
(global-set-key (kbd "<C-wheel-down>") 'text-scale-decrease)
|
||||
|
||||
(menu-bar-mode -1)
|
||||
(tool-bar-mode -1)
|
||||
(scroll-bar-mode -1)
|
||||
|
||||
Reference in New Issue
Block a user