10 KiB
Emacs Configuration from TuDatTr
- Preface
- Package installation
- Appearance
- Emacs Configuration
- Mode Configuration
Preface
Before installing and using emacs, emacs should be run as a daemon.
This decreases the loading times of the editor enormously and enables you to return to your former emacs session at any time.
To do this you first need to make sure emace --daemon
is run during the start up.
To access the daemonized emacs you can either run emacsclient -t
to use it in the terminal or simply emacsclient
if you want to use the GUI version.
Package installation
Preperation
Initialize Emacs builtin package system and add the melpa-package repository.
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(package-initialize)
(package-refresh-contents)
Installation
use-package
A use-package declaration for simplifying your .emacs
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(require 'use-package)
(setq use-package-always-ensure t)
diminish
Diminished modes are minor modes with no modeline display
(use-package diminish)
no-littering
Help keeping ~/.emacs.d clean
(use-package no-littering)
evil/evil-collection
The extensible vi layer for Emacs.
A set of keybindings for evil-mode
(use-package evil
:init
(setq evil-want-keybinding nil)
:config
(evil-mode 1)
(setq evil-search-module 'evil-search))
(use-package evil-collection
:config
(evil-collection-init))
Ivy/Counsil/Swiper
Ivy - a generic completion frontend for Emacs
Swiper - isearch with an overview, and more. Oh, man!
(use-package prescient)
(use-package ivy-prescient
:config
(ivy-prescient-mode 1))
(use-package ivy)
(use-package counsel
:diminish counsel-mode
:config
(counsel-mode 1))
(use-package swiper
:bind (("C-s" . 'swiper)))
Magit
A Git Porcelain inside Emacs.
(use-package magit)
AUCTeX
an extensible package for writing and formatting TeX files.
(use-package auctex
:defer t
:config
(setq TeX-parse-self t)
(setq-default TeX-master nil)
(setq TeX-PDF-mode t)
(add-to-list 'TeX-view-program-list '(("Zathura" "zathura %o")))
(add-to-list 'TeX-view-program-selection '((output-pdf "Zathura")))
)
ox-reveal
Exports Org-mode contents to Reveal.js HTML presentation.
(use-package ox-reveal)
ox-twbs
Export org-mode docs as HTML compatible with Twitter Bootstrap.
(use-package ox-twbs)
org-bullets
utf-8 bullets for org-mode
(use-package org-bullets)
rainbow-mode
Colorize color names in buffers
(use-package rainbow-mode)
rainbow-delimiters
Emacs rainbow delimiters mode
(use-package rainbow-delimiters)
yasnippet
A template system for Emacs
(use-package yasnippet
:config
(setq yas-snippet-dirs '("~/.emacs.d/snippets/"))
(yas-global-mode 1))
company-mode
Modular in-buffer completion framework for Emacs
(use-package company
:config
(global-company-mode))
flycheck
On the fly syntax checking for GNU Emacs
(use-package flycheck
:config
(global-flycheck-mode))
htmlize.el
Convert buffer text and decorations to HTML.
(use-package htmlize)
ansible
Ansible minor mode
(use-package ansible
:config
(ansible 1))
flycheck-rust
Better Rust/Cargo support for Flycheck
(use-package flycheck-rust)
rust-mode
Emacs configuration for Rust
(use-package rust-mode)
cargo.el
(use-package cargo)
ein
(use-package ein)
ob-async
(use-package ob-async)
simpleclip
(use-package simpleclip
:config
(simpleclip-mode 1))
ledger-mode
(use-package ledger-mode
:mode ("\\.ledger\\'")
:config
(autoload 'ledger-mode "ledger-mode" "A major mode for Ledger" t)
(add-to-list 'load-path
(expand-file-name "/path/to/ledger/source/lisp/"))
(add-to-list 'auto-mode-alist '("\\.ledger$" . ledger-mode))
)
yaml-mode
(use-package yaml-mode
:config
(add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode))
:bind-keymap
("\C-m" . (newline-and-indent))
)
Appearance
This section is for appearance customization. Either via packages or manually.
emacs-one-themes
A port of the Vim/Atom One Dark and Light themes to Emacs
##+begin_src emacs-lisp
##+end_src
Transparent Emacs (Commented out)
Makes the default color of the background of emacs the same as the terminals color. This is kind of a janky solution, but it works.
(add-hook 'window-setup-hook
'(lambda ()
(if not (display-graphic-p)
(set-face-background 'default "unspecified-bg"))))
Menubar
Remove the menu-bar at the top of the screen for better immersion.
(menu-bar-mode -1)
Emacs Configuration
Symbolic Links
Follow symlinks without asking for confirmation.
(setq vc-follow-symlinks t)
Tab Behavior (spaces > tabs)
(setq-default indent-tabs-mode nil)
Mode Configuration
Org-mode
Enable org-bullets and hide leading stars.
(add-hook 'org-mode-hook
(lambda ()
(org-bullets-mode 1)
(setq org-pretty-entities t)
(setq org-src-fontify-natively t)))
Enable utf8x on latex output
(setq org-latex-inputenc-alist '(("utf8" . "utf8x")))
minted options for pdfexport
(setq org-latex-listings 'minted
org-latex-packages-alist '(("" "minted"))
org-latex-pdf-process
'("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
"pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
(setq org-latex-minted-options '(("breaklines" "true")
("breakanywhere" "true")))
Keybindings
(define-key org-mode-map (kbd "C-c ,") 'org-insert-structure-template)
Enables specific languages for org-babel, so those languages can be used and compiled in code blocks and disable the compilation confirmation. The code afterwords enables proper indentation inside those source blocks.
(org-babel-do-load-languages
'org-babel-load-languages
'((emacs-lisp . t)
(C . t)
(makefile . t)
(shell . t)
(latex . t)
(python . t)))
(setq org-confirm-babel-evaluate nil)
(setq org-src-tab-acts-natively t)
C-mode
(add-hook 'c-mode-hook
(lambda ()
(display-line-numbers-mode 1)))
C++-mode
(add-hook 'c++-mode-hook
(lambda ()
(display-line-numbers-mode 1)))
rust-mode
cargo.el
(add-hook 'rust-mode-hook 'cargo-minor-mode)
flycheck-rust
(add-hook 'flycheck-mode-hook #'flycheck-rust-setup)