30 KiB
Ricemacs, an Emacs Configuration
- Initial setup
- Customizations
- Package Management
- General
- Functions
- Advice and Aliases
- Hooks
- Key Bindings
- 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.
(setq custom-file "~/.emacs.d/custom.el")
(load custom-file 'noerror)
Set custom faces, without using customize.
(set-face-attribute 'default nil :height 90 :family "DejaVu Sans Mono")
Package Management
Ensure
Ensures packages are installed by default.
(require 'use-package-ensure)
(setq use-package-always-ensure t)
Auto update
Update pending updates of installed packages at startup. https://github.com/rranelli/auto-package-update.el
(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))
Compile
Automatically compile all packages. https://github.com/emacscollective/auto-compile
(use-package auto-compile
:custom (load-prefer-newer t)
:config
(auto-compile-on-load-mode)
(auto-compile-on-save-mode))
Packages
Install and configure packages.
General
(use-package color-theme-sanityinc-tomorrow
:config
(load-theme 'sanityinc-tomorrow-night t)
(color-theme-sanityinc-tomorrow--with-colors 'night
(custom-theme-set-faces
'sanityinc-tomorrow-night
`(highlight ((t (:foreground ,yellow :background ,background))))
`(lazy-highlight ((t (:foreground ,highlight :background ,comment))))
`(line-number-current-line ((t (:foreground ,yellow :background "#222427"))))
`(show-paren-match ((t (:background ,yellow))))
`(cursor ((t (:background ,foreground))))
`(font-lock-keyword-face ((t (:foreground ,green))))
`(font-lock-string-face ((t (:foreground ,aqua))))
`(ivy-current-match ((t (:foreground ,orange))))
`(ivy-cursor ((t (:background ,foreground))))
)))
(use-package which-key
:custom
(which-key-add-column-padding 1)
(which-key-max-display-columns nil)
(which-key-min-display-lines 6)
(which-key-sort-order 'which-key-prefix-then-key-order)
(which-key-sort-uppercase-first nil)
:config (which-key-mode))
(use-package general
:after which-key)
(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))
Evil
Evil mode and related packages.
(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 mode
(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 '("M-h" "M-l" "SPC"))
(evil-collection-setup-minibuffer t)
:config (evil-collection-init))
(use-package evil-nerd-commenter
:after evil)
Telephone Line
Emacs mode line replacement.
(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))
(nil . (telephone-line-buffer-segment
telephone-line-projectile-segment))))
:custom-face
(telephone-line-evil ((t (:weight normal))))
(telephone-line-evil-normal ((t (:background "#87afd7" :foreground "black"))))
(telephone-line-evil-insert ((t (:background "#b5bd68" :foreground "black"))))
(telephone-line-evil-visual ((t (:background "#b294bb" :foreground "black"))))
(telephone-line-evil-replace ((t (:background "#282a2e" :foreground "white"))))
(telephone-line-evil-motion ((t (:background "#8abeb7" :foreground "black"))))
(telephone-line-evil-operator ((t (:background "#de935f" :foreground "black"))))
(telephone-line-evil-emacs ((t (:background "#b294bb" :foreground "black"))))
(telephone-line-projectile ((t (:foreground "default"))))
:config (telephone-line-mode))
NeoTree
Collect icon fonts and propertize them within Emacs
(requires M-x all-the-icons-install-fonts
).
(use-package memoize)
(use-package all-the-icons
:after memoize)
Provides Emacs with a file tree.
(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)
:hook (neotree-mode . (lambda (&rest _) (display-line-numbers-mode 0))))
Centaur Tabs
Places buffers as tabs in a bar at the top.
(use-package centaur-tabs
:custom
(centaur-tabs-background-color "#282a2e")
(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)
:custom-face
(centaur-tabs-default ((t (:background "#282a2e" :foreground "#282a2e"))))
(centaur-tabs-selected ((t (:background "#373b41" :foreground "white"))))
(centaur-tabs-unselected ((t (:background "#282a2e" :foreground "#c5c8c6"))))
:config
(centaur-tabs-mode))
Projectile
Project manager.
(use-package projectile
:custom
(projectile-enable-caching t)
(projectile-indexing-method 'hybrid)
(projectile-project-search-path '("~"))
(projectile-sort-order 'recentf)
:config (projectile-mode))
Org
(use-package htmlize
:custom (org-export-html-postamble nil))
;org-export-html-postamble-format @ToDo
(use-package ox-gfm)
Completion
Autocomplete packages (includes code completion and snippets).
Company
(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)
)
Flycheck
On the fly syntax checking.
(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))
LSP
(use-package lsp-mode
:defer t
: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)
:commands lsp)
(use-package company-lsp
:after company lsp-mode
:custom
(company-transformers nil)
(company-lsp-async t)
(company-lsp-cache-candidates nil)
(company-lsp-enable-snippet t)
:commands company-lsp
:config (push 'company-lsp company-backends))
(use-package lsp-ui
:after flycheck lsp-mode
:hook (lsp-mode . lsp-ui-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-sideline-enable nil)
(lsp-ui-sideline-ignore-duplicate t)
(lsp-ui-sideline-show-code-actions nil)
(lsp-ui-flycheck-enable t)
(lsp-ui-flycheck-list-position 'right)
(lsp-ui-flycheck-live-reporting t)
(lsp-ui-peek-enable nil)
(lsp-ui-peek-list-width 60)
(lsp-ui-peek-peek-height 25)
:commands lsp-ui-mode)
YASnippet
(use-package yasnippet
:defer t
:hook
((org-mode
prog-mode)
. yas-minor-mode)
:config (yas-reload-all))
(use-package yasnippet-snippets
:after yasnippet)
C/C++
Irony requires M-x irony-install-server
.
(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
Prettify
(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))
Possible modern replacement for column-enforce-mode: https://github.com/laishulu/hl-fill-column
General
;; Scrolling
(setq scroll-conservatively 1)
(setq mouse-wheel-scroll-amount '(5))
(setq mouse-wheel-progressive-speed nil)
;; Columns start at 1
(setq column-number-indicator-zero-based nil)
;; Automatically add newline on save at the end of the file
(setq require-final-newline t)
;; 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))
Buffers
;; 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)
Electric
;; Make return key also do indent of previous line
(electric-indent-mode 1)
(setq electric-pair-pairs '(
(?\( . ?\))
(?\[ . ?\])
))
(electric-pair-mode 1)
File Backups
File auto-saves, backups, tramps.
(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) ; ,,
Hide Elements
(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)
Org
;; Org
(with-eval-after-load 'org
(add-to-list 'org-structure-template-alist
'("el" "#+BEGIN_SRC emacs-lisp\n?\n#+END_SRC")))
(setq org-ellipsis " ↴")
(setq org-src-fontify-natively t)
(setq org-src-window-setup 'current-window)
(setq org-latex-toc-command "\\newpage \\tableofcontents \\newpage")
;; Enable syntax highlighting when exporting to .pdf
;; Include latex-exporter
(with-eval-after-load 'ox-latex
;; Add minted to the list of packages to insert in every LaTeX header
(add-to-list 'org-latex-packages-alist '("" "minted"))
;; Define how minted is added to source code
(setq org-latex-listings 'minted)
(setq org-latex-minted-options
'(("frame" "lines") ("linenos=true")))
;; 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)))
Tabs
;; 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
c-default-style "linux")
UTF-8
Set UTF-8 encoding as default.
(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)
Functions
General
Functions that only use built-in Emacs functionality.
(defun config-visit ()
"Config edit."
(interactive)
(find-file "~/.emacs.d/config.org"))
(defun config-reload ()
"Config reload."
(interactive)
(org-babel-load-file (expand-file-name "~/.emacs.d/config.org")))
(defun display-startup-echo-area-message ()
"Hide default startup message."
(message ""))
(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 ()
"Returns 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)))))))
;; https://emacsredux.com/blog/2013/04/21/edit-files-as-root/
(defun sudo-edit (&optional arg)
"Edit currently visited file as root.
With a prefix ARG prompt for a file to visit.
Will also prompt for a file to visit if current
buffer is not visiting a file."
(interactive "P")
(if (or arg (not buffer-file-name))
(find-file (concat "/sudo:root@localhost:"
(read-file-name "Find file(as root): ")))
(find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name))))
Package
Functions that use package functionality.
(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)))
Advice and Aliases
Advice
Define default terminal option.
(defvar terminal-shell "/bin/zsh")
(defadvice ansi-term (before force-bash)
(interactive (list terminal-shell)))
(ad-activate 'ansi-term)
Aliases
General
Make confirm easier, by just pressing y/n.
(defalias 'yes-or-no-p 'y-or-n-p)
Package
Evil command aliases.
(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"))
Hooks
;; Delete trailing whitespace
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;; Highlight parentheses
(add-hook 'prog-mode-hook 'show-paren-mode)
;; C++ // style comments in c-mode
(add-hook 'c-mode-hook (lambda () (c-toggle-comment-style 0)))
;; PHP, set correct tab mode
(add-hook 'php-mode-hook (lambda () (setq indent-tabs-mode t)))
Key Bindings
Useful links:
Mastering Emacs key bindings
use-package bind key
GNU remapping commands
GNU binding combinations of modifiers
Disable default
(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 "C-M-h") nil))
Default
;; 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)
Disable package
Disable spacebar in evil motion.
(with-eval-after-load 'evil-states
(define-key evil-motion-state-map (kbd "<SPC>") nil))
(with-eval-after-load 'php-mode
(define-key php-mode-map (kbd "C-M-h") nil))
Package
;; Buffers
(global-set-key (kbd "M-h") 'centaur-tabs-backward-tab)
(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)
;; 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
(general-define-key
:keymaps 'evil-normal-state-map
;; Neotree
"C-n" 'neotree-toggle-in-project-root)
(general-define-key
:states 'normal
:keymaps '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-define-key
:states 'normal
:keymaps '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
))
Leader
General.el ~leader key binds.
(with-eval-after-load 'general
(general-create-definer space-leader
:prefix "SPC"
:non-normal-prefix "M-SPC"
:global-prefix "M-SPC"
:states '(normal visual insert motion emacs))
(general-create-definer comma-leader
:prefix ","
:states '(normal visual))
(space-leader
"SPC" '(smex :which-key "Smex")
"RET" '(bookmark-jump :which-key "Jump to bookmark")
;; Buffer / bookmark
"b" '(:ignore t :which-key "buffer/bookmark")
"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 :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 save")
;; LSP
"d" '(:ignore t :which-key "lsp")
"d c" '(lsp-describe-thing-at-point :which-key "LSP Describe under cursor")
"d d" '(lsp-find-definition :which-key "LSP Find definition")
"d e" '(lsp-execute-code-action :which-key "LSP Execute code action")
"d f" '(lsp-format-region-or-buffer :which-key "LSP Format region/buffer")
"d r" '(lsp-find-references :which-key "LSP Find references")
"d R" '(lsp-rename :which-key "LSP Rename")
"d s" '(lsp :which-key "Start LSP")
;; Find file
"f" '(:ignore t :which-key "file")
"f f" '(find-file-in-project-root :which-key "Find file")
"f r" '(rename-file-and-buffer :which-key "Rename file")
"f s" '(basic-save-buffer :which-key "Save file")
;; Tabs
"h" '(centaur-tabs-backward-group :which-key "Tab backward group")
"j" '(centaur-tabs-select-end-tab :which-key "Tab select first")
"k" '(centaur-tabs-select-beg-tab :which-key "Tab select last")
"l" '(centaur-tabs-forward-group :which-key "Tab forward group")
;; 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-frame :which-key "Close other frame")
;; Reformat region
"r" '(:ignore t :which-key "region")
"r r" '(indent-region :which-key "Indent region")
;; Search
"s" '(:ignore t :which-key "search")
"s a" '(avy-goto-char-timer :which-key "Avy goto char")
"s b" '(bookmark-jump :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")
;; 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 h" '(evil-window-left :which-key "Focus window left")
"w j" '(evil-window-down :which-key "Focus window down")
"w k" '(evil-window-up :which-key "Focus window up")
"w l" '(evil-window-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>" '(evil-window-left :which-key "Focus window left")
"w <right>" '(evil-window-right :which-key "Focus window down")
"w <up>" '(evil-window-up :which-key "Focus window up")
"w <down>" '(evil-window-down :which-key "Focus window right")
"x" '(smex-major-mode-commands :which-key "Smex major mode")
))
Source: https://github.com/redguardtoo/emacs.d/blob/master/lisp/init-evil.el#L712 https://github.com/suyashbire1/emacs.d/blob/master/init.el
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) |