This is my EMACS configuration.
- IMPORTANT! BEFORE RUNNING EMACS
- PACKAGE MANAGEMENT
- STARTUP
- EVIL MODE
- NEEDED MODULES
- KEYBINDINGS
- FONTS
- GRAPHICAL USER INTERFACE
- THEME
- CENTAUR TABS
- MODELINE
- DASHBOARD
- DIRED
- MAGIT
- ORG MODE
- VTERM
- IVY
- TREEMACS
- PROGRAMMING
- CREDITS
IMPORTANT!
Before everything else, put this line in your empty init.el
.
(org-babel-load-file (expand-file-name "config.org" user-emacs-directory))
Setup package.el
(require 'package)
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
("org" . "https://orgmode.org/elpa/")
("elpa" . "https://elpa.gnu.org/packages/")))
(package-refresh-contents)
(package-initialize)
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(require 'use-package)
(setq use-package-always-ensure t)
(add-to-list 'load-path "~/.emacs.d/lisp")
Important startup settings.
;; Using garbage magic hack.
(use-package gcmh
:config (gcmh-mode 1))
;; Setting garbage collection threshold
(setq gc-cons-threshold 402653184
gc-cons-percentage 0.6)
;; Profile emacs startup
(add-hook 'emacs-startup-hook
(lambda ()
(message "*** Emacs loaded in %s with %d garbage collections."
(format "%.2f seconds"
(float-time
(time-subtract after-init-time before-init-time)))
gcs-done)))
;; Silence compiler warnings as they can be pretty disruptive
(setq comp-async-report-warnings-errors nil)
Vim Keybindings
(use-package evil
:init
(setq evil-want-integration t
evil-want-keybinding nil
evil-split-window-below t
evil-vsplit-window-right t
evil-undo-system 'undo-redo)
(evil-mode))
(use-package evil-collection
:after evil
:config
(setq evil-collection-mode-list '(dashboard dired ibuffer))
(evil-collection-init))
(use-package evil-tutor)
A plugin that shows you available options while doing shortcuts.
(use-package which-key
:init
(setq which-key-sort-order 'which-key-prefix-then-key-order
which-key-sort-uppercase-first nil
which-key-min-display-lines 6
which-key-add-column-padding 4)
(which-key-mode))
Smart projects management plugins.
(use-package projectile
:diminish projectile-mode
:config (projectile-mode)
:custom (projectile-completion-system 'ivy))
(use-package counsel-projectile
:after projectile
:config (counsel-projectile-mode))
Allows to edit sudo files.
(use-package sudo-edit) ; Utilities for opening files with sudo
There are the keybindings.
(use-package general
:after evil
:config (general-evil-setup t))
(nvmap :keymaps 'override :prefix "SPC"
"SPC" '(counsel-M-x :which-key "M-x")
"RET" '(project-compile :which-key "RET")
"<tab>" '(org-open-at-point :which-key "M-x")
"h r r" '((lambda () (interactive) (load-file "~/.emacs.d/init.el")) :which-key "Reload emacs config")
"e" '(treemacs :which-key "Explorer")
"g" '(magit-status :which-key "Magit")
"s" '(swiper :which-key "Swiper")
"t" '(vterm-toggle :which-key "Terminal")
;; Buffers
"b b" '(ivy-switch-buffer :which-key "Switch Buffer")
"b c" '(counsel-switch-buffer-other-window :which-key "Switch Buffer into a new window")
"b i" '(ibuffer :which-key "Ibuffer")
"b k" '(kill-current-buffer :which-key "Kill current buffer")
"b n" '(next-buffer :which-key "Next buffer")
"b p" '(previous-buffer :which-key "Previous buffer")
"b K" '(kill-buffer :which-key "Kill buffer in list")
;; File Management
"." '(find-file :which-key "Find file")
"f f" '(peep-dired :which-key "Peep Dired")
"f j" '(dired-jump :which-key "Dired Jump")
"f r" '(counsel-recentf :which-key "Recent files")
"f s" '(save-buffer :which-key "Save file")
"f u" '(sudo-edit-find-file :which-key "Sudo find file")
"f C" '(copy-file :which-key "Copy file")
"f D" '(delete-file :which-key "Delete file")
"f R" '(rename-file :which-key "Rename file")
"f S" '(write-file :which-key "Save file as...")
"f U" '(sudo-edit :which-key "Sudo edit file")
;; Debug
"d d" '(dap-debug :which-key "Debbuger (dap)")
"d b" '(dap-breakpoint-toggle :which-key "Breakpoint (dap)")
"d n" '(dap-next :which-key "Next Step (dap)")
"d i" '(dap-step-in :which-key "Step In (dap)")
"d o" '(dap-step-out :which-key "Step Out (dap)")
"d p" '(dap-continue :which-key "Continue (dap)")
"d s" '(dap-disconnect :which-key "Stop (dap)")
"d l" '(dap-debug-last :which-key "Last Session (dap)")
"d r" '(dap-debug-restart :which-key "Restart Session (dap)")
"d q" '(dap-delete-session :which-key "Quit Session (dap)")
;; LSP
"l e" '(lsp-treemacs-errors-list :which-key "Errors list (Treemacs)")
"l f" '(lsp-ivy-global-workspace-symbol :which-key "Find symbol (Ivy)")
"l r" '(lsp-rename :which-key "Rename symbol")
"l s" '(lsp-treemacs-symbols :which-key "Symbols (Treemacs)")
;; Compile
"m k" '((lambda () (interactive) (shell-command "make && make clean")) :which-key "make")
"m q" '((lambda () (interactive) (shell-command "qmake")) :which-key "qmake")
"m m" '((lambda () (interactive) (shell-command "./compile_run.sh")) :which-key "run")
;; Org Mode
"o ." '(counsel-org-goto :which-key "Counsel org goto")
"o a" '(org-agenda :which-key "Org agenda")
"o c" '(org-capture :which-key "Org capture")
"o r" '(org-refile :which-key "Org refile")
"o s" '(org-schedule :which-key "Org schedule")
"o t" '(org-todo :which-key "Org todo")
"o T" '(org-todo-list :which-key "Org todo list")
"o x" '(org-toggle-checkbox :which-key "Org toggle checkbox")
"o b" '(org-babel-tangle :which-key "Org babel tangle")
;; Registers
"r c" '(copy-to-register :which-key "Copy to register")
"r f" '(frameset-to-register :which-key "Frameset to register")
"r i" '(insert-register :which-key "Insert register")
"r j" '(jump-to-register :which-key "Jump to register")
"r l" '(list-registers :which-key "List registers")
"r n" '(number-to-register :which-key "Number to register")
"r r" '(counsel-register :which-key "Choose a register")
"r v" '(view-register :which-key "View a register")
"r w" '(window-configuration-to-register :which-key "Window configuration to register")
"r +" '(increment-register :which-key "Increment register")
;; Projects
"p T" '(treemacs-projectile :which-key "Treemacs new project")
"p A" '(treemacs-add-and-display-current-project :which-key "Treemacs add current project")
"p C" '(treemacs-create-workspace :which-key "Treemacs create workspace")
"p E" '(treemacs-edit-workspaces :which-key "Treemacs Edit Workspaces")
"p D" '(treemacs-remove-project-from-workspace :which-key "Treemacs remove project")
"p r" '(treemacs-rename-workspace :which-key "Treemacs rename workspace")
"p s" '(treemacs-switch-workspace :which-key "Treemacs switch workspace")
;; Quit
"q q" '(kill-current-buffer :which-key "Kill buffer")
"q Q" '(evil-quit :which-key "Quit Emacs")
;; Visual
"v b" '(show-branches :which-key "Branches")
"v v" '(show-subtree :which-key "Display")
"v c" '(hide-subtree :which-key "Collapse")
"v o" '(hide-other :which-key "Hide other")
"v a" '(hide-sublevels :which-key "Hide all")
"v A" '(show-all :which-key "Show all")
;; Save
"w w" '(save-buffer :which-key "Save file")
"w q" '((lambda () (interactive) (save-buffer) (kill-current-buffer) (evil-window-delete)) :which-key "Save and close")
"w e" '((lambda () (interactive) (save-buffer) (kill-current-buffer)) :which-key "Save and kill")
"w a w" '(evil-write-all :which-key "Save all file")
"w a q" '((lambda () (interactive) (evil-write-all) (centaur-tabs-kill-all-buffers-in-current-group) (evil-window-delete)) :which-key "Save All and close")
"w Q" '(evil-save-modified-and-close :which-key "Save and close Emacs")
;; Window splits
"w c" '(evil-window-delete :which-key "Close window")
"w n" '(evil-window-new :which-key "New window")
"w s" '(evil-window-split :which-key "Horizontal split window")
"w v" '(evil-window-vsplit :which-key "Vertical split window")
;; Window motions
"w h" '(evil-window-left :which-key "Window left")
"w j" '(evil-window-down :which-key "Window down")
"w k" '(evil-window-up :which-key "Window up")
"w l" '(evil-window-right :which-key "Window right")
;; Yas
"y i" '(yas-insert-snippet :which-key "Insert snippet")
"y n" '(yas-new-snippet :which-key "New snippet")
;; Centaur Tabs
"z z" '(centaur-tabs-counsel-switch-group :which-key "Centaur Tabs groups")
;; Highlighting
"H h" '(describe-char :which-key "Current Highlight")
"H d" '(tree-sitter-debug-mode :which-key "Tree-sitter debug mode")
)
Setting up your fonts.
(set-face-attribute 'default nil
:font "JetBrainsMono NerdFont 10"
:weight 'medium)
(set-face-attribute 'variable-pitch nil
:font "DejaVuSans 10"
:weight 'medium)
(set-face-attribute 'fixed-pitch nil
:font "JetBrainsMono NerdFont 10"
:weight 'medium)
;; Makes comments italic
(set-face-attribute 'font-lock-comment-face nil :slant 'italic)
;; Needed if using emacsclient.
(add-to-list 'default-frame-alist '(font . "JetBrainsMono NerdFont-10"))
Add zooming behaviour with keybinds.
;; Zoom In/Out using keyboard
(global-set-key (kbd "C-=") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)
(global-set-key (kbd "C-0") 'text-scale-adjust)
;; Zoom In/Out using mice
(global-set-key (kbd "<C-wheel-up>") 'text-scale-increase)
(global-set-key (kbd "<C-wheel-down>") 'text-scale-decrease)
This is to fix display (icons) issues for some plugins, dashboard and modeline are concerned.
(use-package all-the-icons)
(use-package all-the-icons-ivy-rich :config (all-the-icons-ivy-rich-mode 1))
Display emojis in Emacs.
(use-package emojify :hook (after-init . global-emojify-mode))
Colorize colors values.
(use-package rainbow-mode
:hook
(org-mode . rainbow-mode)
(prog-mode . rainbow-mode)
:custom
(rainbow-x-colors nil))
Add ligatures support into Emacs. (Be careful you must have a Nerd Font!)
(use-package ligature
:load-path "~/.emacs.d/lisp"
:config
;; Enable traditional ligature support in eww-mode, if the
;; `variable-pitch' face supports it
(ligature-set-ligatures 'eww-mode '("ff" "fi" "ffi"))
;; Enable all Code ligatures in every possible major mode
(ligature-set-ligatures 't '("|||>" "<|||" "<==>" "<!--" "####" "~~>" "***" "||=" "||>"
":::" "::=" "=:=" "===" "==>" "=!=" "=>>" "=<<" "=/=" "!=="
"!!." ">=>" ">>=" ">>>" ">>-" ">->" "->>" "-->" "---" "-<<"
"<~~" "<~>" "<*>" "<||" "<|>" "<$>" "<==" "<=>" "<=<" "<->"
"<--" "<-<" "<<=" "<<-" "<<<" "<+>" "</>" "###" "#_(" "..<"
"..." "+++" "/==" "///" "_|_" "www" "&&" "^=" "~~" "~@" "~="
"~>" "~-" "**" "*>" "*/" "||" "|}" "|]" "|=" "|>" "|-" "{|"
"[|" "]#" "::" ":=" ":>" ":<" "$>" "==" "=>" "!=" "!!" ">:"
">=" ">>" ">-" "-~" "-|" "->" "--" "-<" "<~" "<*" "<|" "<:"
"<$" "<=" "<>" "<-" "<<" "<+" "</" "#{" "#[" "#:" "#=" "#!"
"##" "#(" "#?" "#_" "%%" ".=" ".-" ".." ".?" "+>" "++" "?:"
"?=" "?." "??" ";;" "/*" "/=" "/>" "//" "__" "~~" "(*" "*)"
"\\\\" "://" "www"))
;; Enables ligature checks globally in all buffers. You can also do it
;; per mode with `ligature-mode'.
(global-ligature-mode t))
Transform some symbols into pretty icons.
(require 'prettify-utils)
(defun pretty-icons ()
(setq prettify-symbols-alist
(prettify-utils-generate
("[ ]" " ")
("[X]" " ")
("[-]" " ")
("#+begin_src" "")
("#+end_src" "_end")
("#+begin_example" " ex:")
("#+end_example" "_end")
("lambda" "λ")
))
(prettify-symbols-mode 1))
(add-hook 'org-mode-hook 'pretty-icons)
(add-hook 'prog-mode-hook 'pretty-icons)
Disable anoying graphical elements.
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(desktop-save-mode 1)
Set and enable relative line numbers, create a function to disable it.
(setq-default display-line-numbers-type 'relative)
(global-display-line-numbers-mode 1)
(defun disable-line-numbers (&optional dummy)
(display-line-numbers-mode -1))
I prefer manual indenting with tab and 4 step tab width.
;; Use TAB key to indent in evil --INSERT-- mode.
(evil-global-set-key 'insert (kbd "<tab>") 'tab-to-tab-stop)
;; Indent settings
(setq-default tab-width 4
indent-tabs-mode t
backward-delete-char-untabify-method 'hungry)
;; Languages indentation
(setq-default c-basic-offset 4)
Display indent guides and highlight them at point.
(use-package highlight-indent-guides
:hook (prog-mode . highlight-indent-guides-mode)
:custom
(highlight-indent-guides-method 'character)
(highlight-indent-guides-responsive 'top))
Some miscellaneous patches.
(global-auto-revert-mode t) ; Refresh buffer instantly after a save.
(set-fringe-mode 10) ; Set a little space for side indicators.
(setq-default use-short-answers t ; Replace yes/no prompts with y/n
frame-resize-pixelwise t ; Patching the bottom empty space glitch
make-backup-files nil ; Disable the anoying backup~
truncate-lines t ; Disable lines wrapping
initial-buffer-choice (lambda () (get-buffer-create "*dashboard*")) ; Dashboard at startup
scroll-conservatively 10000) ; Smooth scrolling
A theme library from Doom Emacs.
My themes come with my Emacs config but you can also find them on my repo. Github : https://github.com/Plunne/doom-feather-theme
Notice :
To get my theme works, you have to copy them from ./themes
to ./elpa/doom-themes
.
If you prefer the light theme, change doom-feather-dark
to doom-feather-light
.
With solaire-mode change the dashboard banner logo to plunnemacs-dark.png
.
(use-package doom-themes
:after solaire-mode
:config
(setq doom-themes-enable-bold t
doom-themes-enable-italic t
doom-themes-treemacs-theme "doom-atom")
(doom-themes-treemacs-config)
(load-theme 'doom-feather-light t))
IMORTANT!
To get a better integration with many plugins,
you must comment in ./elpa/doom-themes-.../doom-themes-ext-treemacs.el
the following lines :
Re-enable modeline in Treemacs.
(add-hook 'treemacs-mode-hook #'doom-themes-hide-modeline)
Re-enable fringes in Treemacs.
(add-hook 'treemacs-mode-hook #'doom-themes-hide-fringes-maybe)
(advice-add #'treemacs-select-window :after #'doom-themes-hide-fringes-maybe)
(with-eval-after-load 'treemacs ... ;; The modeline isn't useful in treemacs ;(add-hook 'treemacs-mode-hook #'doom-themes-hide-modeline) <- Comment this ;; Disable fringes (and reset them everytime treemacs is selected because it ;; may change due to outside factors) ;(add-hook 'treemacs-mode-hook #'doom-themes-hide-fringes-maybe) <- Comment this ;(advice-add #'treemacs-select-window :after #'doom-themes-hide-fringes-maybe) <- Comment this ...
Distinguish “real” buffers from “unreal” buffer with different backgrounds intensities.
If you disable it, I recommend you to use the dashboard banner logo plunnemacs.png
.
Also, remove the line :after solaire-mode
in the doom-themes setup.
(use-package solaire-mode :config (solaire-global-mode +1))
Centaur tabs is a plugins that display beautiful tabs with many options.
(use-package centaur-tabs
:hook
(dashboard-mode . centaur-tabs-local-mode)
(dired-mode . centaur-tabs-local-mode)
(org-mode . centaur-tabs-local-mode)
(special-mode . centaur-tabs-local-mode)
(treemacs-mode . centaur-tabs-local-mode)
(vterm-mode . centaur-tabs-local-mode)
:bind
(:map evil-normal-state-map
("g t" . centaur-tabs-forward)
("g T" . centaur-tabs-backward))
:config
(setq centaur-tabs-style "bar"
centaur-tabs-set-bar 'under
x-underline-at-descent-line t
centaur-tabs-set-icons t
centaur-tabs-gray-out-icons 'buffer
centaur-tabs-height 32
centaur-tabs-show-count t
centaur-tabs-close-button " "
centaur-tabs-set-modified-marker t
centaur-tabs-modified-marker " "
centaur-tabs-new-tab-text " "
centaur-tabs-cycle-scope 'tabs)
(centaur-tabs-mode t))
;; Fix centaur-tabs with emacsclient
(defun fix-centaur-tabs ()
(centaur-tabs-mode -1)
(centaur-tabs-mode)
(centaur-tabs-headline-match))
(if (daemonp)
(add-hook 'after-make-frame-functions
(lambda (frame) (with-selected-frame frame (fix-centaur-tabs)))
(fix-centaur-tabs)))
Modeline is the status bar of Emacs, doom-modeline is an enhancement.
(use-package doom-modeline
:after doom-themes
:config
(setq doom-modeline-indent-info t ; Show indent mode
column-number-indicator-zero-based nil ; Column count starts from 1
doom-modeline-buffer-file-name-style 'truncate-nil) ; Filename path (full path there)
(column-number-mode t) ; Display column number
(doom-modeline-mode 1)) ; Use Modeline
(use-package hide-mode-line) ; Allows to hide the modeline of some modes
Launch a beautiful dashboard at startup. Also pretty customizable.
(use-package dashboard
:config
(setq dashboard-set-heading-icons t
dashboard-set-file-icons t
dashboard-center-content nil ; set to 't' for centered content
;; Banner
dashboard-startup-banner (expand-file-name "themes/logo/plunnemacs-light.png" user-emacs-directory) ; use custom image as banner
dashboard-banner-logo-title "Org because Unicorn!"
;; Navigator
dashboard-set-navigator t
dashboard-navigator-buttons ; Format: "(icon title help action face prefix suffix)"
`(( ;; Button 1
(" " "Github" "Github profile"
(lambda (&rest _) (browse-url-firefox "github.com/Plunne")))
;; Button2
(" " "TODOs" "TODO List"
(lambda (&rest _) (org-todo-list)))
;; Button3
(" " "Settings" "config.org"
(lambda (&rest _) (find-file (expand-file-name "config.org" user-emacs-directory))))
))
;; Items
dashboard-items '((recents . 8)
(projects . 10)
(agenda . 5))
dashboard-item-names '(("Agenda for today:" . "Agenda:")
("Agenda for the coming week:" . "Agenda:"))
;; Agenda
dashboard-filter-agenda-entry 'dashboard-no-filter-agenda
dashboard-match-agenda-entry "TODO=\"TODO\"|TODO=\"ACTIVE\"|TODO=\"ACTIVE\""
;; Footer
dashboard-footer-icon (all-the-icons-octicon "dashboard"
:height 1.1
:v-adjust -0.05
:face 'dashboard-navigator)
dashboard-footer-messages '("Plunnemacs powered by @PlunneCeleste.")
dashboard-modify-heading-icons '((recents . "file-text")))
(dashboard-setup-startup-hook))
A nice File Manager for Emacs.
(use-package dired
:ensure nil
:commands (dired dired-jump))
(use-package dired-open
:after dired
:config
(setq dired-open-extensions '(("gif" . "sxiv")
("jpg" . "sxiv")
("png" . "sxiv")
("mkv" . "mpv")
("mp4" . "mpv"))))
(use-package dired-single :after dired)
(use-package all-the-icons-dired :hook (dired-mode . all-the-icons-dired-mode))
(use-package peep-dired)
(with-eval-after-load 'dired
(evil-define-key 'normal dired-mode-map (kbd "h") 'dired-single-up-directory)
(evil-define-key 'normal dired-mode-map (kbd "l") 'dired-single-buffer)
(evil-define-key 'normal peep-dired-mode-map (kbd "j") 'peep-dired-next-file)
(evil-define-key 'normal peep-dired-mode-map (kbd "k") 'peep-dired-prev-file))
(add-hook 'peep-dired-hook 'evil-normalize-keymaps)
An aweful git client for Emacs.
(use-package magit :commands magit-status)
The KILLER FEATURE of Emacs!
General settings for Org Mode.
(use-package org
:hook
(org-mode . org-indent-mode)
(org-mode . org-bullets-mode)
(org-mode . disable-line-numbers)
(org-mode . visual-fill-column-mode)
(org-mode . variable-pitch-mode)
:config
(setq org-ellipsis " "
org-hide-emphasis-markers t
org-blank-before-new-entry (quote ((heading . nil)
(plain-list-item . nil)))))
Org Agenda will change your life.
Basical settings for org-agenda, you can add/change/remove the path/s of your Org files and their directories.
(setq org-directory "~/Org/"
org-agenda-files '("~/Org/agenda.org"
"~/Org/daily.org"
"~/Org/history.org")
org-log-done 'time)
TODO is an amazing way to organize your life!
There you can change the TODO keywords. The | separates ACTIVE and INNACTIVE states.
(setq org-todo-keywords ; This overwrites the default Doom org-todo-keywords
'((sequence
"TODO(t)" ; A task to do
"ACTIVE(a)" ; An active task (currently working on)
"OPTIONAL(o)" ; Optional task if possible
"WAIT(w)" ; Waiting for another task
"|" ; The pipe necessary to separate "active" states and "inactive" states
"DONE(d)" ; Task has been completed
"CANCELLED(c)" ))) ; Task has been cancelled
Org templates allows you to create some todo template to add TODOs.
(setq org-capture-templates
`(
;; Tasks
("t" "Tasks")
;; Simple TODO
("tt" "TODO" entry (file+olp "~/Org/agenda.org" "TASK LIST")
"* TODO %?") ; * TODO task to do
))
Habits separate your daily task to your TODOs for more clarity.
(require 'org-habit)
(setq org-habit-graph-column 60)
(add-to-list 'org-modules 'org-habit)
Auto done a TODO when a check list is complete.
(eval-after-load 'org-list
'(add-hook 'org-checkbox-statistics-hook (function checkbox-list-complete)))
(defun checkbox-list-complete ()
(save-excursion
(org-back-to-heading t)
(let ((beg (point)) end)
(end-of-line)
(setq end (point))
(goto-char beg)
(if (re-search-forward "\\[\\([0-9]*%\\)\\]\\|\\[\\([0-9]*\\)/\\([0-9]*\\)\\]" end t)
(if (match-end 1)
(if (equal (match-string 1) "100%")
;; all done - do the state change
(org-todo 'done)
(org-todo 'todo))
(if (and (> (match-end 2) (match-beginning 2))
(equal (match-string 2) (match-string 3)))
(org-todo 'done)
(org-todo 'todo)))))))
When you complete a task, you can move it to another Org file, personnally i use it to make an history of my tasks.
(setq org-refile-targets '(("agenda.org" :maxlevel . 1)
("daily.org" :maxlevel . 1)
("history.org" :maxlevel . 2)))
(advice-add 'org-refile :after 'org-save-all-org-buffers) ;; Save Org buffers after refiling!
Change the Org Bullets whatever you want.
(use-package org-bullets :custom (org-bullets-bullet-list '("✿" "❀" "◉" "○" "●" "►" "◆")))
Customize Org fonts, also lists improvements.
Appearence of org contents.
(set-face-attribute 'org-block nil :foreground nil :inherit 'fixed-pitch)
(set-face-attribute 'org-code nil :inherit '(shadow fixed-pitch))
(set-face-attribute 'org-table nil :inherit '(shadow fixed-pitch))
(set-face-attribute 'org-verbatim nil :inherit '(shadow fixed-pitch))
(set-face-attribute 'org-special-keyword nil :inherit '(font-lock-comment-face fixed-pitch))
(set-face-attribute 'org-meta-line nil :inherit '(font-lock-comment-face fixed-pitch))
(set-face-attribute 'org-checkbox nil :inherit 'fixed-pitch)
Replace list hyphen with dot.
(font-lock-add-keywords 'org-mode
'(("^ *\\([-]\\) "
(0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•"))))))
Better look for checked lists.
(defface org-checkbox-done-text
'((t (:foreground "#503F65" :strike-through t)))
"Face for the text part of a checked org-mode checkbox.")
(font-lock-add-keywords
'org-mode
`(("^[ \t]*\\(?:[-+*]\\|[0-9]+[).]\\)[ \t]+\\(\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?\\[\\(?:X\\|\\([0-9]+\\)/\\2\\)\\][^\n]*\n\\)"
1 'org-checkbox-done-text prepend))
'append)
Make Org Mode looks like an office text editor.
(use-package visual-fill-column
:custom
((visual-fill-column-width 112)
(visual-fill-column-center-text t)
(visual-fill-column-enable-sensible-window-split t)))
Call simples snippets into Org Mode.
(with-eval-after-load 'org
(require 'org-tempo)
(evil-global-set-key 'insert (kbd "C-.") 'tempo-complete-tag)
(add-to-list 'org-structure-template-alist '("cpp" . "src cpp"))
(add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
(add-to-list 'org-structure-template-alist '("ino" . "src arduino"))
(add-to-list 'org-structure-template-alist '("ltx" . "src latex"))
(add-to-list 'org-structure-template-alist '("lua" . "src lua"))
(add-to-list 'org-structure-template-alist '("mk" . "src makefile"))
(add-to-list 'org-structure-template-alist '("py" . "src python"))
(add-to-list 'org-structure-template-alist '("sh" . "src shell"))
)
The vanilla org blocks syntax is yuck. Make it better.
(setq org-src-fontify-natively t
org-src-tab-acts-natively t
org-src-preserve-indentation nil
org-edit-src-content-indentation 0
org-confirm-babel-evaluate nil)
ToC auto creates Table of Contents when saving an org file.
(use-package toc-org
:commands toc-org-enable
:init (add-hook 'org-mode-hook 'toc-org-enable))
Auto write output files at save.
(use-package org-auto-tangle
:defer t
:hook (org-mode . org-auto-tangle-mode))
A toggle terminal emulator.
;; Vterm base
(use-package vterm)
;; Shell configuration
(setq shell-file-name "/bin/zsh"
vterm-max-scrollback 5000)
;; Vterm toggle
(use-package vterm-toggle
:commands vterm-toggle
:custom
(vterm-toggle-reset-window-configration-after-exit t)
(vterm-toggle-scope 'project)
(vterm-toggle-fullscreen-p nil)
(vterm-toggle-hide-method 'delete-window)
:hook
(vterm-toggle-show . evil-emacs-state) ; Enter into Emacs mode (enable typing with completion)
(vterm-toggle-show . hide-mode-line-mode) ; Hide Vterm Modeline
(vterm-toggle-show . disable-line-numbers)) ; Hide Vterm Line Numbers
;; Escape Emacs mode
(define-key evil-emacs-state-map [escape] 'evil-normal-state)
;; Vterm toggle settings
(with-eval-after-load 'vterm
(add-to-list 'display-buffer-alist
'((lambda (buffer-or-name _)
(let ((buffer (get-buffer buffer-or-name)))
(with-current-buffer buffer
(or (equal major-mode 'vterm-mode)
(string-prefix-p vterm-buffer-name (buffer-name buffer))))))
(display-buffer-reuse-window display-buffer-in-side-window)
(side . bottom)
(reusable-frames . visible)
(window-height . 0.2)))
)
Ivy is a minibuffer completion mechanism.
;; Ivy, a generic completion mechanism for Emacs
(use-package ivy
:init (ivy-mode)
:config
(setq ivy-count-format "%d/%d " ; Display the current candidate and the number of candidate
ivy-initial-inputs-alist nil ; Remove the '^' in Ivy prompt
ivy-use-virtual-buffers t
enable-recursive-minibuffers t))
;; Counsel, a collection of Ivy-enhanced versions of common Emacs commands
(use-package counsel
:after ivy
:config (counsel-mode))
;; Swiper, an Ivy-enhanced alternative to Isearch
(use-package swiper :after ivy)
;; Ivy-Rich, improve Ivy with a better look
(use-package ivy-rich
:after ivy
:config (ivy-rich-mode 1))
(setq ivy-rich-path-style 'abbrev) ; Abbreviate filenames
;; Smex, an Ivy history
(use-package smex
:after ivy
:config (smex-initialize))
Emacs on a tree.
(use-package treemacs
:bind
(:map global-map
([f8] . treemacs)
("C-<f8>" . treemacs-select-window))
:config
(treemacs-follow-mode t))
(add-hook 'treemacs-mode-hook (lambda() (disable-line-numbers)))
(use-package treemacs-evil :after (treemacs evil))
(use-package treemacs-icons-dired :hook (dired-mode . treemacs-icons-dired-enable-once))
(use-package treemacs-magit :after (treemacs magit))
(use-package treemacs-projectile :after (treemacs projectile))
For programming we need these important tools that will change our workflow.
(use-package company
:init (company-mode)
:custom
(company-minimum-prefix-length 1)
(company-idle-delay 0.0))
(use-package company-box :hook (company-mode . company-box-mode))
(add-hook 'after-init-hook 'global-company-mode)
(use-package smartparens :config (smartparens-global-mode t))
(use-package evil-commentary
:after evil
:config (evil-commentary-mode))
(add-hook 'c-mode-common-hook (lambda () (setq comment-start "// " comment-end "")))
(use-package evil-multiedit
:after evil
:custom (evil-multiedit-follow-matches t))
(evil-multiedit-default-keybinds)
(use-package rainbow-delimiters
:hook
;; Bash
(sh-mode . rainbow-delimiters-mode)
;; C/C++
(c-mode . rainbow-delimiters-mode)
(c++-mode . rainbow-delimiters-mode)
(objc-mode . rainbow-delimiters-mode)
(cuda-mode . rainbow-delimiters-mode)
;; Elisp
(emacs-lisp-mode . rainbow-delimiters-mode)
;; HTML/CSS
(css-mode . rainbow-delimiters-mode)
;; Lua
(lua-mode . rainbow-delimiters-mode)
;; Python
(python-mode . rainbow-delimiters-mode))
Language Server Protocol.
(use-package lsp-mode
:commands lsp
:init
(setq lsp-keymap-prefix "C-c l")
:hook
(lsp-mode . lsp-headerline-breadcrumb-mode)
(lsp-mode . lsp-enable-which-key-integration))
(use-package lsp-ui
:commands lsp-ui-mode
:hook (lsp-mode . lsp-ui-mode)
:custom
(lsp-ui-sideline-show-hover t)
(lsp-ui-sideline-show-diagnostics t)
(lsp-ui-sideline-show-code-actions t)
(lsp-ui-doc-show-with-cursor t)
(lsp-ui-doc-position 'at-point))
(use-package lsp-treemacs
:after lsp
:config (lsp-treemacs-sync-mode 1))
(use-package lsp-ivy :after lsp)
(nvmap :prefix "g" "r" '(lsp-ui-peek-find-references :which-key "goto references (lsp-ui-peek)"))
A debugger for EMACS.
(use-package dap-mode
:commands dap-debug
:custom (dap-auto-configure-features '(breakpoints locals expressions)))
Notify syntax errors.
(use-package flycheck :config (global-flycheck-mode))
Improve the syntax highlighting so much!
(use-package tree-sitter-langs)
(use-package tree-sitter
:after tree-sitter-langs
:hook
;; Bash
(sh-mode . tree-sitter-hl-mode)
;; C/C++
(c-mode . tree-sitter-hl-mode)
(c++-mode . tree-sitter-hl-mode)
(objc-mode . tree-sitter-hl-mode)
(cuda-mode . tree-sitter-hl-mode)
;; HTML/CSS
(html-mode . tree-sitter-hl-mode)
(css-mode . tree-sitter-hl-mode)
;; Python
(python-mode . tree-sitter-hl-mode)
)
Needed : npm i -g bash-language-server
M-x lsp-install-server
RET bash-ls
You need to have installed ccls
and clang
on your computer.
(use-package ccls :hook ((c-mode c++-mode objc-mode cuda-mode) . (lambda () (require 'ccls) (lsp))))
(with-eval-after-load 'ccls
(require 'dap-cpptools)
(dap-cpptools-setup)
)
A mode to preview websites in real time in your browser.
(use-package impatient-mode)
To enable it :
- Run the server : M-x
httpd-start
- Enable impatient-mode in every buffers of the site you are editing : M-x
impatient-mode
Then, browse the local link : http://localhost:8080/imp
(use-package json-mode)
Enable Lua language server and setup indent width to 4.
(use-package lua-mode :custom (lua-indent-level 4))
Enable Python LSP.
(use-package lsp-pyright :hook (python-mode . (lambda () (require 'lsp-pyright) (lsp))))
(use-package yaml-mode)
Make every snippets you want with YASnippet !
(use-package yasnippet
:config
(setq yas-snippet-dirs '("~/.emacs.d/snippets"))
(yas-global-mode 1))
(evil-global-set-key 'insert (kbd "C-,") 'yas-expand)
(evil-global-set-key 'insert (kbd "C-]") 'yas-next-field)
(evil-global-set-key 'insert (kbd "C-[") 'yas-prev-field)
Thanks to all of these peoples that made awesome tutorials about writing Emacs configurations.
- Derek Taylor (DT/DistroTube) : https://www.youtube.com/c/DistroTube
- David Wilson (System Crafters) : https://www.youtube.com/c/SystemCrafters
- Lukewh : https://www.youtube.com/c/Lukew
- Jake B : https://www.youtube.com/c/JakeBox0
- Zaiste Programming : https://www.youtube.com/c/ZaisteProgramming