Last active
February 9, 2022 16:07
-
-
Save AloisJanicek/24db14e72fa59937bdd43b24615e724e to your computer and use it in GitHub Desktop.
Minimal emacs init.el for fun or profit. With evil and counsel but without use-package or straight. Ready for both terminal and GUI.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Setup packages and stuff | |
(require 'package) | |
;; Add MELPA | |
(add-to-list 'package-archives | |
'("melpa" . "https://melpa.org/packages/") t) | |
(unless package--initialized | |
(package-initialize)) | |
;; List of packages to install | |
(setq package-selected-packages | |
'( | |
evil | |
evil-leader | |
evil-collection | |
counsel | |
ivy-hydra | |
mood-line | |
evil-terminal-cursor-changer | |
modus-operandi-theme | |
modus-vivendi-theme | |
rainbow-delimiters | |
)) | |
;; Ensure all the packages are installed | |
(dolist (package package-selected-packages) | |
(unless (package-installed-p package) | |
(unless package-archive-contents | |
(package-refresh-contents)) | |
(package-install package))) | |
;; Sane defaults | |
(setq | |
confirm-kill-processes nil | |
frame-title-format '("%b - Emacs Vanilla") | |
create-lockfiles nil | |
make-backup-files nil | |
custom-file (expand-file-name "custom.el" user-emacs-directory) | |
) | |
(setq-default indent-tabs-mode nil | |
tab-width 4) | |
;; Clear whitespace when saving file | |
(add-hook 'before-save-hook 'whitespace-cleanup) | |
;; Setup evil and stuff | |
(setq evil-want-keybinding nil) | |
(require 'evil) | |
(when (require 'evil-collection nil t) | |
(evil-collection-init)) | |
(evil-mode 1) | |
;; Setup counsel and ivy | |
(require 'counsel) | |
(counsel-mode) | |
(setq ivy-initial-inputs-alist nil) | |
(setq ivy-read-action-function #'ivy-hydra-read-action) | |
(setq ivy-read-action-format-function #'ivy-read-action-format-columns) | |
;; Collect list of recently opened files | |
(recentf-mode) | |
;; Highlight matching parens | |
(show-paren-mode) | |
;; Enable rainbow parens | |
(add-hook 'prog-mode-hook #'rainbow-delimiters-mode) | |
;; Misc GUI settings | |
(setq inhibit-splash-screen t) | |
(menu-bar-mode -1) | |
(tool-bar-mode -1) | |
(scroll-bar-mode -1) | |
;; Enable nice minimal mode-line | |
(mood-line-mode) | |
(if (display-graphic-p) | |
;; settings for GUI | |
(progn | |
(load-theme 'modus-vivendi t) | |
(set-face-attribute 'default nil | |
:height 110 | |
:family "Monospace" | |
) | |
) | |
;; settings for terminal | |
(progn | |
(require 'evil-terminal-cursor-changer) | |
(evil-terminal-cursor-changer-activate) | |
(setq evil-motion-state-cursor 'box) | |
(setq evil-visual-state-cursor 'box) | |
(setq evil-normal-state-cursor 'box) | |
(setq evil-insert-state-cursor 'bar) | |
(setq evil-emacs-state-cursor 'hbar) | |
(load-theme 'modus-vivendi t) | |
(custom-theme-set-faces | |
'modus-vivendi | |
'(default ((t (:background nil))))))) | |
;; Global Key Bindings | |
(global-set-key (kbd "M-a") 'mark-whole-buffer) | |
(global-set-key (kbd "M-s") 'save-buffer) | |
(global-set-key (kbd "M-f") 'swiper) | |
(global-set-key (kbd "M-q") 'save-buffers-kill-emacs) | |
(global-set-key (kbd "C-j") 'evil-window-down) | |
(global-set-key (kbd "C-k") 'evil-window-up) | |
(global-set-key (kbd "C-h") 'evil-window-left) | |
(global-set-key (kbd "C-l") 'evil-window-right) | |
(global-set-key (kbd "C-SPC") 'complete-symbol) | |
;; Evil Leader | |
(require 'evil-leader) | |
(global-evil-leader-mode) | |
(evil-leader/set-leader "SPC") | |
(evil-leader/set-key | |
"." 'counsel-find-file | |
"," 'counsel-switch-buffer | |
"fr" 'counsel-recentf | |
"bs" 'save-buffer | |
"bk" (lambda () | |
(interactive) | |
(kill-buffer (current-buffer))) | |
"ws" 'evil-window-split | |
"wv" 'evil-window-vsplit | |
"wc" 'evil-window-delete | |
"cs" 'eval-last-sexp | |
"q" 'evil-quit | |
"he" 'view-echo-area-messages | |
"hf" 'counsel-describe-function | |
"hv" 'counsel-describe-variable | |
"h." 'describe-symbol | |
"sb" 'swiper | |
"sd" 'counsel-rg | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment