Skip to content

akirabaruah/emacs-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Controls

General

Simplify key bindings.

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

Evil

Use Vim keybindings to avoid Repetitive Strain Injury (RSI).

(use-package evil
  :ensure t
  :demand t
  :requires general
  :general
  (:states '(normal visual emacs)
    "SPC" 'hydra-leader/body)
  :init
  (setq evil-want-C-i-jump nil)  ;; C-i is also <tab>; don't use it for evil.
  (setq evil-want-keybinding nil)  ;; Use evil-collection for bindings
                                   ;; in other packages.
  ;; For some reason, Magit's git-commit-mode defaults to emacs state instead of
  ;; normal or insert states. The with-editor-mode-hook below ensures that we
  ;; start that mode with insert instead of emacs state. See
  ;; https://github.com/emacs-evil/evil/issues/1145 and
  ;; https://emacs.stackexchange.com/questions/14008/default-magit-commit-state-in-evil.
  :hook ((with-editor-mode . evil-insert-state)
         (after-init . evil-mode)))

Evil Collection

Common Evil keybindings for other modes. Don’t initialize the whole package here; instead setup various components within the requiring use-package definition. See https://github.com/emacs-evil/evil-collection.

(use-package evil-collection
  :ensure t
  :requires evil
  :init
  ;; See evil-collection-mode-list definition in
  ;; https://github.com/emacs-evil/evil-collection/blob/master/evil-collection.el
  ;; for available modes and how to add them below.
  (evil-collection-init
    '((buff-menu "buff-menu")
      dired
      magit
      (package-menu package))))

Hydra

Hydras are configurable key command menus.

(use-package hydra
  :ensure t)

Which Key

See https://github.com/justbur/emacs-which-key.

(use-package which-key
  :ensure t
  :hook (after-init . which-key-mode))

Magit

Git interface. See https://github.com/magit/magit.

(use-package magit :ensure t)

Enable Evil keybindings for Magit. See https://github.com/emacs-evil/evil-magit.

(use-package evil-magit
  :requires (evil magit)
  :ensure t)

Hydra Menus

Definitions for Hydra menus. Requires the hydra package installed above.

Leader Menu

First, create a top-level menu launched by the leader key.

(defhydra hydra-leader (:color blue) "
Leader Hydra
"
  ("f" hydra-file/body "file")
  ("b" hydra-buffer/body "buffer")
  ("w" hydra-window/body "window")
  ("g" magit-status "magit")
  ("E" hydra-editor/body "editor")
  ("Q" save-buffers-kill-emacs "quit emacs")
  ("SPC" nil "cancel"))

File

Basic file navigation.

(defhydra hydra-file (:color blue :hint nil) "
File Hydra
"
  ("e" load-file "load elisp")
  ("f" find-file "find")
  ("s" save-buffer "save"))

Buffer

Buffer manipulation.

(defhydra hydra-buffer (:color blue) "
Buffer Hydra
"
  ("b" switch-to-buffer "switch to buffer")
  ("r" revert-buffer-no-confirm "reload buffer contents")
  ("SPC" nil "cancel"))

Custom buffer functions used above.

;; See https://www.emacswiki.org/emacs/RevertBuffer#toc1.
(defun revert-buffer-no-confirm ()
    "Revert buffer without confirmation."
    (interactive)
    (revert-buffer :ignore-auto :noconfirm))

Window

Window manipulation.

(defhydra hydra-window (:hint nil) "
Window Hydra
^Movement^  ^Manipulation^
^--------^  ^------------^---------
_j_: down   _-_: split vertically
_k_: up     _/_: split horizontally
_h_: left   _c_: close window
_l_: right
"
  ("j" evil-window-down)
  ("k" evil-window-up)
  ("h" evil-window-left)
  ("l" evil-window-right)
  ("-" split-window-vertically)
  ("/" split-window-horizontally)
  ("c" delete-window)
  ("SPC" nil "cancel" :color blue))

Editor

Editor configuration.

(defhydra hydra-editor (:color blue :hint nil) "
Emacs Hydra
"
  ("r" load-editor-init "reload init file")
  ("i" find-editor-init "open init file")
  ("o" find-editor-config "open config")
  ("SPC" nil "cancel" :color blue))

Define custom functions for editor init and config files used above.

(defun load-editor-init ()
  "Load editor initialization file."
  (interactive)
  (load-file user-init-file))

(defun find-editor-init ()
  "Open the editor initialization file for modification."
  (interactive)
  (find-file user-init-file))

(defun find-editor-config ()
  "Open the editor config file for modification."
  (interactive)
  (find-file user-config-file))

Display

Column Numbers

Show column numbers.

(setq-default column-number-mode t)

Line Numbers

Show line numbers. See https://www.emacswiki.org/emacs/LineNumbers.

(when (version<= "26.0.50" emacs-version )
  (global-display-line-numbers-mode)
  ;; https://github.com/coldnew/linum-relative#backends
  (setq linum-relative-backend 'display-line-numbers-mode))

Linum Relative

(use-package linum-relative
  :ensure t
  :hook (after-init . linum-relative-mode))

Centered Cursor Mode

(use-package centered-cursor-mode
  :ensure t
  :hook (after-init . global-centered-cursor-mode))

Diff HL

Highlights uncomitted changes for various VC backends. See https://github.com/dgutov/diff-hl.

(use-package diff-hl
  :ensure t
  :config
  (unless (display-graphic-p) (diff-hl-margin-mode))
  :hook (after-init . global-diff-hl-mode))

Helpful

See https://github.com/Wilfred/helpful.

(use-package helpful
  :ensure t)

Content

Files

Backup Files

Save backups of open files to /tmp (or equivalent) directory.

(setq backup-directory-alist
      `((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
      `((".*" ,temporary-file-directory t)))

Custom File

Put custom autogenerated settings in a separate file.

(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(when (file-exists-p custom-file)
  (load custom-file 'noerror))

Clean Up

Delete trailing whitespace on save.

(add-hook 'before-save-hook 'delete-trailing-whitespace)

Editing

Column Width

Use up to 80 characters per line by default.

(setq-default fill-column 80)

Automatically wrap blocks of text.

(setq-default auto-fill-function 'do-auto-fill)

Intelligence

Company

“COMPlete ANYthing” framework for text completion. See https://company-mode.github.io/.

(use-package company
  :ensure t
  :requires evil-collection
  :custom
  (evil-collection-company-use-tng nil "Disable company-tng frontend")
  :init
  (setq company-idle-delay 0)
  (evil-collection-company-setup)
  :config
  (add-to-list 'company-backends 'company-ispell)
  (add-to-list 'company-backends 'company-yasnippet)
  :hook (after-init . global-company-mode))

Flycheck

On-the-fly syntax checking. See https://github.com/flycheck/flycheck.

(use-package flycheck
  :ensure t
  :hook (after-init . global-flycheck-mode))

YASnippet

Reusable text snippets. See https://github.com/joaotavora/yasnippet.

(use-package yasnippet
  :ensure t
  :config
  :hook (after-init . yas-global-mode))

Yasnippet doesn’t include snippets out of the box, so include the official package of pre-written snippets. See https://github.com/AndreaCrotti/yasnippet-snippets.

(use-package yasnippet-snippets
  :ensure t
  :requires yasnippet)

Theme

Doom Themes

Cool themes from https://github.com/hlissner/emacs-doom-themes.

(use-package doom-themes
  :ensure t
  :config
  (load-theme 'doom-one t))

Doom Modeline

See https://github.com/seagle0128/doom-modeline.

(use-package doom-modeline
  :ensure t
  :hook (after-init . doom-modeline-mode))

All the Icons

Nice fonts used by Doom packages. For example, see https://github.com/jacktasia/beautiful-emacs/blob/master/init.org.

(use-package all-the-icons
  :if window-system
  :ensure t
  :config
  (when (not (member "all-the-icons" (font-family-list)))
    (all-the-icons-install-fonts t)))

Languages

LSP Mode

Language Server Protocol integration. See https://github.com/emacs-lsp/lsp-mode.

(use-package lsp-mode
  :ensure t
  :hook (c++-mode . lsp-deferred)
  :commands lsp lsp-deferred)

CC Mode

Configs for the C/C++ mode included in Emacs.

(use-package cc-mode
  :ensure t
  :mode (("\\.h\\'" . c++-mode)))

Google C Style

Google style formatting for C/C++ modes.

(use-package google-c-style
  :ensure t
  :init
  (add-hook 'c-mode-common-hook
            (lambda ()
              (google-set-c-style)
              (google-make-newline-indent))))

GN Mode

Major mode for gn (Generate Ninja) from https://github.com/lashtear/gn-mode.

(use-package gn-mode
  :ensure t
  :mode (("\\.gn\\'" . gn-mode)
         ("\\.gni\\'" . gn-mode)))

YAML Mode

See https://github.com/yoshiki/yaml-mode.

(use-package yaml-mode
  :ensure t
  :mode (("\\.yml\\'" . yaml-mode)
         ("\\.yaml\\'" . yaml-mode)))

About

Akira's Emacs configuration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published