13 KiB
- Bloxie's Emacs Configuration
- Introduction
- Config
Bloxie's Emacs Configuration
By Curt Spark / Bloxiebird.
Introduction
Welcome to my Emacs configuration!
Config
Appearance
Remove Tool Bar
(tool-bar-mode -1)
Remove Menu Bar
(menu-bar-mode -1)
Remove Scroll Bar
(scroll-bar-mode -1)
Display Line Numbers
(add-hook 'prog-mode-hook 'display-line-numbers-mode)
Modern Fringes
(use-package modern-fringes
:ensure t
:init
(modern-fringes-invert-arrows))
Theming
(use-package dracula-theme
:ensure t
:init
(load-theme 'dracula t))
All The Icons
(use-package all-the-icons
:ensure t)
All The Icons for Ivy/Counsel
(use-package all-the-icons-ivy
:ensure t
:init
(all-the-icons-ivy-setup))
Mode Line
Spaceline
(use-package spaceline
:ensure t
:config
(require 'spaceline-config)
(setq powerline-default-separator (quote arrow))
(spaceline-spacemacs-theme))
Display the time on the Mode Line, this is more useful for EXWM.
(setq display-time-default-load-average nil)
(display-time-mode t)
Diminish
With Diminish you can optionally remove some of the names of the modes in the Mode Line.
(use-package diminish
:ensure t)
Emacs Dashboard
Install the Emacs Dashboard :
(use-package dashboard
:ensure t
:config
(dashboard-setup-startup-hook))
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))
Emacs Dashboard Config :
;; Set the title
(setq dashboard-banner-logo-title "Welcome to Bloxie's Emacs!")
;; Set the banner
(setq dashboard-startup-banner 'logo)
;; Value can be
;; 'official which displays the official emacs logo
;; 'logo which displays an alternative emacs logo
;; 1, 2 or 3 which displays one of the text banners
;; "path/to/your/image.png" which displays whatever image you would prefer
;; Content is not centered by default. To center, set
(setq dashboard-center-content t)
;; To disable shortcut "jump" indicators for each section, set
(setq dashboard-show-shortcuts nil)
;;To customize which widgets are displayed, you can use the following snippet
(setq dashboard-items '((recents . 5)
(bookmarks . 5)
(projects . 5)
(agenda . 5)
(registers . 5)))
;; To show agenda for the upcoming seven days set the variable show-week-agenda-p to t.
;; (setq show-week-agenda-p t)
;; Note that setting list-size for the agenda list is intentionally ignored; all agenda items for the current day will be displayed.
;; To customize which categories from the agenda items should be visible in the dashboard set the dashboard-org-agenda-categories to the list of categories you need.
;; (setq dashboard-org-agenda-categories '("Tasks" "Appointments"))
;; To add icons to the widget headings and their items:
(setq dashboard-set-heading-icons t)
(setq dashboard-set-file-icons t)
;; To show navigator below the banner:
(setq dashboard-set-navigator t)
;; To customize the buttons of the navigator like this:
;; Format: "(icon title help action face prefix suffix)"
(setq dashboard-navigator-buttons
`(;; line1
((,(all-the-icons-octicon "mark-github" :height 1.1 :v-adjust 0.0)
"Homepage"
"Browse homepage"
(lambda (&rest _) (browse-url "https://gitlab.com/bloxiebird/linux-emacs-configuration")))
("★" "Star" "Show stars" (lambda (&rest _) (show-stars)) warning)
("?" "" "?/h" #'show-help nil "<" ">"))
))
EXWM
Emacs X Window Manager
+BEGIN_SRC emacs-lisp (use-package exwm :ensure t :config (require 'exwm-config) (exwm-config-default)) +END_SRC
EXWM System Tray +BEGIN_SRC emacs-lisp (require 'exwm-systemtray) (exwm-systemtray-enable) +END_SRC
If not using EXWM, it will ask to replace the Window Manager with EXWM, I do not like this prompt when using Emacs on other Window Managers. +BEGIN_SRC emacs-lisp (setq exwm-replace 'nil) +END_SRC
Ido gets automatically enabled in the default EXWM configuration, as we're using Ivy. Let's disable it.
(ido-mode -1)
Set Number of Workspaces initially created. +BEGIN_SRC emacs-lisp (setq exwm-workspace-number 10) +END_SRC
EXWM Specific Keybindings +BEGIN_SRC emacs-lisp
; Set whether workspaces wrap around or not. (defvar exwm-workspace-switch-wrap t)
(defun exwm/exwm-workspace-next () "Switch to next exwm-workspace (to the right)." (interactive) (let* ((only-workspace? (equal exwm-workspace-number 1)) (overflow? (= exwm-workspace-current-index (1- exwm-workspace-number)))) (cond (only-workspace? nil) (overflow? (when exwm-workspace-switch-wrap (exwm-workspace-switch 0))) (t (exwm-workspace-switch (1+ exwm-workspace-current-index))))))
(defun exwm/exwm-workspace-prev () "Switch to next exwm-workspace (to the left)." (interactive) (let* ((only-workspace? (equal exwm-workspace-number 1)) (overflow? (= exwm-workspace-current-index 0))) (cond (only-workspace? nil) (overflow? (when exwm-workspace-switch-wrap (exwm-workspace-switch (1- exwm-workspace-number)))) (t (exwm-workspace-switch (1- exwm-workspace-current-index))))))
(global-set-key (kbd "<s-right>") 'exwm/exwm-workspace-next) (global-set-key (kbd "<s-left>") 'exwm/exwm-workspace-prev) (global-set-key (kbd "s-e") 'evil-quit-all) (global-set-key (kbd "s-k") 'exwm-workspace-move) (global-set-key (kbd "s-w") 'exwm-workspace-swap) +END_SRC
The Emacs Application Framework
The Emacs Application Framework is a big project, please check the README before use, install dependencies etc.
+BEGIN_SRC emacs-lisp (use-package eaf :load-path "~/.emacs.d/site-lisp/emacs-application-framework" ; Set to "/usr/share/emacs/site-lisp/eaf" if installed from AUR :bind ("C-c C-f" . 'eaf-open) :custom (eaf-find-alternate-file-in-dired t) :config (eaf-bind-key scroll_up "C-n" eaf-pdf-viewer-keybinding) (eaf-bind-key scroll_down "C-p" eaf-pdf-viewer-keybinding) (eaf-bind-key take_photo "p" eaf-camera-keybinding)) +END_SRC
Dynamic Window Tiling
Edwina
Edwina is a dynamic window manager for Emacs. It automatically arranges your Emacs panes (called “windows” in Emacs parlance) into predefined layouts, dwm-style. +BEGIN_SRC emacs-lisp (use-package edwina :ensure t :config (setq display-buffer-base-action '(display-buffer-below-selected)) (edwina-setup-dwm-keys) (edwina-mode 1)) +END_SRC
Golden Ratio
+BEGIN_SRC emacs-lisp (use-package golden-ratio :ensure t :init (golden-ratio-mode 1)) +END_SRC
Custom
Resizing Buffers
(global-set-key (kbd "<C-up>") 'shrink-window)
(global-set-key (kbd "<C-down>") 'enlarge-window)
(global-set-key (kbd "<C-left>") 'shrink-window-horizontally)
(global-set-key (kbd "<C-right>") 'enlarge-window-horizontally)
Fullscreen Function
(defun fullscreen (&optional f)
(interactive)
(x-send-client-message nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0))
(x-send-client-message nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0)))
Call Function on Startup
(fullscreen)
Symon
A system resource viewer
Add hashtag before + to enable
+BEGIN_SRC emacs-lisp (use-package symon :ensure t :init (symon-mode 1)) +END_SRC
DMenu
A recreation of the iconic Suckless Dynamic Menu.
(use-package dmenu
:ensure t
:bind
("s-d" . 'dmenu))
Evil Mode
(use-package evil
:ensure t
:init
(evil-mode 1))
Org Mode
Simple Org Mode Preview in HTML
(defun update-other-buffer ()
(interactive)
(other-window 1)
(revert-buffer nil t)
(other-window -1))
(defun org-compile-beamer-and-update-other-buffer ()
"Has as a premise that it's run from an org-mode buffer and the
other buffer already has the PDF open"
(interactive)
(org-beamer-export-to-pdf)
(update-other-buffer))
(defun org-compile-latex-and-update-other-buffer ()
"Has as a premise that it's run from an org-mode buffer and the
other buffer already has the PDF open"
(interactive)
(org-latex-export-to-pdf)
(update-other-buffer))
(define-key org-mode-map (kbd "C-c lr") 'org-compile-latex-and-update-other-buffer)
(define-key org-mode-map (kbd "C-c br") 'org-compile-beamer-and-update-other-buffer)
LateX Preview
(use-package org-fragtog
:ensure t
:init
(add-hook 'org-mode-hook 'org-fragtog-mode))
Org Bullets
(use-package org-bullets
:ensure t
:config
(add-hook 'org-mode-hook (lambda () (org-bullets-mode))))
Enable Indent Mode
(add-hook 'org-mode-hook 'org-indent-mode)
Enable Beamer Support
(add-hook 'org-mode-hook 'org-beamer-mode)
Agenda
Set Agenda Directory :
(setq org-agenda-files (quote("~/.emacs.d/agenda.org")))
Calendar/Diary integration :
(setq org-agenda-include-diary t)
Projectile
Install Projectile:
(use-package projectile
:ensure t
:init
(projectile-mode))
Auto Completion
Ivy
(use-package ivy
:ensure t
:init
(ivy-mode 1)
:bind
("C-s" . swiper))
Ivy Configuration :
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t)
Counsel
(use-package counsel
:ensure t)
Counsel for Projectile
(use-package counsel-projectile
:ensure t
:init
(counsel-projectile-mode))
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
Company
Company Base
(use-package company
:ensure t
:init
(add-hook 'prog-mode-hook 'company-mode))
Configuration :
; No delay in showing suggestions.
(setq company-idle-delay 0)
; Show suggestions after entering one character.
(setq company-minimum-prefix-length 1)
; Wrap around when suggestions reach bottom.
(setq company-selection-wrap-around t)
; Use tab key to cycle through suggestions.
; ('tng' means 'tab and go')
(company-tng-configure-default)
Company Quickhelp
(use-package company-quickhelp
:ensure t
:init
(company-quickhelp-mode))
Company + Yasnippet
+BEGIN_SRC emacs-lisp (use-package yasnippet :ensure t :config (use-package yasnippet-snippets :ensure t) (yas-reload-all)) (add-hook 'prog-mode-hook 'yas-minor-mode) (add-to-list 'company-backends 'company-yasnippet) +END_SRC
Company-Jedi Python
(use-package company-jedi
:ensure t)
Set Company-Jedi to run on Python buffers. :
(require 'company-jedi)
(autoload 'jedi:setup "jedi" nil t)
(add-hook 'python-mode-hook 'jedi:setup)
(add-to-list 'company-backends 'company-jedi)
Which Key
(use-package which-key
:ensure t
:init
(which-key-mode))
Spell Correction
Flyspell Correct Ivy
(use-package flyspell-correct-ivy
:ensure t
:bind ("C-M-;" . flyspell-correct-wrapper)
:init
(setq flyspell-correct-interface #'flyspell-correct-ivy))
Multiple Cursors
(use-package multiple-cursors
:ensure t
:bind
("C-c m" . 'mc/mark-next-like-this)
:bind
("C-c C-m" . 'mc/mark-all-like-this))
Expand Region
Auto selects a region of text/code.
(use-package expand-region
:ensure t
:bind
("C-c e" . 'er/expand-region))
Rainbow Delimiters
This Minor Mode will mark pairs of brackets with colours.
(use-package rainbow-delimiters
:ensure t)
Set Minor Mode as Global :
(define-globalized-minor-mode global-rainbow-delimiters-mode rainbow-delimiters-mode
(lambda () (rainbow-delimiters-mode 1)))
(global-rainbow-delimiters-mode 1)
Rainbow Mode
This Minor Mode will highlight RGB/HEX values with their respective colours.
(use-package rainbow-mode
:ensure t)
Set Minor Mode as Global :
(define-globalized-minor-mode global-rainbow-mode rainbow-mode
(lambda () (rainbow-mode 1)))
(global-rainbow-mode 1)