1
0
mirror of https://github.com/alrayyes/dotfiles/ synced 2023-11-14 15:56:30 +00:00
dotfiles/emacs/.emacs.d/config.org
2021-05-05 20:28:15 +02:00

6.2 KiB

Ryan's Emacs config

About

My personal Emacs config.

init.el

To load this config add the following to init.el

(org-babel-load-file
 (expand-file-name
  "config.org"
  user-emacs-directory))

Package Management

Archives

  (setq package-archives '(("melpa" . "https://melpa.org/packages/")
			   ("org" . "https://orgmode.org/elpa/")
			   ("elpa" . "https://elpa.gnu.org/packages/")))

  (package-initialize)
  (unless package-archive-contents
  (package-refresh-contents))

Use-Package

The use-package macro allows you to isolate package configuration in your .emacs file in a way that is both performance-oriented and, well, tidy.

(unless (package-installed-p 'use-package)
  (package-install 'use-package))

(require 'use-package)
  ;; "ensure" packages by default
  (setq use-package-always-ensure t)

Ensure

The :ensure keyword causes the package(s) to be installed automatically if not already present on your system

(require 'use-package-ensure)
(setq use-package-always-ensure t)

General Configuration

User Interface

Start with minimal interface

(setq inhibit-startup-message t) ;; Disable startup message

(scroll-bar-mode -1)        ; Disable visible scrollbar
(tool-bar-mode -1)          ; Disable the toolbar
(tooltip-mode -1)           ; Disable tooltips
(menu-bar-mode -1)          ; Disable the menu bar

;; Set up the visible bell
(setq visible-bell t)

Enable line numbers and customize their format.

  (column-number-mode)
  (global-display-line-numbers-mode t)
  (setq display-line-numbers-type `relative)

Theme

(use-package doom-themes)
(load-theme 'doom-molokai t)

Font

  (set-face-attribute 'default nil :font "JetBrainsMono Nerd Font")

Icons

(use-package all-the-icons)

Mode Line

Doom Modeline

    (use-package doom-modeline
  :init (doom-modeline-mode 1)
  :custom (doom-modeline-height 15))

Keyboard Bindings

Escape Cancels All

(global-set-key (kbd "<escape>") 'keyboard-escape-quit)

Evil Mode

General

  (use-package evil
    :init      ;; tweak evil's configuration before loading it
    (setq evil-want-keybinding nil)
(setq evil-want-C-u-scroll t)
    (evil-mode))

Evil Collection

Evil Collection is also installed since it adds 'evil' bindings to parts of Emacs that the standard Evil package does not cover, such as: calendar, help-mode and ibuffer.

  (use-package evil-collection
    :after evil
    :config
    (evil-collection-init))

General Keybindings

general.el provides a more convenient way to bind keys in emacs for both evil and non-evil users. general-define-key allows defining multiple keys at once, implicitly wrapping key strings with (kbd …), having named prefix key sequences (like the leader key in vim), and more.

   (use-package general
     :config
     (general-evil-setup t)

  (general-create-definer dw/leader-key-def
     :keymaps '(normal insert visual emacs)
     :prefix "SPC"
     :global-prefix "C-SPC"))

Keybinding Panel (which-key)

which-key shows an overview of what keybindings are available based on the prefix keys you entered.

  (use-package which-key
    :init (which-key-mode)
  :config(setq which-key-idle-delay 0.3))

Ivy

General

    (use-package ivy
      :diminish
      :bind (("C-s" . swiper)
	     :map ivy-minibuffer-map
	     ("TAB" . ivy-alt-done)
	     ("C-l" . ivy-alt-done)
	     ("C-j" . ivy-next-line)
	     ("C-k" . ivy-previous-line)
	     :map ivy-switch-buffer-map
	     ("C-k" . ivy-previous-line)
	     ("C-l" . ivy-done)
	     ("C-d" . ivy-switch-buffer-kill)
	     :map ivy-reverse-i-search-map
	     ("C-k" . ivy-previous-line)
	     ("C-d" . ivy-reverse-i-search-kill))
      :init
      (ivy-mode 1)) ;; Load keybindings

Ivy-rich

ivy-rich comes with rich transformers for commands from ivy and counsel.

      (use-package ivy-rich
:after counsel
    :init
  (ivy-rich-mode 1))

Counsel

ivy-mode ensures that any Emacs command using completing-read-function uses ivy for completion.

Counsel takes this further, providing versions of common Emacs commands that are customised to make the best use of Ivy. For example, counsel-find-file has some additional keybindings. Pressing DEL will move you to the parent directory.

(use-package counsel
  :demand t
  :bind (("M-x" . counsel-M-x)
         ("C-x b" . counsel-ibuffer)
         ("C-x C-f" . counsel-find-file)
         ;; ("C-M-j" . counsel-switch-buffer)
         ("C-M-l" . counsel-imenu)
         :map minibuffer-local-map
         ("C-r" . 'counsel-minibuffer-history))
  :custom
  (counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
  :config
  (setq ivy-initial-inputs-alist nil)) ;; Don't start searches with ^

Development

Languages

Emacs Lisp

Helpful

Helpful is an alternative to the built-in Emacs help that provides much more contextual information.

(use-package helpful
  :custom
  (counsel-describe-function-function #'helpful-callable)
  (counsel-describe-variable-function #'helpful-variable)
  :bind
  ([remap describe-function] . helpful-function)
  ([remap describe-symbol] . helpful-symbol)
  ([remap describe-variable] . helpful-variable)
  ([remap describe-command] . helpful-command)
  ([remap describe-key] . helpful-key))

Productivity

Rainbow Delimiters

  (use-package rainbow-delimiters
    :hook (prog-mode . rainbow-delimiters-mode))