#+title: Emacs config #+author O. George #+BABEL: :cache no #+PROPERTY: header-args:emacs-lisp :tangle init.el [[https://github.com/horhik/dotfiles][░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ ░░█░█░█▀█░█▀▄░█░█░▀█▀░█░█░▀░█▀▀░░░░ ░░█▀█░█░█░█▀▄░█▀█░░█░░█▀▄░░░▀▀█░░░░ ░░▀░▀░▀▀▀░▀░▀░▀░▀░▀▀▀░▀░▀░░░▀▀▀░░░░ ░░█▀▄░█▀█░▀█▀░█▀▀░▀█▀░█░░░█▀▀░█▀▀░░ ░░█░█░█░█░░█░░█▀▀░░█░░█░░░█▀▀░▀▀█░░ ░░▀▀░░▀▀▀░░▀░░▀░░░▀▀▀░▀▀▀░▀▀▀░▀▀▀░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░]] * Help info ~C-z~ to toggle vim/emacs mode * UI ** Cleaning up UI #+begin_src emacs-lisp (require 'package) (setq inhibit-startup-message t) (menu-bar-mode -1) (toggle-scroll-bar -1) (tool-bar-mode -1) (tooltip-mode -1) (set-fringe-mode 10) (visual-line-mode t) (visual-line-mode 1) #+end_src #+RESULTS: : t ** Initializing packages #+begin_src emacs-lisp (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") '("org" . "https://orgmode.org/elpa/")) (package-initialize) (unless package-archive-contents (package-refresh-contents)) (defvar package-list '( lsp-mode rustic evil-mc rainbow-delimiters doom-themes doom-modeline lusty-explorer ac-racer auto-complete all-the-icons linum-relative racer cargo flycheck-rust rust-mode gruvbox-theme evil general use-package treemacs treemacs-all-the-icons treemacs-evil org-roam org-roam-server interaction-log)) (dolist (p package-list) (when (not (package-installed-p p)) (package-install p))) (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(custom-safe-themes '("6b5c518d1c250a8ce17463b7e435e9e20faa84f3f7defba8b579d4f5925f60c1" "75b8719c741c6d7afa290e0bb394d809f0cc62045b93e1d66cd646907f8e6d43" "7661b762556018a44a29477b84757994d8386d6edee909409fabe0631952dad9" default)) '(package-selected-packages '(rls lsp highlight-parentheses neotree treemacs-persp spaceline-all-the-icons all-the-icons-ivy-rich all-the-icons-ivy treemacs-the-icons dired-icon treemacs-magit treemacs-projectile nlinum linum-mode unicode-fonts ewal-doom-themes ivy-rich which-key counsel org-roam treemacs-evil treemacs-all-the-icons treemacs use-package general gruvbox-theme flycheck-rust cargo linum-relative ac-racer lusty-explorer doom-modeline doom-themes rainbow-delimiters evil-mc rustic lsp-mode avy))) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. ) ;; Setting up use-package (require 'use-package) (setq use-package-always-ensure t) #+end_src #+RESULTS: : t ** Fonts #+begin_src emacs-lisp ;; Default fonts (add-to-list 'default-frame-alist '(font . "Mononoki Nerd Font" )) (set-face-attribute 'default t :font "Mononoki Nerd Font" ) (use-package unicode-fonts :init (unicode-fonts-setup)) (set-fontset-font "fontset-startup" 'unicode (font-spec :name "Mononoki Nerd Font" :size 14)) ;; Fallback for emojies (set-fontset-font "fontset-default" 'unicode (font-spec :name "Twemoji" :size 14)) #+end_src #+RESULTS: *** Theme #+begin_src emacs-lisp (load-theme 'doom-gruvbox) #+end_src #+RESULTS: : t ** Emojies #+begin_src emacs-lisp ;; Emojies (use-package emojify :hook (after-init . global-emojify-mode) :config (setq emojify-emoji-set "twemoji-v2") (setq emojify-set-emoji-styles 'unicode) (setq emojify-display-style 'unicode)) #+end_src #+RESULTS: | org-roam-mode | global-emojify-mode | x-wm-set-size-hint | tramp-register-archive-file-name-handler | magit-maybe-define-global-key-bindings | ** Modeline (bottom bar) #+begin_src emacs-lisp ;; mode line (require 'doom-modeline) (doom-modeline-mode 1) #+end_src #+RESULTS: : t ** Line numbers #+begin_src emacs-lisp ;; Line numbers (column-number-mode) ;; Enable line numbers for some modes (dolist (mode '(text-mode-hook prog-mode-hook conf-mode-hook)) (add-hook mode (lambda () (display-line-numbers-mode 1) (setq display-line-numbers 'relative)))) ;; Override some modes which derive from the above (dolist (mode '(org-mode-hook)) (add-hook mode (lambda () (display-line-numbers-mode 0)))) #+end_src #+RESULTS: * Evil mode #+begin_src emacs-lisp (use-package evil :ensure t :init (setq evil-want-integration t) ;; This is optional since it's already set to t by default. (setq evil-want-keybinding nil) :config (evil-mode 1) (define-key evil-insert-state-map (kbd "C-g") 'evil-normal-state) (evil-global-set-key 'motion "j" 'evil-next-visual-line) (evil-global-set-key 'motion "k" 'evil-previous-visual-line)) (use-package undo-tree :after evil :init (global-undo-tree-mode) (evil-set-undo-system 'undo-tree)) (use-package evil-mc :after evil :config (evil-mc-mode 1) ;; enable (global-set-key (kbd "") 'keyboard-escape-quit) :bind ( :map evil-normal-state-map ("SPC m u" . evil-mc-undo-all-cursors) :map evil-visual-state-map ("SPC m a" . evil-mc-make-cursor-in-visual-selection-beg))) (use-package evil-collection :ensure t :after evil :config (evil-collection-init)) #+end_src #+RESULTS: : t * Completition #+begin_src emacs-lisp (use-package counsel) (use-package ivy :diminish :bind ( ("M-x" . counsel-M-x) ("C-s" . swiper) :map ivy-minibuffer-map ("TAB" . ivy-alt-done) ("C-f" . ivy-alt-done) ("C-l" . ivy-alt-done) ("C-j" . ivy-next-line) ("C-k" . ivy-previous-line) :map ivy-switch-buffer-map ("C-k" . ivy-previous-line) ("C-l" . ivy-done) ("C-d" . ivy-switch-buffer-kill) :map ivy-reverse-i-search-map ("C-k" . ivy-previous-line) ("C-d" . ivy-reverse-i-search-kill)) :init (ivy-mode 1)) (use-package smex :after counsel) #+end_src #+RESULTS: : ivy-reverse-i-search-kill * Keybindings #+begin_src emacs-lisp (defun add-to-map(keys func) "Add a keybinding in evil mode from keys to func." (define-key evil-normal-state-map (kbd keys) func) (define-key evil-motion-state-map (kbd keys) func)) (add-to-map "" nil) (add-to-map " s" 'save-buffer) (defun open-file (file) "just more shortest function for opening the file" (interactive) ((lambda (file) (interactive) (find-file (expand-file-name (format "%s" file)))) file ) ) (general-evil-setup) (general-define-key :prefix "SPC" :keymaps 'normal "o" '(treemacs :which-key "treemacs") "SPC" '(counsel-M-x :which-key "M-x") ;; org-roam ;; dotfiles editing config "f f" '(counsel-find-file :which-key "find-file") "f r" '(counsel-buffer-or-recentf :which-key "recent files") ;; switch buffer "b b" '(counsel-switch-buffer :which-key "switch buff") ;; Theme "h" '(counsel-load-theme :which-key "switch theme") ;; Org-roam keymap "r d" '(org-roam-toady :which-key "roam today") "r t a" '(org-roam-tag-add :which-key "roam add tag") "r t d" '(org-roam-tag-delete :which-key "roam delete tag") "r a a" '(org-roam-alias-add :which-key "roam add alias") "r f f" '(org-roam-find-file :which-key "roam findgfile ") "r g" '(org-roam-graph-show :which-key "roam graph ") "r b b" '(org-roam-buffer-toggle-display :which-key "roam buffer toggle ") "r b s" '(org-roam-buffer-activate :which-key "roam buffer show ") "r b h" '(org-roam-buffer-deactivate :which-key "roam buffer hide ") ;; Bind keymaps "p" '(:keymap projectile-command-map :package projectile) "w" '(:keymap evil-window-map :package evil) "t" '(:keymap tab-bar-map :package tab-bar) ;; Edit common files "f e" '(lambda() (interactive) (find-file "~/.emacs.d/config.org") :which-key "config.org") "f v" '(lambda() (interactive) (find-file "~/.config/nvim/init.vim" :which-key "neovim config" )) "f d" '(lambda() (interactive) (find-file "~/dotfiles/home" :which-key "dotfiles dired" )) "f a" '(lambda() (interactive) (find-file "~/.config/alacritty/alacritty.yml" :which-key "alacritty")) "f b" '(lambda() (interactive) (find-file "~/Brain" :which-key "my brain"))) #+end_src #+RESULTS: * Features ** Org roam #+begin_src emacs-lisp (use-package org-roam :ensure t :hook (after-init . org-roam-mode) :custom (org-roam-directory "~/Brain") :config (setq org-roam-server-host "127.0.0.1" org-roam-server-port 5034 org-roam-server-authenticate nil org-roam-server-export-inline-images t org-roam-server-serve-files nil org-roam-server-served-file-extensions '("pdf" "mp4" "ogv") org-roam-server-network-poll t org-roam-server-network-arrows nil org-roam-server-network-label-truncate t org-roam-server-network-label-truncate-length 60 org-roam-server-network-label-wrap-length 20) :bind (:map org-roam-mode-map (("C-c o l" . org-roam) ("C-c o f" . org-roam-find-file) ("C-c o g" . org-roam-graph) ("C-c o t" . org-roam-dailies-capture-today)) :map org-mode-map (("C-c o i" . org-roam-insert)) (("C-c o I" . org-roam-insert-immediate)))) #+end_src #+RESULTS: : org-roam-insert-immediate ** Org roam protocol #+begin_src emacs-lisp (require 'org-roam-protocol) #+end_src #+RESULTS: : org-roam-protocol ** Interaction log #+begin_src emacs-lisp (use-package interaction-log :ensure t) #+end_src #+RESULTS: ** Rainbow brakets #+begin_src emacs-lisp (use-package highlight-parentheses :ensure t :init (global-highlight-parentheses-mode t) (show-paren-mode t)) ; (use-package rainbow-delimiters :hook (prog-mode . rainbow-delimiters-mode)) #+end_src #+RESULTS: | rainbow-delimiters-mode | (lambda nil (display-line-numbers-mode 1) (setq display-line-numbers 'relative)) | ** Which key (keybindings autocompletition ) #+begin_src emacs-lisp ;;Which key (use-package which-key :init (which-key-mode) :diminish which-key-mode :config (setq which-key-idle-delay 0.3)) (use-package ivy-rich :init (ivy-rich-mode 1)) #+end_src #+RESULTS: ** Treemacs (file tree) #+begin_src emacs-lisp (use-package all-the-icons) (use-package treemacs-all-the-icons) (use-package treemacs :after all-the-icons :ensure t :defer t :init (with-eval-after-load 'winum (define-key winum-keymap (kbd "M-0") #'treemacs-select-window)) :config (progn (setq treemacs-collapse-dirs (if treemacs-python-executable 3 0) treemacs-deferred-git-apply-delay 0.5 treemacs-directory-name-transformer #'identity treemacs-display-in-side-window t treemacs-eldoc-display t treemacs-file-event-delay 5000 treemacs-file-extension-regex treemacs-last-period-regex-value treemacs-file-follow-delay 0.2 treemacs-file-name-transformer #'identity treemacs-follow-after-init t treemacs-git-command-pipe "" treemacs-goto-tag-strategy 'refetch-index treemacs-indentation 2 treemacs-indentation-string " " treemacs-is-never-other-window nil treemacs-max-git-entries 5000 treemacs-missing-project-action 'ask treemacs-move-forward-on-expand nil treemacs-no-png-images nil treemacs-no-delete-other-windows t treemacs-project-follow-cleanup nil treemacs-persist-file (expand-file-name ".cache/treemacs-persist" user-emacs-directory) treemacs-position 'left treemacs-read-string-input 'from-child-frame treemacs-recenter-distance 0.1 treemacs-recenter-after-file-follow nil treemacs-recenter-after-tag-follow nil treemacs-recenter-after-project-jump 'always treemacs-recenter-after-project-expand 'on-distance treemacs-show-cursor nil treemacs-show-hidden-files t treemacs-silent-filewatch nil treemacs-silent-refresh nil treemacs-sorting 'alphabetic-asc treemacs-space-between-root-nodes t treemacs-tag-follow-cleanup t treemacs-tag-follow-delay 1.5 treemacs-user-mode-line-format nil treemacs-user-header-line-format nil treemacs-width 35 treemacs-workspace-switch-cleanup nil) ;; The default width and height of the icons is 22 pixels. If you are ;; using a Hi-DPI display, uncomment this to double the icon size. ;;(treemacs-resize-icons 44) (treemacs-follow-mode t) (treemacs-filewatch-mode t) (treemacs-load-theme 'all-the-icons) (treemacs-fringe-indicator-mode 'always) (pcase (cons (not (null (executable-find "git"))) (not (null treemacs-python-executable))) (`(t . t) (treemacs-git-mode 'deferred)) (`(t . _) (treemacs-git-mode 'simple)))) :bind (:map global-map ("M-0" . treemacs-select-window) ("C-x t 1" . treemacs-delete-other-windows) ("C-o" . treemacs) ("C-x t B" . treemacs-bookmark) ("C-x t C-t" . treemacs-find-file) ("C-x t M-t" . treemacs-find-tag))) (use-package treemacs-evil :after (treemacs evil) :ensure t ) (use-package treemacs-projectile :after (treemacs projectile) :ensure t) (use-package treemacs-icons-dired :after (treemacs dired) :ensure t :config (treemacs-icons-dired-mode)) (use-package treemacs-magit :after (treemacs magit) :ensure t) (use-package treemacs-persp ;;treemacs-perspective if you use perspective.el vs. persp-mode :after (treemacs persp-mode) ;;or perspective vs. persp-mode :ensure t :config (treemacs-set-scope-type 'Perspectives)) (use-package neotree :ensure t :init (setq neo-theme (if (display-graphic-p) 'icons 'arrow))) #+end_src #+RESULTS: ** Literate programming #+begin_src emacs-lisp (org-babel-do-load-languages 'org-babel-load-languages '((python . t))) #+end_src #+RESULTS: ** Projects #+begin_src emacs-lisp (use-package projectile :diminish projectile-mode :config (projectile-mode) :init (setq projectile-switch-project-action #'projectile-deired)) (use-package counsel-projectile :config (counsel-projectile-mode)) #+end_src ** Magit #+begin_src emacs-lisp (use-package magit) #+end_src #+RESULTS: : t ** Workspaces #+begin_src emacs-lisp (use-package workgroups2) #+end_src * Org mode #+begin_src emacs-lisp (defun org-mode-setup() (org-indend-mode) (variable-pitch-mode 1) (auto-fill-mode 0) (visual-line-mode 1) (setq evil-auto indent 1)) (use-package org :config) (use-package org-bullets :after org :hook (org-mode . org-bullets-mode)) (set-face-attribute 'org-document-title nil :font "hack" :weight 'bold :height 1.3) (dolist (face '((org-level-1 . 1.3) (org-level-2 . 1.2) (org-level-3 . 1.05) (org-level-4 . 1.0) (org-level-5 . 1.1) (org-level-6 . 1.1) (org-level-7 . 1.1) (org-level-8 . 1.1))) (set-face-attribute (car face) nil :font "hack" :weight 'bold :height (cdr face))) (require 'org-indent) (set-face-attribute 'org-block nil :foreground nil :inherit 'fixed-pitch :font "mononoki" ) (set-face-attribute 'org-table nil :inherit 'fixed-pitch) (set-face-attribute 'org-formula nil :inherit 'fixed-pitch) (set-face-attribute 'org-code nil :inherit '(shadow fixed-pitch)) (set-face-attribute 'org-indent nil :inherit '(org-hide 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) ;; Get rid of the background on column views (set-face-attribute 'org-column nil :background nil) (set-face-attribute 'org-column-title nil :background nil) (setq org-src-fontify-natively t) (defun my/visual-fill () (setq visual-fill-column-width 140 visual-fill-column-center-text t) (visual-fill-column-mode 1)) (use-package visual-fill-column :defer t :hook (org-mode . my/visual-fill)) #+end_src #+RESULTS: | my/visual-fill | org-bullets-mode | #[0 \301\211\207 [imenu-create-index-function org-imenu-get-tree] 2] | #[0 \300\301\302\303\304$\207 [add-hook change-major-mode-hook org-show-all append local] 5] | #[0 \300\301\302\303\304$\207 [add-hook change-major-mode-hook org-babel-show-result-all append local] 5] | org-babel-result-hide-spec | org-babel-hide-all-hashes | (lambda nil (display-line-numbers-mode 0)) | ** Templates ~(