#+Property: Header-args :tangle init.el #+auto_tangle: t #+AUTHOR: Eduardo Cueto-Mendoza based on Chris Smith a.k.a LTG * Table of Contents :TOC: - [[#package-management-system][PACKAGE MANAGEMENT SYSTEM]] - [[#straightel][STRAIGHT.EL]] - [[#use-package][USE PACKAGE]] - [[#backup][BACKUP]] - [[#packages][PACKAGES]] - [[#beacon][BEACON]] - [[#focus][FOCUS]] - [[#magit][MAGIT]] - [[#rainbow-mode][RAINBOW Mode]] - [[#rainbow-delimiters][Rainbow Delimiters]] - [[#highlight-todo][Highlight TODO]] - [[#which-key][WHICH-KEY]] - [[#vterm][VTERM]] - [[#vterm-toggle][VTERM-TOGGLE]] - [[#treemacs][TREEMACS]] - [[#doom-modeline][DOOM-MODELINE]] - [[#all-the-icons][ALL-THE-ICONS]] - [[#org-mode][ORG-MODE]] - [[#org-auto-tangle][ORG-AUTO-TANGLE]] - [[#org-definitions][ORG DEFINITIONS]] - [[#toc-org][TOC-ORG]] - [[#org-modern-mode][ORG-MODERN-MODE]] - [[#org-tempo][ORG-TEMPO]] - [[#vertico][VERTICO]] - [[#vertico-directory][Vertico-Directory]] - [[#company][COMPANY]] - [[#marginalia][MARGINALIA]] - [[#embark][EMBARK]] - [[#evil][EVIL]] - [[#dashboard][DASHBOARD]] - [[#consult][Consult]] - [[#perspective][Perspective]] - [[#development][DEVELOPMENT]] - [[#lsp-mode][LSP MODE]] - [[#jedi-for-python][Jedi for python]] - [[#rustic-rust-stuff][Rustic (Rust Stuff)]] - [[#ccls][CCLS]] - [[#haskell-mode][HASKELL-MODE]] - [[#rust-mode][RUST-MODE]] - [[#flycheck][FLYCHECK]] - [[#tree-sitter-grammers][Tree-Sitter-Grammers]] - [[#remap-modes-for-tree-sitter][REMAP MODES FOR TREE-SITTER]] - [[#projectile][PROJECTILE]] - [[#yasnippet][YASNIPPET]] - [[#lsp-treemacs][LSP-TREEMACS]] - [[#garbage-collection][GARBAGE COLLECTION]] - [[#native-compile][NATIVE COMPILE]] - [[#user-interface-enhancements][USER INTERFACE ENHANCEMENTS]] - [[#enabling-return-for-min-buffer-questions][Enabling Return for min-buffer questions]] - [[#disable-electric-indent][DISABLE ELECTRIC INDENT]] - [[#fonts-and-themes][Fonts and Themes]] - [[#zooming-inout][Zooming IN/OUT]] - [[#general-keybinds][GENERAL KEYBINDS]] * PACKAGE MANAGEMENT SYSTEM ** STRAIGHT.EL We are using straight.el intead of using package.el as our package manager, below is the boostrap code in order for it to work. #+begin_src emacs-lisp ;; Install straight.el (defvar bootstrap-version) (let ((bootstrap-file (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) (bootstrap-version 6)) (unless (file-exists-p bootstrap-file) (with-current-buffer (url-retrieve-synchronously "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el" 'silent 'inhibit-cookies) (goto-char (point-max)) (eval-print-last-sexp))) (load bootstrap-file nil 'nomessage)) #+end_src * USE PACKAGE #+begin_src emacs-lisp (setq straight-use-package-by-default t) #+end_src * BACKUP Put all backup files in the Trash can, by default emacs makes these annoying backup files on the filesystem and this will make it where those backups goto the trash #+begin_src emacs-lisp (setq backup-directory-alist '((".*" . "~/.local/share/Trash/files"))) #+end_src * PACKAGES ** BEACON BEACON is a package so you never lose your mouse cursor again, it will highlight a line where your mouse cursor is. #+begin_src emacs-lisp (use-package beacon) #+end_src #+begin_src emacs-lisp (use-package doom-themes) #+end_src ** FOCUS This is package that dims surrounding text while typing #+begin_src emacs-lisp (use-package focus) #+end_src ** MAGIT Magit is a fully featured git client for emacs #+begin_src emacs-lisp (use-package magit) #+end_src ** RAINBOW Mode Display the actual color for a hex value, works in all modes #+begin_src emacs-lisp (use-package rainbow-mode :hook org-mode prog-mode) #+end_src ** Rainbow Delimiters #+begin_src emacs-lisp (use-package rainbow-delimiters :hook ((org-mode . rainbow-delimiters-mode) (prog-mode . rainbow-delimiters-mode))) #+end_src ** Highlight TODO Highlight certain words in documents and colorize them #+begin_src emacs-lisp (use-package hl-todo :hook ((org-mode . hl-todo-mode) (prog-mode . hl-todo-mode)) :config (setq hl-todo-highlight-punctuation ":" hl-todo-keyword-faces `(("TODO" warning bold) ("FIXME" error bold) ("HACK" font-lock-constant-face bold) ("REVIEW" font-lock-keyword-face bold) ("NOTE" success bold) ("DEPRECATED" font-lock-doc-face bold)))) #+end_src ** WHICH-KEY Which-key is a program to display what keys are next on your minibuffer #+begin_src emacs-lisp (use-package which-key :straight t :init (which-key-mode 1) :config (setq which-key-side-window-location 'bottom which-key-sort-order #'which-key-key-order which-key-allow-imprecise-window-fit nil which-key-sort-uppercase-first nil which-key-add-column-padding 1 which-key-max-display-columns nil which-key-min-display-lines 6 which-key-side-window-slot -10 which-key-side-window-max-height 0.25 which-key-idle-delay 0.8 which-key-max-description-length 25 which-key-allow-imprecise-window-fit nil which-key-separator " → " )) #+end_src ** VTERM Vterm is a terminal emulator within in Emacs. The default shell is set to fish but it could be changed #+begin_src emacs-lisp (use-package vterm :config (setq shell-file-name "/bin/fish" vterm-max-scrollback 5000)) #+end_src ** VTERM-TOGGLE Vterm-toggle toggles between the vterm buffer and what ever buffer your editing #+begin_src emacs-lisp (use-package vterm-toggle :after vterm :config (setq vterm-toggle-fullscreen-p nil) (setq vterm-toggle-scope 'project) (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-at-bottom) ;;(display-buffer-reuse-window display-buffer-in-direction) ;;display-buffer-in-direction/direction/dedicated is added in emacs27 ;;(direction . bottom) ;;(dedicated . t) ;dedicated is supported in emacs27 (reusable-frames . visible) (window-height . 0.3)))) #+end_src ** TREEMACS #+begin_src emacs-lisp (use-package treemacs :ensure t :defer t) (use-package treemacs-icons-dired :hook (dired-mode . treemacs-icons-dired-enable-once) :straight t) (use-package treemacs-persp :after (treemacs persp-mode) :ensure t :config (treemacs-set-scope-type 'Perspectives)) #+end_src ** DOOM-MODELINE Doom-modeline is a modeline for your minibuffer, doom-modeline was inspired by 'doom-emacs' #+begin_src emacs-lisp (use-package doom-modeline :straight t :init (doom-modeline-mode 1)) #+end_src ** ALL-THE-ICONS All the icons is a package to display proper symbols/icons on the modeline. #+begin_src emacs-lisp (use-package all-the-icons :if (display-graphic-p)) (use-package all-the-icons-dired :hook (dired-mode . (lambda () (all-the-icons-dired-mode t)))) #+end_src * ORG-MODE ** ORG-AUTO-TANGLE Org-auto-tangle is a package that will automaticlly tangle your org file for you when you save your .org document. Set #+auto_tangle: t in your header file. #+begin_src emacs-lisp (use-package org-auto-tangle :defer t :hook (org-mode . org-auto-tangle-mode)) #+end_src ** ORG DEFINITIONS Setting some default .org definitions. #+begin_src emacs-lisp (add-hook 'org-mode-hook 'org-indent-mode) (setq org-directory "~/.emacs.d/Org/" org-agenda-files '("~/.emacs.d/Org/agenda.org") org-default-notes-file (expand-file-name "notes.org" org-directory) org-ellipsis " ▼ " org-log-done 'time org-journal-dir "~/.emacs.d/Org/journal/" org-journal-date-format "%d %B, %Y (%A) " org-journal-file-format "%Y-%m-%d.org" org-hide-emphasis-markers t) (setq org-src-preserve-indentation nil org-src-tab-acts-natively t org-edit-src-content-indentation 0 org-src-fontify-natively t org-confirm-babel-evaluate nil) #+end_src ** TOC-ORG This package will automaticlly generate a table of contents in org mode. use :TOC: at the end of your table of contents header. #+begin_src emacs-lisp (use-package toc-org :commands toc-org-enable :init (add-hook 'org-mode-hook 'toc-org-enable)) #+end_src ** ORG-MODERN-MODE #+begin_src emacs-lisp (use-package org-modern) (with-eval-after-load 'org (global-org-modern-mode)) #+end_src ** ORG-TEMPO This package allows you to type '" . company-select-last)) (:map company-mode-map ("" . tab-indent-or-complete) ("TAB" . tab-indent-or-complete))) (defun company-yasnippet-or-completion () (interactive) (or (do-yas-expand) (company-complete-common))) (defun check-expansion () (save-excursion (if (looking-at "\\_>") t (backward-char 1) (if (looking-at "\\.") t (backward-char 1) (if (looking-at "::") t nil))))) (defun do-yas-expand () (let ((yas/fallback-behavior 'return-nil)) (yas/expand))) (defun tab-indent-or-complete () (interactive) (if (minibufferp) (minibuffer-complete) (if (or (not yas/minor-mode) (null (do-yas-expand))) (if (check-expansion) (company-complete-common) (indent-for-tab-command))))) (use-package company-box :after company :hook (company-mode . company-box-mode)) #+end_src ** MARGINALIA This package provides marginalia-mode which adds marginalia to the minibuffer completions. #+begin_src emacs-lisp ;; Enable rich annotations using the Marginalia package (use-package marginalia ;; Bind `marginalia-cycle' locally in the minibuffer. To make the binding ;; available in the *Completions* buffer, add it to the ;; `completion-list-mode-map'. :bind (:map minibuffer-local-map ("M-A" . marginalia-cycle)) ;; The :init section is always executed. :init ;; Marginalia must be actived in the :init section of use-package such that ;; the mode gets enabled right away. Note that this forces loading the ;; package. (marginalia-mode)) #+end_src ** EMBARK #+begin_src emacs-lisp (use-package embark :straight t) (use-package embark-consult :straight t :hook (embark-collection-mode . consult-preview-at-point-mode)) #+end_src ** EVIL Evil Mode is 'vim keybindings for EMACS. We are setting "evil-mode" by default. #+begin_src emacs-lisp (use-package evil :straight t :init (setq evil-want-keybinding nil) (setq evil-vsplit-window-right t) (setq evil-split-window-below t) :config (evil-mode 1)) (use-package evil-collection :after evil :straight t :config (evil-collection-init)) #+end_src ** DASHBOARD This is a startup dashboard for emacs, it shows recent files, projects and your org-agendas. #+begin_src emacs-lisp ;;install dashboard (use-package dashboard :straight t :init (setq dashboard-set-heading-icons t) (setq dashboard-set-file-icons t) (setq dashboard-banner-logo-title "emacs rocks") (setq dashboard-startup-banner 'logo) (setq dashboard-center-content nil) (setq dashboard-items '((recents . 5) (projects . 3) (agenda . 3)))) :config (dashboard-setup-startup-hook) #+end_src ** Consult #+begin_src emacs-lisp (use-package consult) (use-package consult-dir :straight t :bind (("C-x C-d" . consult-dir) :map vertico-map ("C-x C-d" . consult-dir) ("C-x C-j" . consult.dir-jump-file))) #+end_src ** Perspective This package adds workspaces for your buffers in Emacs. This package is very similiar in how a tiling window manager works with its workspaces. #+begin_src emacs-lisp (use-package perspective :bind ("C-x C-b" . persp-list-buffers) ; or use a nicer switcher, see below :custom (persp-mode-prefix-key (kbd "C-c M-p")) ; pick your own prefix key here :init (persp-mode)) #+end_src * DEVELOPMENT ** LSP MODE #+begin_src emacs-lisp (use-package lsp-mode :ensure :commands lsp :custom (lsp-rust-analyzer-cargo-watch-command "clippy") (lsp-eldoc-render-all t) (lsp-idle-delay 0.6) (lsp-inlay-hint-enable nil) (lsp-rust-analyzer-display-lifetime-elision-hints-enable "skip_trivial") (lsp-rust-analyzer-display-chaining-hints nil) (lsp-rust-analyzer-displal-lifetime-elision-hints-use-parameter-names nil) (lsp-rust-analyzer-display-closure-return-type-hints nil) (lsp-rust-analyzer-display-parameter-hints nil) (lsp-rust-analyzer-display-reborrow-hints nil) (setq lsp-auto-guess-root nil) :config (add-hook 'lsp-mode-hook 'lsp-ui-mode 'lsp-mode-hook 'lsp-enable-which-key-integration)) (use-package lsp-ui :ensure :commands lsp-ui-mode :custom (lsp-ui-peek-always-show nil) (lsp-ui-sideline-show-hover nil) (lsp-ui-doc-enable nil)) #+end_src ** Jedi for python #+begin_src emacs-lisp (use-package lsp-jedi :ensure t) #+end_src ** Rustic (Rust Stuff) #+begin_src emacs-lisp (use-package rustic :ensure :bind (:map rustic-mode-map ("M-j" . lsp-ui-imenu) ("M-?" . lsp-find-references)) :config (setq lsp-format-buffer t)) #+end_src ** CCLS lsp for C++ #+begin_src emacs-lisp (use-package ccls :hook ((c-mode c++-mode objc-mode cuda-mode) . (lambda () (require 'ccls) (lsp)))) (setq ccls-executable "/usr/bin/ccls") ;;(setq ccls-sem-highlight-method 'font-lock) (setq ccls-use-default-rainbow-sem-highlight 'font-lock) (ccls-code-lens-mode 1) #+end_src ** HASKELL-MODE #+begin_src emacs-lisp (use-package haskell-mode) #+end_src ** RUST-MODE #+begin_src emacs-lisp (use-package toml-mode) (use-package rust-mode :hook (rust-mode . lsp-mode)) #+end_src ** FLYCHECK #+begin_src emacs-lisp (use-package flycheck :straight t) #+end_src ** Tree-Sitter-Grammers #+begin_src emacs-lisp (setq treesit-language-source-alist '((rust "https://github.com/tree-sitter/tree-sitter-rust"))) #+end_src ** REMAP MODES FOR TREE-SITTER #+begin_src emacs-lisp (setq major-mode-remap-alist '((rust-mode . rust-ts-mode))) #+end_src ** PROJECTILE Projectile is a project interaction library for Emacs. #+begin_src emacs-lisp (use-package projectile) #+end_src ** YASNIPPET #+begin_src emacs-lisp (use-package yasnippet :config (yas-reload-all) (add-hook 'prog-mode-hook 'yas-minor-mode) (add-hook 'text-mode-hook 'yas-minor-mode)) #+end_src ** LSP-TREEMACS #+begin_src emacs-lisp (use-package lsp-treemacs :commands lsp-treemacs-errors-list) #+end_src * GARBAGE COLLECTION GC is the process of freeing up memory from unused/used up variables. We set the threshold on the GC so emacs will be a little faster. #+begin_src emacs-lisp ;; 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) #+end_src * NATIVE COMPILE Native Compile support and silence some annoying warnings when a package gets installed. #+begin_src emacs-lisp ;; Silence compiler warnings as they can be pretty disruptive (if (boundp 'comp-deferred-compilation) (setq comp-deferred-compilation nil) (setq native-comp-deferred-compilation nil)) ;; In noninteractive sessions, prioritize non-byte-compiled source files to ;; prevent the use of stale byte-code. Otherwise, it saves us a little IO time ;; to skip the mtime checks on every *.elc file. (setq load-prefer-newer noninteractive) #+end_src * USER INTERFACE ENHANCEMENTS #+begin_src emacs-lisp ;; load dashboard instead of scratchpad at startup *INSTALL DASHBOARD* (setq initial-buffer-choice (lambda () (get-buffer "*dashboard*"))) ;;(load-theme 'doom-tokyo-night :no-confirm) ; Set theme (load-theme 'doom-xcode :no-confirm) ; Set theme (menu-bar-mode -1) ; Turn menubar off (scroll-bar-mode -1) ; Turn scrollbar off (tool-bar-mode -1) ; Turn tool-bar off (global-display-line-numbers-mode 1) ; Display line numbers globally (beacon-mode 1) ; Turn beacon on (toggle-frame-maximized) (setq inhibit-startup-screen t) ; Disable startup default startup screen (setq auto-save-interval 1000) (setq make-backup-files nil) ; Disable automatic backup files #+end_src * Enabling Return for min-buffer questions #+begin_src emacs-lisp (defun y-or-n-p-with-return (orig-func &rest args) (let ((query-replace-map (copy-keymap query-replace-map))) (define-key query-replace-map (kbd "RET") 'act) (apply orig-func args))) (advice-add 'y-or-n-p :around #'y-or-n-p-with-return) #+end_src * DISABLE ELECTRIC INDENT fix some of the weird indents in org mode #+begin_src emacs-lisp (electric-indent-mode -1) (setq org-edit-src-content-indentation 0) #+end_src * Fonts and Themes #+begin_src emacs-lisp (set-face-attribute 'default nil :font "Terminess Nerd Font" :height 180 :weight 'bold) (set-face-attribute 'variable-pitch nil :font "Terminess Nerd Font" :height 180 :weight 'semibold) (set-face-attribute 'fixed-pitch nil :font "Terminess Nerd Font" :height 180 :weight 'bold) ;; Makes commented text and keywords italics. ;; This is working in emacsclient but not emacs. ;; Your font must have an italic face available. (set-face-attribute 'font-lock-comment-face nil :slant 'italic) (set-face-attribute 'font-lock-keyword-face nil :slant 'italic) ;;(add-to-list 'default-frame-alist '(font . "JetBrainsMono Nerd Font-14")) (setq pixel-scroll-precision-mode 1) ;; Uncomment the following line if line spacing needs adjusting. ;;(setq-default line-spacing 0.12) (add-to-list 'default-frame-alist '(alpha-background . 90)) ;; Needed if using emacsclient. Otherwise, your fonts will be smaller than expected. ;;(add-to-list 'default-frame-alist '(font . "SauceCodePro Nerd Font-16" :weight 'semibold)) ;; changes certain keywords to symbols, such as lamda! (setq global-prettify-symbols-mode t) ;;(add-hook 'find-file-hook (lambda () (set-face-attribute 'default nil :height 105))) #+end_src #+RESULTS: : t * Zooming IN/OUT Zoom in with Cntrl+ and out with Cntrl-, also use mousewheel up to zoomin and mousewheel down to zoom out #+begin_src emacs-lisp (global-set-key (kbd "C-+") 'text-scale-increase) (global-set-key (kbd "C--") 'text-scale-decrease) ;; (global-set-key (kbd "") 'text-scale-increase) ;; (global-set-key (kbd "") 'text-scale-decrease) #+end_src * GENERAL KEYBINDS General provides a more convenient way method for binding keys in emacs that works for both 'evil mode' and 'non-evil-mode'. #+begin_src emacs-lisp ;;install general ;; (global-set-key (kbd "C-t") 'vterm-toggle) (use-package general :config (general-evil-setup) ;; set up 'SPC' as the global leader key (general-create-definer ltg/leader-keys :states '(normal insert visual emacs) :keymaps 'override :prefix "SPC" ;; set leader :global-prefix "M-SPC") (ltg/leader-keys "SPC" '(execute-extended-command :wk "M-x") "." '(find-file :wk "Find file") "f f" '(find-file :wk "Find file") "t t" 'vterm-toggle "t l" 'eshell "=" '(perspective-map :wk "Perspective") ;; Lists all the perspective keybindings "TAB TAB" '(comment-line :wk "Comment lines") "u" '(universal-argument :wk "Universal argument")) (ltg/leader-keys "b" '(:ignore t :wk "Buffers") "b i" '(ibuffer :wk "Ibuffer") "b p" '(previous-buffer :wk "Previous buffer") "b n" '(next-buffer :wk "Next buffer")) (ltg/leader-keys "d" '(:ignore t :wk "Dired") "d d" '(dired :wk "Open Dired") "d j" '(dired-jump :wk "Dired jump to current")) (ltg/leader-keys "f" '(:ignore t :wk "Files") "f c" '((lambda () (interactive) (find-file "~/.emacs.d/README.org")) :wk "Open emacs config") "f d" '(find-grep-dired :wk "Search for strings in files in DIR")) (ltg/leader-keys "e" '(:ignore t :wk "Evaluate") "e r" '(eval-region :wk "Eval Region") "e b" '(eval-buffer :wk "Eval Buffer")) ) #+end_src