|
|
|
#+STARTUP: overview
|
|
|
|
#+TITLE: Ricemacs, an Emacs Configuration
|
|
|
|
#+AUTHOR: Riyyi
|
|
|
|
#+LANGUAGE: en
|
|
|
|
#+OPTIONS: toc:nil
|
|
|
|
#+SETUPFILE: https://fniessen.github.io/org-html-themes/setup/theme-readtheorg.setup
|
|
|
|
#+LATEX_HEADER: \usepackage{color}
|
|
|
|
#+LATEX_HEADER: \usepackage[top=100pt,bottom=100pt,left=75pt,right=75pt]{geometry}
|
|
|
|
#+LATEX_HEADER: \definecolor{blue}{rgb}{0,0.5,1}
|
|
|
|
#+LATEX_HEADER: \hypersetup{colorlinks=true, linkcolor=blue, urlcolor=blue, citecolor=blue}
|
|
|
|
|
|
|
|
* Table of Contents :toc_4:
|
|
|
|
- [[#initial-setup][Initial setup]]
|
|
|
|
- [[#irony-mode][Irony mode]]
|
|
|
|
- [[#all-the-icons][All the icons]]
|
|
|
|
- [[#customizations][Customizations]]
|
|
|
|
- [[#package-management][Package Management]]
|
|
|
|
- [[#ensure][Ensure]]
|
|
|
|
- [[#auto-update][Auto update]]
|
|
|
|
- [[#compile][Compile]]
|
|
|
|
- [[#packages][Packages]]
|
|
|
|
- [[#general][General]]
|
|
|
|
- [[#evil][Evil]]
|
|
|
|
- [[#telephone-line][Telephone Line]]
|
|
|
|
- [[#neotree][NeoTree]]
|
|
|
|
- [[#centaur-tabs][Centaur Tabs]]
|
|
|
|
- [[#projectile][Projectile]]
|
|
|
|
- [[#org][Org]]
|
|
|
|
- [[#completion][Completion]]
|
|
|
|
- [[#company][Company]]
|
|
|
|
- [[#flycheck][Flycheck]]
|
|
|
|
- [[#lsp][LSP]]
|
|
|
|
- [[#yasnippet][YASnippet]]
|
|
|
|
- [[#cc][C/C++]]
|
|
|
|
- [[#php][PHP]]
|
|
|
|
- [[#prettify][Prettify]]
|
|
|
|
- [[#rss][RSS]]
|
|
|
|
- [[#general-1][General]]
|
|
|
|
- [[#buffers][Buffers]]
|
|
|
|
- [[#electric][Electric]]
|
|
|
|
- [[#file-backups][File Backups]]
|
|
|
|
- [[#hide-elements][Hide Elements]]
|
|
|
|
- [[#org-1][Org]]
|
|
|
|
- [[#recentf][Recentf]]
|
|
|
|
- [[#tabs][Tabs]]
|
|
|
|
- [[#utf-8][UTF-8]]
|
|
|
|
- [[#window][Window]]
|
|
|
|
- [[#functions][Functions]]
|
|
|
|
- [[#general-2][General]]
|
|
|
|
- [[#package][Package]]
|
|
|
|
- [[#advice-and-aliases][Advice and Aliases]]
|
|
|
|
- [[#advice][Advice]]
|
|
|
|
- [[#aliases][Aliases]]
|
|
|
|
- [[#general-3][General]]
|
|
|
|
- [[#package-1][Package]]
|
|
|
|
- [[#hooks][Hooks]]
|
|
|
|
- [[#key-bindings][Key Bindings]]
|
|
|
|
- [[#disable-default][Disable Default]]
|
|
|
|
- [[#disable-package][Disable Package]]
|
|
|
|
- [[#set-default][Set Default]]
|
|
|
|
- [[#set-package][Set Package]]
|
|
|
|
- [[#leader][Leader]]
|
|
|
|
- [[#global-leader][Global Leader]]
|
|
|
|
- [[#local-leader][Local Leader]]
|
|
|
|
- [[#notes][Notes]]
|
|
|
|
|
|
|
|
* Initial setup
|
|
|
|
|
|
|
|
These commands need to be run after the first startup.
|
|
|
|
|
|
|
|
** Irony mode
|
|
|
|
|
|
|
|
M-x =irony-install-server=
|
|
|
|
|
|
|
|
** All the icons
|
|
|
|
|
|
|
|
M-x =all-the-icons-install-fonts=
|
|
|
|
|
|
|
|
* Customizations
|
|
|
|
|
|
|
|
Store custom-file separately, don't freak out when it's not found.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(setq custom-file (concat emacs-d "/custom.el"))
|
|
|
|
(load custom-file 'noerror)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
Set custom faces, without using customize.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(set-face-attribute 'default nil :height 90 :family "DejaVu Sans Mono")
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
* Package Management
|
|
|
|
** Ensure
|
|
|
|
|
|
|
|
Ensures packages are installed by default.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(require 'use-package-ensure)
|
|
|
|
(setq use-package-always-ensure t)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Auto update
|
|
|
|
|
|
|
|
Update pending updates of installed packages at startup.
|
|
|
|
https://github.com/rranelli/auto-package-update.el
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(use-package auto-package-update
|
|
|
|
:custom
|
|
|
|
(auto-package-update-delete-old-versions t)
|
|
|
|
(auto-package-update-hide-results t)
|
|
|
|
(auto-package-update-last-update-day-path (concat emacs-cache "/.last-package-update-day"))
|
|
|
|
:config
|
|
|
|
(auto-package-update-maybe))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Compile
|
|
|
|
|
|
|
|
Automatically compile all packages.
|
|
|
|
https://github.com/emacscollective/auto-compile
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(use-package auto-compile
|
|
|
|
:custom (load-prefer-newer t)
|
|
|
|
:config
|
|
|
|
(auto-compile-on-load-mode)
|
|
|
|
(auto-compile-on-save-mode))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Packages
|
|
|
|
|
|
|
|
Install and configure packages.
|
|
|
|
|
|
|
|
*** General
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(use-package hybrid-reverse-theme
|
|
|
|
:load-path "~/code/elisp/emacs-hybrid-reverse"
|
|
|
|
:custom (load-theme 'hybrid-reverse t))
|
|
|
|
|
|
|
|
(use-package all-the-icons
|
|
|
|
:defer t)
|
|
|
|
|
|
|
|
(use-package which-key
|
|
|
|
:defer 1
|
|
|
|
:custom
|
|
|
|
(which-key-add-column-padding 1)
|
|
|
|
(which-key-max-display-columns nil)
|
|
|
|
(which-key-min-display-lines 5)
|
|
|
|
(which-key-sort-order 'which-key-prefix-then-key-order)
|
|
|
|
(which-key-sort-uppercase-first nil)
|
|
|
|
:config (which-key-mode))
|
|
|
|
|
|
|
|
(use-package general)
|
|
|
|
|
|
|
|
(use-package ido-vertical-mode
|
|
|
|
:config (ido-vertical-mode))
|
|
|
|
|
|
|
|
(use-package smex
|
|
|
|
:defer t
|
|
|
|
:custom (smex-prompt-string "Command: ")
|
|
|
|
:config (smex-initialize))
|
|
|
|
|
|
|
|
(use-package avy
|
|
|
|
:defer t)
|
|
|
|
|
|
|
|
(use-package hungry-delete
|
|
|
|
:config (global-hungry-delete-mode))
|
|
|
|
|
|
|
|
(use-package smart-tabs-mode
|
|
|
|
:config
|
|
|
|
(smart-tabs-add-language-support latex latex-mode-hook
|
|
|
|
((latex-indent-line . 4)
|
|
|
|
(latex-indent-region . 4)))
|
|
|
|
(smart-tabs-insinuate 'c 'c++ 'java 'python 'latex))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
*** Evil
|
|
|
|
|
|
|
|
Evil mode and related packages.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(use-package undo-tree)
|
|
|
|
(use-package goto-chg)
|
|
|
|
|
|
|
|
(use-package evil
|
|
|
|
:after (undo-tree goto-chg)
|
|
|
|
:custom
|
|
|
|
(evil-search-module 'evil-search)
|
|
|
|
(evil-ex-complete-emacs-commands nil)
|
|
|
|
(evil-vsplit-window-right t)
|
|
|
|
(evil-split-window-below t)
|
|
|
|
(evil-shift-round nil)
|
|
|
|
(evil-want-C-u-scroll t)
|
|
|
|
;; Do not set half cursor in operator state
|
|
|
|
(evil-operator-state-cursor 'box)
|
|
|
|
;; Needed by evil-collection
|
|
|
|
(evil-want-integration t)
|
|
|
|
(evil-want-keybinding nil)
|
|
|
|
:config (evil-mode))
|
|
|
|
|
|
|
|
(use-package evil-collection
|
|
|
|
:after evil
|
|
|
|
:custom
|
|
|
|
(evil-collection-company-use-tng nil)
|
|
|
|
(evil-collection-key-blacklist (list dot/leader-key dot/localleader-key
|
|
|
|
dot/leader-alt-key dot/localleader-alt-key
|
|
|
|
"M-h" "M-j" "M-k" "M-l"))
|
|
|
|
(evil-collection-setup-minibuffer t)
|
|
|
|
:config (evil-collection-init))
|
|
|
|
|
|
|
|
(use-package evil-nerd-commenter
|
|
|
|
:defer t
|
|
|
|
:after evil)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
*** Telephone Line
|
|
|
|
|
|
|
|
Emacs mode line replacement.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(use-package telephone-line
|
|
|
|
:custom
|
|
|
|
(telephone-line-lhs
|
|
|
|
'((evil . (telephone-line-evil-tag-segment))
|
|
|
|
(accent . (telephone-line-erc-modified-channels-segment
|
|
|
|
telephone-line-process-segment
|
|
|
|
telephone-line-buffer-segment))
|
|
|
|
(nil . (telephone-line-projectile-segment))))
|
|
|
|
:config (telephone-line-mode))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
*** NeoTree
|
|
|
|
|
|
|
|
Provides Emacs with a file tree.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(use-package neotree
|
|
|
|
:after all-the-icons
|
|
|
|
:custom
|
|
|
|
(neo-theme (if (display-graphic-p) 'icons 'arrow))
|
|
|
|
(neo-autorefresh nil)
|
|
|
|
(neo-dont-be-alone t)
|
|
|
|
(neo-mode-line-type 'none)
|
|
|
|
(neo-show-hidden-files t)
|
|
|
|
(neo-vc-integration '(face))
|
|
|
|
:hook (neotree-mode . (lambda (&rest _) (display-line-numbers-mode 0))))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
*** Centaur Tabs
|
|
|
|
|
|
|
|
Places buffers as tabs in a bar at the top.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(use-package centaur-tabs
|
|
|
|
:after all-the-icons
|
|
|
|
:demand
|
|
|
|
:custom
|
|
|
|
(centaur-tabs-height 40)
|
|
|
|
(centaur-tabs-set-icons t)
|
|
|
|
(centaur-tabs-style "slant")
|
|
|
|
;; (centaur-tabs-set-modified-marker t)
|
|
|
|
;; (centaur-tabs-modified-marker "*")
|
|
|
|
;; (centaur-tabs-height 29)
|
|
|
|
;; (centaur-tabs-set-icons nil)
|
|
|
|
:hook (neotree-mode . centaur-tabs-local-mode)
|
|
|
|
:config
|
|
|
|
(centaur-tabs-mode))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
*** Projectile
|
|
|
|
|
|
|
|
Project manager.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(use-package projectile
|
|
|
|
:custom
|
|
|
|
(projectile-enable-caching t)
|
|
|
|
(projectile-indexing-method 'hybrid)
|
|
|
|
(projectile-project-search-path '("~"))
|
|
|
|
(projectile-sort-order 'recentf)
|
|
|
|
:config (projectile-mode))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
*** Org
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(use-package htmlize
|
|
|
|
:defer t
|
|
|
|
:custom (org-export-html-postamble nil))
|
|
|
|
;org-export-html-postamble-format @ToDo
|
|
|
|
|
|
|
|
;; Table of contents
|
|
|
|
(use-package toc-org
|
|
|
|
:defer t)
|
|
|
|
|
|
|
|
;; Github flavored Markdown exporter
|
|
|
|
(use-package ox-gfm
|
|
|
|
:defer t)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
*** Completion
|
|
|
|
|
|
|
|
Autocomplete packages (includes code completion and snippets).
|
|
|
|
|
|
|
|
**** Company
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(use-package company
|
|
|
|
:defer t
|
|
|
|
:custom
|
|
|
|
(company-idle-delay 0.2)
|
|
|
|
(company-minimum-prefix-length 2)
|
|
|
|
(company-tooltip-align-annotations 't)
|
|
|
|
:hook
|
|
|
|
((c-mode-common
|
|
|
|
emacs-lisp-mode
|
|
|
|
latex-mode
|
|
|
|
org-mode
|
|
|
|
php-mode
|
|
|
|
shell-mode
|
|
|
|
shell-script-mode)
|
|
|
|
. company-mode)
|
|
|
|
)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
**** Flycheck
|
|
|
|
|
|
|
|
On the fly syntax checking.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(use-package flycheck
|
|
|
|
:defer t
|
|
|
|
:hook
|
|
|
|
((c-mode-common
|
|
|
|
emacs-lisp-mode
|
|
|
|
latex-mode
|
|
|
|
org-mode
|
|
|
|
php-mode
|
|
|
|
shell-mode
|
|
|
|
shell-script-mode)
|
|
|
|
. flycheck-mode))
|
|
|
|
|
|
|
|
;; For .el files which are intended to be packages
|
|
|
|
(use-package flycheck-package
|
|
|
|
:after flycheck
|
|
|
|
:config
|
|
|
|
(add-to-list 'flycheck-checkers 'flycheck-emacs-lisp-package)
|
|
|
|
(flycheck-package-setup))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
**** LSP
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(use-package lsp-mode
|
|
|
|
:commands lsp
|
|
|
|
:after which-key
|
|
|
|
:hook
|
|
|
|
((c-mode ; clangd
|
|
|
|
c++-mode ; clangd
|
|
|
|
php-mode) ; nodejs-intelephense
|
|
|
|
. lsp-deferred)
|
|
|
|
:custom
|
|
|
|
(lsp-auto-guess-root t)
|
|
|
|
(lsp-clients-clangd-args '("-compile-commands-dir=build" "-j=2" "-background-index" "-log=error"))
|
|
|
|
(lsp-enable-xref t)
|
|
|
|
(lsp-keep-workspace-alive nil)
|
|
|
|
(lsp-prefer-flymake nil)
|
|
|
|
:config
|
|
|
|
|
|
|
|
;; Enable which-key descriptions
|
|
|
|
(dolist (leader-key (list dot/leader-key dot/leader-alt-key))
|
|
|
|
(let ((lsp-keymap-prefix (concat leader-key " l")))
|
|
|
|
(lsp-enable-which-key-integration)))
|
|
|
|
)
|
|
|
|
|
|
|
|
(use-package company-lsp
|
|
|
|
:commands company-lsp
|
|
|
|
:after (company lsp-mode)
|
|
|
|
:custom
|
|
|
|
(company-transformers nil)
|
|
|
|
(company-lsp-async t)
|
|
|
|
(company-lsp-cache-candidates nil)
|
|
|
|
(company-lsp-enable-snippet t)
|
|
|
|
:config (push 'company-lsp company-backends))
|
|
|
|
|
|
|
|
(use-package lsp-ui
|
|
|
|
:commands lsp-ui-mode
|
|
|
|
:after (flycheck lsp-mode)
|
|
|
|
:custom
|
|
|
|
(lsp-ui-doc-border (face-foreground 'default))
|
|
|
|
(lsp-ui-doc-enable nil)
|
|
|
|
(lsp-ui-doc-header t)
|
|
|
|
(lsp-ui-doc-include-signature t)
|
|
|
|
(lsp-ui-doc-position 'top)
|
|
|
|
(lsp-ui-doc-use-childframe t)
|
|
|
|
(lsp-ui-flycheck-enable t)
|
|
|
|
(lsp-ui-flycheck-list-position 'right)
|
|
|
|
(lsp-ui-flycheck-live-reporting t)
|
|
|
|
(lsp-ui-peek-enable nil)
|
|
|
|
(lsp-ui-sideline-enable nil))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
**** YASnippet
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(use-package yasnippet
|
|
|
|
:defer t
|
|
|
|
:hook
|
|
|
|
((org-mode
|
|
|
|
prog-mode
|
|
|
|
tex-mode)
|
|
|
|
. yas-minor-mode)
|
|
|
|
:custom (yas-prompt-functions '(yas-ido-prompt
|
|
|
|
yas-completing-prompt))
|
|
|
|
:config (yas-reload-all))
|
|
|
|
|
|
|
|
(use-package yasnippet-snippets
|
|
|
|
:after yasnippet)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
**** C/C++
|
|
|
|
|
|
|
|
Irony requires M-x =irony-install-server=.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(use-package irony
|
|
|
|
:defer t
|
|
|
|
:hook
|
|
|
|
((c-mode
|
|
|
|
c++-mode)
|
|
|
|
. irony-mode)
|
|
|
|
(irony-mode . irony-cdb-autosetup-compile-options)
|
|
|
|
:config (push 'glsl-mode irony-supported-major-modes))
|
|
|
|
|
|
|
|
(use-package company-irony
|
|
|
|
:after company irony
|
|
|
|
:config (push 'company-irony company-backends))
|
|
|
|
|
|
|
|
(use-package company-c-headers
|
|
|
|
:after company
|
|
|
|
:config (push 'company-c-headers company-backends))
|
|
|
|
;; company-irony-c-headers
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
*** PHP
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(use-package php-mode
|
|
|
|
:defer t
|
|
|
|
:hook
|
|
|
|
(php-mode
|
|
|
|
. (lambda () (progn
|
|
|
|
(setq indent-tabs-mode t)
|
|
|
|
(setq lsp-ui-doc-enable t)))))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
*** Prettify
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(use-package dashboard
|
|
|
|
:custom
|
|
|
|
(initial-buffer-choice (lambda () (get-buffer "*dashboard*")))
|
|
|
|
(dashboard-banner-logo-title "GNU Emacs master race!")
|
|
|
|
(dashboard-center-content t)
|
|
|
|
(dashboard-set-file-icons t)
|
|
|
|
(dashboard-set-footer nil)
|
|
|
|
(dashboard-set-heading-icons t)
|
|
|
|
(dashboard-show-shortcuts t)
|
|
|
|
(dashboard-startup-banner 'logo)
|
|
|
|
(dashboard-items '((projects . 10)
|
|
|
|
(bookmarks . 5)
|
|
|
|
(recents . 5)))
|
|
|
|
:hook (dashboard-mode . (lambda (&rest _) (display-line-numbers-mode 0)))
|
|
|
|
:config (dashboard-setup-startup-hook))
|
|
|
|
|
|
|
|
(use-package rainbow-mode
|
|
|
|
:defer t
|
|
|
|
:hook (prog-mode . rainbow-mode))
|
|
|
|
|
|
|
|
(use-package rainbow-delimiters
|
|
|
|
:defer t
|
|
|
|
:hook (prog-mode . rainbow-delimiters-mode))
|
|
|
|
|
|
|
|
(use-package org-bullets
|
|
|
|
:defer t
|
|
|
|
:hook (org-mode . org-bullets-mode))
|
|
|
|
|
|
|
|
;; Cmake syntax highlighting
|
|
|
|
(use-package cmake-mode
|
|
|
|
:defer t)
|
|
|
|
|
|
|
|
;; Shader syntax highlighting
|
|
|
|
(use-package glsl-mode
|
|
|
|
:defer t)
|
|
|
|
|
|
|
|
;; Mark code after the 80 column range
|
|
|
|
(use-package column-enforce-mode
|
|
|
|
:defer t
|
|
|
|
:custom (column-enforce-comments nil)
|
|
|
|
:custom-face (column-enforce-face ((t (:background "#373b41" :foreground "#de935f"))))
|
|
|
|
:hook (prog-mode . column-enforce-mode))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
Possible modern replacement for column-enforce-mode:
|
|
|
|
https://github.com/laishulu/hl-fill-column
|
|
|
|
|
|
|
|
*** RSS
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(use-package elfeed
|
|
|
|
:defer t
|
|
|
|
:custom
|
|
|
|
(elfeed-db-directory (concat emacs-d "/elfeed"))
|
|
|
|
(elfeed-enclosure-default-dir "~/downloads/")
|
|
|
|
(elfeed-search-filter "@6-months-ago +unread")
|
|
|
|
(elfeed-search-clipboard-type 'CLIPBOARD)
|
|
|
|
(elfeed-search-title-max-width 100)
|
|
|
|
(elfeed-search-title-min-width 30)
|
|
|
|
(elfeed-search-trailing-width 55)
|
|
|
|
(elfeed-show-unique-buffers t)
|
|
|
|
(elfeed-feeds
|
|
|
|
'(("https://www.youtube.com/feeds/videos.xml?user=linustechtips" comedy reviews youtube)
|
|
|
|
("https://www.youtube.com/feeds/videos.xml?channel_id=UC2eYFnH61tmytImy1mTYvhA" boomer linux shell youtube)
|
|
|
|
("https://phoronix.com/rss.php" linux news reviews)
|
|
|
|
("https://lukesmith.xyz/rss.xml" boomer linux shell)
|
|
|
|
))
|
|
|
|
:hook
|
|
|
|
(elfeed-search-mode . (lambda (&rest _) (display-line-numbers-mode 0)))
|
|
|
|
(elfeed-show-mode . (lambda (&rest _) (display-line-numbers-mode 0))))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
* General
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
;; Columns start at 1
|
|
|
|
(setq column-number-indicator-zero-based nil)
|
|
|
|
|
|
|
|
;; Custom thems, do not ask if safe
|
|
|
|
(setq custom-safe-themes t)
|
|
|
|
|
|
|
|
;; Scrolling
|
|
|
|
(setq scroll-conservatively 1)
|
|
|
|
(setq mouse-wheel-scroll-amount '(5))
|
|
|
|
(setq mouse-wheel-progressive-speed nil)
|
|
|
|
|
|
|
|
;; Automatically add newline on save at the end of the file
|
|
|
|
(setq require-final-newline t)
|
|
|
|
|
|
|
|
;; Parenthesis, set behavior
|
|
|
|
(setq show-paren-delay 0)
|
|
|
|
(setq show-paren-style 'mixed)
|
|
|
|
|
|
|
|
;; End sentences with a single space
|
|
|
|
(setq sentence-end-double-space nil)
|
|
|
|
|
|
|
|
;; Tramp default protocol
|
|
|
|
(setq tramp-default-method "ssh")
|
|
|
|
|
|
|
|
;; Set undo limit, measured in bytes
|
|
|
|
(setq-default undo-limit 400000)
|
|
|
|
(setq-default undo-strong-limit 3000000)
|
|
|
|
(setq-default undo-outer-limit 12000000)
|
|
|
|
|
|
|
|
;; Enable line numbers
|
|
|
|
(global-display-line-numbers-mode)
|
|
|
|
|
|
|
|
;; C++ syntax highlighting for .h files
|
|
|
|
(add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode))
|
|
|
|
|
|
|
|
;; When in the GUI version of Emacs, enable pretty symbols
|
|
|
|
(when window-system (global-prettify-symbols-mode t))
|
|
|
|
|
|
|
|
;; Set the frame title
|
|
|
|
(setq frame-title-format
|
|
|
|
`("%b"
|
|
|
|
(:eval
|
|
|
|
(if (buffer-file-name)
|
|
|
|
(concat
|
|
|
|
(if (buffer-modified-p) " *" nil)
|
|
|
|
" ("
|
|
|
|
(abbreviate-file-name
|
|
|
|
(directory-file-name
|
|
|
|
(file-name-directory (buffer-file-name))))
|
|
|
|
")")
|
|
|
|
nil))
|
|
|
|
,(format " - GNU Emacs %s" emacs-version)
|
|
|
|
))
|
|
|
|
(setq icon-title-format frame-title-format)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Buffers
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
;; Buffers
|
|
|
|
(setq ido-create-new-buffer 'always)
|
|
|
|
(setq ido-enable-flex-maching t)
|
|
|
|
(setq ido-everywhere t)
|
|
|
|
(setq ibuffer-expert t)
|
|
|
|
;; Enable ido
|
|
|
|
(ido-mode 1)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Electric
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
;; Make return key also do indent of previous line
|
|
|
|
(electric-indent-mode 1)
|
|
|
|
(setq electric-pair-pairs '(
|
|
|
|
(?\( . ?\))
|
|
|
|
(?\[ . ?\])
|
|
|
|
))
|
|
|
|
(electric-pair-mode 1)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** File Backups
|
|
|
|
|
|
|
|
File auto-saves, backups, tramps.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(unless (file-directory-p emacs-cache)
|
|
|
|
(make-directory emacs-cache t))
|
|
|
|
;https://emacs.stackexchange.com/questions/33/put-all-backups-into-one-backup-folder
|
|
|
|
(setq backup-directory-alist `((".*" . ,emacs-cache))
|
|
|
|
auto-save-file-name-transforms `((".*" ,(concat emacs-cache "") t))
|
|
|
|
auto-save-list-file-prefix (concat emacs-cache "/.saves-")
|
|
|
|
tramp-backup-directory-alist `((".*" . ,emacs-cache))
|
|
|
|
tramp-auto-save-directory emacs-cache)
|
|
|
|
(setq create-lockfiles nil ; Disable lockfiles (.#)
|
|
|
|
backup-by-copying t ; Don't cobber symlinks
|
|
|
|
delete-old-versions t ; Cleanup backups
|
|
|
|
version-control t ; Use version numbers on backups
|
|
|
|
kept-new-versions 5 ; Backups to keep
|
|
|
|
kept-old-versions 2) ; ,,
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Hide Elements
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(menu-bar-mode 0)
|
|
|
|
(scroll-bar-mode 0)
|
|
|
|
(tool-bar-mode 0)
|
|
|
|
(tooltip-mode 0)
|
|
|
|
(fringe-mode 0)
|
|
|
|
(blink-cursor-mode 0)
|
|
|
|
|
|
|
|
(setq inhibit-startup-message t)
|
|
|
|
(setq initial-scratch-message nil)
|
|
|
|
(setq ring-bell-function 'ignore)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Org
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(use-package org
|
|
|
|
:custom
|
|
|
|
(org-directory (concat (getenv "HOME") "/documents/org"))
|
|
|
|
(org-ellipsis " ↴")
|
|
|
|
(org-latex-toc-command "\\newpage \\tableofcontents \\newpage")
|
|
|
|
(org-return-follows-link t)
|
|
|
|
(org-src-fontify-natively t)
|
|
|
|
(org-src-window-setup 'current-window)
|
|
|
|
)
|
|
|
|
|
|
|
|
;; Enable syntax highlighting when exporting to .pdf
|
|
|
|
;; Load latex exporter
|
|
|
|
(use-package ox-latex
|
|
|
|
:ensure nil ; ox-latex.el is part of org
|
|
|
|
:defer t
|
|
|
|
:after org
|
|
|
|
:custom
|
|
|
|
;; Define how minted is added to source code blocks
|
|
|
|
(org-latex-listings 'minted)
|
|
|
|
(org-latex-minted-options '(("frame" "lines") ("linenos=true")))
|
|
|
|
:config
|
|
|
|
;; Add minted package to every LaTeX header
|
|
|
|
(add-to-list 'org-latex-packages-alist '("" "minted"))
|
|
|
|
;; Append -shell-escape to every element in org-latex-pdf-process
|
|
|
|
(setq org-latex-pdf-process
|
|
|
|
(mapcar
|
|
|
|
(lambda (s)
|
|
|
|
(if (not (string-match-p "-shell-escape" s))
|
|
|
|
(replace-regexp-in-string "%latex " "%latex -shell-escape " s)
|
|
|
|
s))
|
|
|
|
org-latex-pdf-process))
|
|
|
|
)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Recentf
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(use-package recentf
|
|
|
|
:config
|
|
|
|
(setq recentf-auto-cleanup 'never)
|
|
|
|
(setq recentf-exclude '("~$" "/ssh:" "/sudo:"))
|
|
|
|
(setq recentf-filename-handlers '(abbreviate-file-name))
|
|
|
|
(setq recentf-max-menu-items 0)
|
|
|
|
(setq recentf-max-saved-items 200)
|
|
|
|
(setq recentf-save-file (concat emacs-cache "/recentf"))
|
|
|
|
(recentf-mode)
|
|
|
|
)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Tabs
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
;; Tabs
|
|
|
|
(setq-default tab-width 4
|
|
|
|
indent-tabs-mode t)
|
|
|
|
|
|
|
|
;; C/C++-like languages formatting style
|
|
|
|
;https://www.emacswiki.org/emacs/IndentingC
|
|
|
|
(setq-default c-basic-offset 4
|
|
|
|
sgml-basic-offset 4
|
|
|
|
c-default-style "linux")
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** UTF-8
|
|
|
|
|
|
|
|
Set UTF-8 encoding as default.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(prefer-coding-system 'utf-8-unix)
|
|
|
|
(setq locale-coding-system 'utf-8-unix)
|
|
|
|
;; Default also sets keyboard and terminal coding system
|
|
|
|
(set-default-coding-systems 'utf-8-unix)
|
|
|
|
(set-buffer-file-coding-system 'utf-8-unix)
|
|
|
|
(set-file-name-coding-system 'utf-8-unix)
|
|
|
|
(set-selection-coding-system 'utf-8-unix)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Window
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
;; Window rules
|
|
|
|
(setq display-buffer-alist
|
|
|
|
'(
|
|
|
|
("^\\(\\*e?shell\\|vterm\\).*"
|
|
|
|
(display-buffer-in-side-window)
|
|
|
|
(window-height . 0.25)
|
|
|
|
(side . bottom)
|
|
|
|
(slot . -1)
|
|
|
|
(centaur-tabs-local-mode 1))
|
|
|
|
("\\*Help.*"
|
|
|
|
(display-buffer-in-side-window)
|
|
|
|
(window-height . 0.25)
|
|
|
|
(side . bottom)
|
|
|
|
(slot . 0)
|
|
|
|
(centaur-tabs-local-mode 1))
|
|
|
|
("\\*Faces\\*"
|
|
|
|
(display-buffer-in-side-window)
|
|
|
|
(window-height . 0.25)
|
|
|
|
(side . bottom)
|
|
|
|
(slot . 1)
|
|
|
|
(centaur-tabs-local-mode 1))
|
|
|
|
))
|
|
|
|
|
|
|
|
(add-hook 'shell-mode-hook 'centaur-tabs-local-mode)
|
|
|
|
(add-hook 'eshell-mode-hook 'centaur-tabs-local-mode)
|
|
|
|
(add-hook 'help-mode-hook 'centaur-tabs-local-mode)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
* Functions
|
|
|
|
** General
|
|
|
|
|
|
|
|
Functions that only use built-in Emacs functionality.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(defun bookmark-jump-ido ()
|
|
|
|
"Use ido to search for the bookmark."
|
|
|
|
(interactive)
|
|
|
|
(bookmark-jump
|
|
|
|
(bookmark-get-bookmark
|
|
|
|
(ido-completing-read "Jump to bookmark: " (bookmark-all-names)))))
|
|
|
|
|
|
|
|
(defun bookmark-delete-ido ()
|
|
|
|
"Use ido to search for the bookmark to delete."
|
|
|
|
(interactive)
|
|
|
|
(bookmark-delete
|
|
|
|
(bookmark-get-bookmark
|
|
|
|
(ido-completing-read "Delete bookmark: " (bookmark-all-names)))))
|
|
|
|
|
|
|
|
(defun config-visit ()
|
|
|
|
"Config edit."
|
|
|
|
(interactive)
|
|
|
|
(find-file (concat emacs-d "/config.org")))
|
|
|
|
|
|
|
|
(defun config-reload ()
|
|
|
|
"Config reload."
|
|
|
|
(interactive)
|
|
|
|
(org-babel-load-file (concat emacs-d "/config.org")))
|
|
|
|
|
|
|
|
(defun display-startup-echo-area-message ()
|
|
|
|
"Hide default startup message."
|
|
|
|
(message ""))
|
|
|
|
|
|
|
|
(defun dot/describe-symbol-at-point (&optional symbol)
|
|
|
|
"Display the full documentation of SYMBOL at point.
|
|
|
|
Will show the info of SYMBOL as a function, variable, and/or face."
|
|
|
|
(interactive "P")
|
|
|
|
(let ((symbol (symbol-at-point)))
|
|
|
|
(when symbol
|
|
|
|
(describe-symbol symbol))))
|
|
|
|
|
|
|
|
(defun dot/indent-buffer ()
|
|
|
|
"Indent each nonblank line in the buffer."
|
|
|
|
(interactive)
|
|
|
|
(save-excursion
|
|
|
|
(indent-region (point-min) (point-max) nil)))
|
|
|
|
|
|
|
|
(defun dot/org-ret-at-point ()
|
|
|
|
"Org return key at point.
|
|
|
|
|
|
|
|
If point is on:
|
|
|
|
link -- follow it
|
|
|
|
otherwise -- run the default (evil-ret) expression"
|
|
|
|
(interactive)
|
|
|
|
(let ((type (org-element-type (org-element-context))))
|
|
|
|
(pcase type
|
|
|
|
('link (if org-return-follows-link (org-open-at-point) (evil-ret)))
|
|
|
|
(_ (evil-ret))
|
|
|
|
)))
|
|
|
|
|
|
|
|
(defun dot/sudo-find-file (filename)
|
|
|
|
"Edit file FILENAME as root."
|
|
|
|
(interactive "FOpen file (as root): ")
|
|
|
|
(find-file (concat "/sudo:root@localhost:" filename)))
|
|
|
|
|
|
|
|
(defun dot/sudo-this-file ()
|
|
|
|
"Edit the current file as root."
|
|
|
|
(interactive)
|
|
|
|
(if buffer-file-name
|
|
|
|
(find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name))
|
|
|
|
(princ "Current buffer isn't a file")))
|
|
|
|
|
|
|
|
(defun split-follow-horizontally ()
|
|
|
|
"Split and follow window."
|
|
|
|
(interactive)
|
|
|
|
(split-window-below)
|
|
|
|
(other-window 1))
|
|
|
|
(defun split-follow-vertically ()
|
|
|
|
"Split and follow window."
|
|
|
|
(interactive)
|
|
|
|
(split-window-right)
|
|
|
|
(other-window 1))
|
|
|
|
|
|
|
|
(defun find-project-root ()
|
|
|
|
"Return root of the project, determined by .git/, 'default-directory' otherwise."
|
|
|
|
(let ((search-directory (locate-dominating-file "." ".git")))
|
|
|
|
(if search-directory
|
|
|
|
search-directory
|
|
|
|
default-directory))
|
|
|
|
)
|
|
|
|
|
|
|
|
(defun find-file-in-project-root ()
|
|
|
|
"Find file in project root."
|
|
|
|
(interactive)
|
|
|
|
(let ((default-directory (find-project-root)))
|
|
|
|
(call-interactively 'find-file)))
|
|
|
|
|
|
|
|
|
|
|
|
;; https://emacsredux.com/blog/2013/05/04/rename-file-and-buffer/
|
|
|
|
(defun rename-file-and-buffer ()
|
|
|
|
"Rename the current buffer and file it is visiting."
|
|
|
|
(interactive)
|
|
|
|
(let ((filename (buffer-file-name)))
|
|
|
|
(if (not (and filename (file-exists-p filename)))
|
|
|
|
(message "Buffer is not visiting a file!")
|
|
|
|
(let ((new-name (read-file-name "New name: " filename)))
|
|
|
|
(cond
|
|
|
|
((vc-backend filename) (vc-rename-file filename new-name))
|
|
|
|
(t
|
|
|
|
(rename-file filename new-name t)
|
|
|
|
(set-visited-file-name new-name t t)))))))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Package
|
|
|
|
|
|
|
|
Functions that use package functionality.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(defun centaur-tabs-buffer-groups ()
|
|
|
|
"Organize tabs into groups."
|
|
|
|
(list
|
|
|
|
(cond
|
|
|
|
((string-equal "*" (substring (buffer-name) 0 1)) "Emacs")
|
|
|
|
((derived-mode-p 'dired-mode) "Dired")
|
|
|
|
((memq major-mode '(org-mode
|
|
|
|
org-agenda-mode
|
|
|
|
diary-mode
|
|
|
|
emacs-lisp-mode)) "OrgMode")
|
|
|
|
(t "User"))))
|
|
|
|
|
|
|
|
(defun dashboard-goto-bookmarks ()
|
|
|
|
"Go to bookmarks."
|
|
|
|
(interactive)
|
|
|
|
(funcall (local-key-binding "m")))
|
|
|
|
|
|
|
|
(defun dashboard-goto-projects ()
|
|
|
|
"Go to projects."
|
|
|
|
(interactive)
|
|
|
|
(funcall (local-key-binding "p")))
|
|
|
|
|
|
|
|
(defun dashboard-goto-recent-files ()
|
|
|
|
"Go to recent files."
|
|
|
|
(interactive)
|
|
|
|
(funcall (local-key-binding "r")))
|
|
|
|
|
|
|
|
(defun lsp-format-region-or-buffer ()
|
|
|
|
"Format the selection (or buffer) with LSP."
|
|
|
|
(interactive)
|
|
|
|
(unless (bound-and-true-p lsp-mode)
|
|
|
|
(user-error "Not in an LSP buffer"))
|
|
|
|
(call-interactively
|
|
|
|
(if (use-region-p)
|
|
|
|
#'lsp-format-region
|
|
|
|
#'lsp-format-buffer)))
|
|
|
|
|
|
|
|
(defun neotree-toggle-in-project-root ()
|
|
|
|
"Toggle Neotree in project root."
|
|
|
|
(interactive)
|
|
|
|
(let ((default-directory (find-project-root)))
|
|
|
|
(call-interactively 'neotree-toggle)))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
* Advice and Aliases
|
|
|
|
** Advice
|
|
|
|
|
|
|
|
Define default terminal option.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(defvar terminal-shell "/bin/zsh")
|
|
|
|
(defadvice ansi-term (before force-bash)
|
|
|
|
(interactive (list terminal-shell)))
|
|
|
|
(ad-activate 'ansi-term)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Aliases
|
|
|
|
|
|
|
|
*** General
|
|
|
|
|
|
|
|
Make confirm easier, by just pressing y/n.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(defalias 'yes-or-no-p 'y-or-n-p)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
*** Package
|
|
|
|
|
|
|
|
Evil command aliases.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(with-eval-after-load 'evil-ex
|
|
|
|
(evil-ex-define-cmd "W" "w")
|
|
|
|
(evil-ex-define-cmd "Q" "q")
|
|
|
|
(evil-ex-define-cmd "WQ" "wq")
|
|
|
|
(evil-ex-define-cmd "Wq" "wq"))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
* Hooks
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
;; Delete trailing whitespace
|
|
|
|
(add-hook 'before-save-hook 'delete-trailing-whitespace)
|
|
|
|
|
|
|
|
;; Highlight parenthesis
|
|
|
|
(add-hook 'prog-mode-hook 'show-paren-mode)
|
|
|
|
|
|
|
|
;; Enable 'table of contents' in org
|
|
|
|
(add-hook 'org-mode-hook 'toc-org-mode)
|
|
|
|
|
|
|
|
;; C++ // style comments in c-mode
|
|
|
|
(add-hook 'c-mode-hook (lambda () (c-toggle-comment-style 0)))
|
|
|
|
|
|
|
|
;; LaTeX, set correct tab mode
|
|
|
|
(add-hook 'latex-mode-hook (lambda () (setq indent-tabs-mode t)))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
* Key Bindings
|
|
|
|
|
|
|
|
Useful links:\\
|
|
|
|
[[https://www.masteringemacs.org/article/mastering-key-bindings-emacs][Mastering Emacs key bindings]] \\
|
|
|
|
[[https://github.com/jwiegley/use-package/blob/master/bind-key.el][use-package bind key]] \\
|
|
|
|
[[https://www.gnu.org/software/emacs/manual/html_node/elisp/Remapping-Commands.html][GNU remapping commands]] \\
|
|
|
|
[[https://www.gnu.org/software/emacs/manual/html_node/efaq/Binding-combinations-of-modifiers-and-function-keys.html][GNU binding combinations of modifiers]] \\
|
|
|
|
[[https://github.com/hlissner/doom-emacs/blob/develop/modules/config/default/+evil-bindings.el][Doom Emacs bindings]]
|
|
|
|
|
|
|
|
** Disable Default
|
|
|
|
|
|
|
|
Disable keybinds of default modes that clash with the custom keybinds below.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(with-eval-after-load 'org
|
|
|
|
(define-key org-mode-map (kbd "M-h") nil)
|
|
|
|
(define-key org-mode-map (kbd "C-M-h") nil))
|
|
|
|
|
|
|
|
(with-eval-after-load 'cc-mode
|
|
|
|
(define-key c-mode-base-map (kbd "M-j") nil)
|
|
|
|
(define-key c-mode-base-map (kbd "C-M-h") nil))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Disable Package
|
|
|
|
|
|
|
|
Disable keybinds of installed packages that clash with the custom keybinds below.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(with-eval-after-load 'evil-states
|
|
|
|
(define-key evil-motion-state-map (kbd dot/leader-key) nil))
|
|
|
|
|
|
|
|
(with-eval-after-load 'php-mode
|
|
|
|
(define-key php-mode-map (kbd "M-j") nil)
|
|
|
|
(define-key php-mode-map (kbd "C-M-h") nil))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Set Default
|
|
|
|
|
|
|
|
Set custom keybinds to functionality of default modes.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
;; Buffers
|
|
|
|
(global-set-key (kbd "C-x b") 'ido-switch-buffer)
|
|
|
|
(global-set-key (kbd "C-x C-b") 'ibuffer)
|
|
|
|
(global-set-key (kbd "M-w") 'kill-this-buffer)
|
|
|
|
|
|
|
|
;; Config edit/reload
|
|
|
|
(global-set-key (kbd "C-c r") 'config-reload)
|
|
|
|
(global-set-key (kbd "C-c v") 'config-visit)
|
|
|
|
|
|
|
|
;; Split and follow window
|
|
|
|
(global-set-key (kbd "C-x 2") 'split-follow-horizontally)
|
|
|
|
(global-set-key (kbd "C-x 3") 'split-follow-vertically)
|
|
|
|
|
|
|
|
;; Find file
|
|
|
|
(global-set-key (kbd "C-x C-f") 'find-file-in-project-root)
|
|
|
|
|
|
|
|
;; Terminal
|
|
|
|
(global-set-key (kbd "<s-backspace>") 'ansi-term)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Set Package
|
|
|
|
|
|
|
|
Set custom keybinds to functionality of custom packages.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
;; Buffers
|
|
|
|
(global-set-key (kbd "M-h") 'centaur-tabs-backward-tab)
|
|
|
|
(global-set-key (kbd "M-j") 'centaur-tabs-forward-group)
|
|
|
|
(global-set-key (kbd "M-k") 'centaur-tabs-backward-group)
|
|
|
|
(global-set-key (kbd "M-l") 'centaur-tabs-forward-tab)
|
|
|
|
(global-set-key (kbd "C-M-h") 'centaur-tabs-move-current-tab-to-left)
|
|
|
|
(global-set-key (kbd "C-M-l") 'centaur-tabs-move-current-tab-to-right)
|
|
|
|
(global-set-key (kbd "M-\`") 'evil-switch-to-windows-last-buffer)
|
|
|
|
|
|
|
|
(global-set-key (kbd "M-s") 'avy-goto-char-timer)
|
|
|
|
(global-set-key (kbd "M-x") 'smex)
|
|
|
|
|
|
|
|
;; Company completion selection
|
|
|
|
(with-eval-after-load 'company
|
|
|
|
(define-key company-active-map (kbd "M-n") nil)
|
|
|
|
(define-key company-active-map (kbd "M-p") nil)
|
|
|
|
(define-key company-active-map (kbd "M-h") #'company-abort)
|
|
|
|
(define-key company-active-map (kbd "M-j") #'company-select-next)
|
|
|
|
(define-key company-active-map (kbd "M-k") #'company-select-previous)
|
|
|
|
(define-key company-active-map (kbd "M-l") #'company-complete-selection)
|
|
|
|
(define-key company-active-map (kbd "<escape>") #'company-abort))
|
|
|
|
; https://github.com/company-mode/company-mode/blob/master/company.el#L661
|
|
|
|
|
|
|
|
;; Evil command history selection
|
|
|
|
(with-eval-after-load 'evil-ex
|
|
|
|
(define-key evil-ex-completion-map (kbd "M-h") 'abort-recursive-edit)
|
|
|
|
(define-key evil-ex-completion-map (kbd "M-j") #'next-complete-history-element)
|
|
|
|
(define-key evil-ex-completion-map (kbd "M-k") #'previous-complete-history-element)
|
|
|
|
(define-key evil-ex-completion-map (kbd "M-l") 'exit-minibuffer))
|
|
|
|
|
|
|
|
; Overwrite evil keymaps
|
|
|
|
;(evil-global-set-key 'motion (kbd "C-w") 'kill-this-buffer)
|
|
|
|
;(evil-define-key 'motion 'global (kbd "C-w") 'kill-this-buffer)
|
|
|
|
;(define-key evil-motion-state-map (kbd "C-w") 'kill-this-buffer) ; @Todo test this with nil
|
|
|
|
;https://github.com/noctuid/evil-guide#global-keybindings-and-evil-states
|
|
|
|
|
|
|
|
(with-eval-after-load 'evil-states
|
|
|
|
;; Global evil keymap
|
|
|
|
(general-def evil-normal-state-map
|
|
|
|
"C-n" 'neotree-toggle-in-project-root)
|
|
|
|
|
|
|
|
;; Neotree
|
|
|
|
(general-def 'normal neotree-mode-map
|
|
|
|
"RET" 'neotree-enter
|
|
|
|
"<backtab>" 'neotree-collapse-all ; <S-tab>
|
|
|
|
"c" 'neotree-create-node
|
|
|
|
"r" 'neotree-rename-node
|
|
|
|
"d" 'neotree-delete-node
|
|
|
|
"h" 'neotree-select-previous-sibling-node
|
|
|
|
"j" 'neotree-next-line
|
|
|
|
"k" 'neotree-previous-line
|
|
|
|
"l" 'neotree-enter
|
|
|
|
"R" 'neotree-refresh
|
|
|
|
"C" 'neotree-change-root
|
|
|
|
"H" 'neotree-hidden-file-toggle
|
|
|
|
"q" 'neotree-hide
|
|
|
|
)
|
|
|
|
|
|
|
|
;; Dashboard
|
|
|
|
(general-def 'normal dashboard-mode-map
|
|
|
|
[down-mouse-1] 'widget-button-click
|
|
|
|
"g" 'dashboard-refresh-buffer
|
|
|
|
"m" 'dashboard-goto-bookmarks
|
|
|
|
"p" 'dashboard-goto-projects
|
|
|
|
"r" 'dashboard-goto-recent-files
|
|
|
|
)
|
|
|
|
|
|
|
|
;; Org
|
|
|
|
(general-def 'normal org-mode-map
|
|
|
|
"RET" 'dot/org-ret-at-point)
|
|
|
|
|
|
|
|
;; Elfeed
|
|
|
|
(general-def 'normal elfeed-search-mode-map
|
|
|
|
"b" 'elfeed-search-browse-url
|
|
|
|
"c" 'elfeed-search-clear-filter
|
|
|
|
"gr" '(elfeed-search-update--force :which-key "Refresh buffer")
|
|
|
|
"gR" '(elfeed-search-fetch :which-key "Update feeds")
|
|
|
|
"q" 'kill-this-buffer
|
|
|
|
"u" 'elfeed-search-tag-all-unread
|
|
|
|
"U" nil
|
|
|
|
"r" 'elfeed-search-untag-all-unread
|
|
|
|
)
|
|
|
|
|
|
|
|
(general-def 'normal elfeed-show-mode-map
|
|
|
|
"b" #'elfeed-show-visit
|
|
|
|
"g" 'elfeed-show-refresh
|
|
|
|
"q" 'kill-this-buffer
|
|
|
|
"u" #'elfeed-show-tag--unread
|
|
|
|
"y" #'elfeed-show-yank
|
|
|
|
))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
** Leader
|
|
|
|
|
|
|
|
General.el ~leader key binds.
|
|
|
|
|
|
|
|
*** Global Leader
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(general-create-definer space-leader
|
|
|
|
:prefix dot/leader-key
|
|
|
|
:non-normal-prefix dot/leader-alt-key
|
|
|
|
:global-prefix dot/leader-alt-key
|
|
|
|
:states '(normal visual insert motion emacs))
|
|
|
|
|
|
|
|
(space-leader
|
|
|
|
"SPC" '(smex :which-key "Smex")
|
|
|
|
"RET" '(bookmark-jump-ido :which-key "Jump to bookmark")
|
|
|
|
|
|
|
|
;; Buffer / bookmark
|
|
|
|
"b" '(:ignore t :which-key "buffer/bookmark")
|
|
|
|
"b a" '(auto-revert-mode :which-key "Auto revert buffer")
|
|
|
|
"b b" '(ido-switch-buffer :which-key "Switch buffer")
|
|
|
|
"b B" '(ibuffer :which-key "List buffers")
|
|
|
|
"b d" '(kill-current-buffer :which-key "Kill buffer")
|
|
|
|
"b h" '(previous-buffer :which-key "Previous buffer")
|
|
|
|
"b k" '(kill-current-buffer :which-key "Kill buffer")
|
|
|
|
"b l" '(next-buffer :which-key "Next buffer")
|
|
|
|
"b m" '(bookmark-set :which-key "Make bookmark")
|
|
|
|
"b M" '(bookmark-delete-ido :which-key "Delete bookmark")
|
|
|
|
"b n" '(evil-buffer-new :which-key "New empty buffer")
|
|
|
|
"b r" '(revert-buffer :which-key "Revert buffer")
|
|
|
|
"b s" '(basic-save-buffer :which-key "Save buffer")
|
|
|
|
"b S" '(evil-write-all :which-key "Save all buffers")
|
|
|
|
"b <left>" '(previous-buffer :which-key "Previous buffer")
|
|
|
|
"b <right>" '(next-buffer :which-key "Next buffer")
|
|
|
|
|
|
|
|
;; Comments / config
|
|
|
|
"c" '(:ignore t :which-key "comment/config")
|
|
|
|
"c c" '(evilnc-comment-or-uncomment-lines :which-key "Toggle comment")
|
|
|
|
"c p" '(evilnc-comment-or-uncomment-paragraphs :which-key "Toggle comment paragraph")
|
|
|
|
"c r" '(config-reload :which-key "Config reload")
|
|
|
|
"c v" '(config-visit :which-key "Config visit")
|
|
|
|
"c y" '(evilnc-comment-and-kill-ring-save :which-key "Comment and copy")
|
|
|
|
|
|
|
|
;; Elisp
|
|
|
|
"e" '(:ignore t :which-key "elisp")
|
|
|
|
"e b" '(eval-buffer :which-key "Evaluate buffer")
|
|
|
|
"e e" '(eval-last-sexp :which-key "Evaluate last sexp")
|
|
|
|
"e r" '(eval-region :which-key "Evaluate region")
|
|
|
|
|
|
|
|
;; Find file
|
|
|
|
"f" '(:ignore t :which-key "file")
|
|
|
|
"f f" '(find-file-in-project-root :which-key "Find file")
|
|
|
|
"f r" '(recentf-open-files :which-key "Recent files")
|
|
|
|
"f R" '(rename-file-and-buffer :which-key "Rename file")
|
|
|
|
"f s" '(basic-save-buffer :which-key "Save file")
|
|
|
|
"f S" '(write-file :which-key "Save file as...")
|
|
|
|
"f u" '(dot/sudo-find-file :which-key "Sudo find file")
|
|
|
|
"f U" '(dot/sudo-this-file :which-key "Sudo this file")
|
|
|
|
|
|
|
|
;; Help
|
|
|
|
"h" '(help-command :which-key "help")
|
|
|
|
"h o" '(dot/describe-symbol-at-point :which-key "describe-symbol-at-point")
|
|
|
|
|
|
|
|
;; Insert
|
|
|
|
"i" '(:ignore t :which-key "insert")
|
|
|
|
"i b" '(dot/indent-buffer :which-key "Indent buffer")
|
|
|
|
"i r" '(indent-region :which-key "Indent region")
|
|
|
|
"i s" '(yas-insert-snippet :which-key "Insert snippet")
|
|
|
|
|
|
|
|
;; Neotree
|
|
|
|
"n" '(neotree-toggle-in-project-root :which-key "Toggle Neotree")
|
|
|
|
|
|
|
|
;; Projectile
|
|
|
|
"p" '(:keymap projectile-command-map :which-key "projectile")
|
|
|
|
|
|
|
|
;; Quit
|
|
|
|
"q" '(:ignore t :which-key "quit")
|
|
|
|
"q q" '(save-buffers-kill-terminal :which-key "Quit Emacs")
|
|
|
|
"q Q" '(save-buffers-kill-emacs :which-key "Quit Emacs (and daemon)")
|
|
|
|
"q f" '(delete-frame :which-key "Close frame")
|
|
|
|
"q o" '(delete-other-frames :which-key "Close other frames")
|
|
|
|
|
|
|
|
;; Search
|
|
|
|
"s" '(:ignore t :which-key "search")
|
|
|
|
"s a" '(avy-goto-char-timer :which-key "Avy goto char")
|
|
|
|
"s b" '(bookmark-jump-ido :which-key "Jump to bookmark")
|
|
|
|
|
|
|
|
;; Tabs
|
|
|
|
"t" '(:ignore t :which-key "tabs")
|
|
|
|
"t b" '(centaur-tabs-group-buffer-groups :which-key "Group tabs by buffer")
|
|
|
|
"t p" '(centaur-tabs-group-by-projectile-project :which-key "Group tabs by project")
|
|
|
|
"t h" '(centaur-tabs-backward-group :which-key "Tab backward group")
|
|
|
|
"t j" '(centaur-tabs-select-end-tab :which-key "Tab select first")
|
|
|
|
"t k" '(centaur-tabs-select-beg-tab :which-key "Tab select last")
|
|
|
|
"t l" '(centaur-tabs-forward-group :which-key "Tab forward group")
|
|
|
|
|
|
|
|
;; Update packages
|
|
|
|
"u" '(auto-package-update-now :which-key "Update packages")
|
|
|
|
|
|
|
|
;; Window
|
|
|
|
;; "w" '(:keymap evil-window-map :which-key "window")
|
|
|
|
"w" '(:ignore t :which-key "window")
|
|
|
|
"w =" '(balance-windows-area :which-key "Balance windows area")
|
|
|
|
"w h" '(windmove-left :which-key "Focus window left")
|
|
|
|
"w j" '(windmove-down :which-key "Focus window down")
|
|
|
|
"w k" '(windmove-up :which-key "Focus window up")
|
|
|
|
"w l" '(windmove-right :which-key "Focus window right")
|
|
|
|
"w o" '(delete-other-windows :which-key "Close other windows")
|
|
|
|
"w s" '(:ignore t :which-key "split")
|
|
|
|
"w s h" '(split-follow-horizontally :which-key "Split horizontal")
|
|
|
|
"w s v" '(split-follow-vertically :which-key "Split vertical")
|
|
|
|
"w w" '(other-window :which-key "Focus other window")
|
|
|
|
"w q" '(delete-window :which-key "Close window")
|
|
|
|
"w <left>" '(windmove-left :which-key "Focus window left")
|
|
|
|
"w <right>" '(windmove-right :which-key "Focus window right")
|
|
|
|
"w <up>" '(windmove-up :which-key "Focus window up")
|
|
|
|
"w <down>" '(windmove-down :which-key "Focus window down")
|
|
|
|
;; winner-redo (built-in window history)
|
|
|
|
;; winner-undo
|
|
|
|
|
|
|
|
"x" '(smex-major-mode-commands :which-key "Smex major mode")
|
|
|
|
)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
Evaluated keybinds.
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(with-eval-after-load 'lsp-mode
|
|
|
|
(space-leader lsp-mode-map
|
|
|
|
"l" lsp-command-map
|
|
|
|
)
|
|
|
|
)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
Source:
|
|
|
|
https://github.com/redguardtoo/emacs.d/blob/master/lisp/init-evil.el#L712
|
|
|
|
https://github.com/suyashbire1/emacs.d/blob/master/init.el
|
|
|
|
|
|
|
|
*** Local Leader
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(general-create-definer local-leader
|
|
|
|
:prefix dot/localleader-key
|
|
|
|
:non-normal-prefix dot/localleader-alt-key
|
|
|
|
:global-prefix dot/localleader-alt-key
|
|
|
|
:states '(normal visual insert motion emacs)
|
|
|
|
)
|
|
|
|
|
|
|
|
(which-key-add-key-based-replacements dot/localleader-key "<localleader>")
|
|
|
|
(which-key-add-key-based-replacements dot/localleader-alt-key "<localleader>")
|
|
|
|
|
|
|
|
(local-leader org-mode-map
|
|
|
|
"'" '(org-edit-special :which-key "Org edit")
|
|
|
|
"c" '(org-edit-special :which-key "Org edit")
|
|
|
|
"e" '(org-export-dispatch :which-key "Org export")
|
|
|
|
"l" '(org-insert-link :which-key "Org make link")
|
|
|
|
"o" '(org-open-at-point :which-key "Org open at point")
|
|
|
|
|
|
|
|
"i" '(:ignore t :which-key "insert")
|
|
|
|
"i h" '(org-insert-heading :which-key "Org insert heading")
|
|
|
|
|
|
|
|
"s" '(:ignore t :which-key "tree/subtree")
|
|
|
|
"s h" '(org-promote-subtree :which-key "Org promote subtree")
|
|
|
|
"s j" '(org-move-subree-down :which-key "Org move subtree down")
|
|
|
|
"s k" '(org-move-subtree-up :which-key "Org move subtree up")
|
|
|
|
"s l" '(org-demote-subtree :which-key "Org demote subtree")
|
|
|
|
"s <left>" '(org-promote-subtree :which-key "Org promote subtree")
|
|
|
|
"s <right>" '(org-demote-subtree :which-key "Org demote subtree")
|
|
|
|
"s <up>" '(org-move-subree-up :which-key "Org move subtree up")
|
|
|
|
"s <down>" '(org-move-subtree-down :which-key "Org move subtree down")
|
|
|
|
)
|
|
|
|
|
|
|
|
(local-leader org-src-mode-map
|
|
|
|
"'" '(org-edit-src-exit :which-key "Org exit edit")
|
|
|
|
"c" '(org-edit-src-exit :which-key "Org exit edit")
|
|
|
|
"k" '(org-edit-src-abort :which-key "Org abort edit")
|
|
|
|
)
|
|
|
|
|
|
|
|
(define-key org-src-mode-map (kbd "C-c C-c") #'org-edit-src-exit)
|
|
|
|
|
|
|
|
(local-leader elfeed-search-mode-map
|
|
|
|
"g" '(elfeed-search-update--force :which-key "Elfeed refresh buffer")
|
|
|
|
"G" '(elfeed-search-fetch :which-key "Elfeed update feeds")
|
|
|
|
)
|
|
|
|
|
|
|
|
(local-leader elfeed-show-mode-map
|
|
|
|
"g" '(elfeed-show-refresh :which-key "Elfeed refresh buffer")
|
|
|
|
)
|
|
|
|
|
|
|
|
;; c-fill-paragraph Reflow comment
|
|
|
|
;; https://youtu.be/hbmV1bnQ-i0?t=1910
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
* Notes
|
|
|
|
|
|
|
|
Org mode keybinds:
|
|
|
|
|
|
|
|
| Keystroke | Description | Function |
|
|
|
|
|----------------+----------------------------+--------------------------------------|
|
|
|
|
| <C-c C-c> | Update tags/headline | (org-ctrl-c-ctrl-c) |
|
|
|
|
| <C-return> | Insert heading | (org-insert-heading-respect-content) |
|
|
|
|
| <C-x n s> | ? | (org-narrow-to-subtree) |
|
|
|
|
| <C-x n w> | ? | (widen) |
|
|
|
|
| <M-return> | Insert heading | (org-meta-return) |
|
|
|
|
| <M-S-return> | Insert todo heading | (org-insert-todo-heading) |
|
|
|
|
| <M-down> | Move subtree down | (org-metadown) |
|
|
|
|
| <M-left> | Promote heading | (org-metaleft) |
|
|
|
|
| <M-right> | Demote heading | (org-metaright) |
|
|
|
|
| <M-up> | Move subtree up | (org-metaup) |
|
|
|
|
| <S-left/right> | Cycle to next todo keyword | (org-shiftleft/org-shiftright) |
|
|
|
|
| <S-up/down> | Cycle todo priority | (org-shiftup/org-shiftdown) |
|