;;; init.el --- Tavo's emacs config ;;; Commentary: ;;; M-x nerd-icons-install-fonts ;;; M-x all-the-icons-install-fonts ;;; Code: ;; --- Prerequisites for elpa---- ; (unless (file-directory-p "~/.config/emacs/elpa/gnupg") ; (make-directory "~/.config/emacs/elpa/gnupg") ; (shell-command "gpg --homedir ~/.config/emacs/elpa/gnupg --keyserver hkp://keyserver.ubuntu.com --recv-keys 645357D2883A0966") ; (shell-command "find ~/.config/emacs/elpa/gnupg -type d -exec chmod 700 {} \;") ; (shell-command "find ~/.config/emacs/elpa/gnupg -type f -exec chmod 600 {} \;")) ;; --- ;; --- Preferences --- (setq custom-file (concat user-emacs-directory "custom.el")) (load custom-file 'noerror) (setq warning-minimum-level :error) (setq scroll-step 1 scroll-conservatively 10000) (scroll-bar-mode 0) (menu-bar-mode 0) (tool-bar-mode 0) (global-display-line-numbers-mode 1) (setq-default display-line-numbers-width 3) (delete-selection-mode 1) (electric-indent-mode 0) (global-hl-line-mode 1) (electric-pair-mode 1) (column-number-mode) (dolist (dir '("~/.local/share/emacs/auto-save/" "~/.local/share/emacs/backup/" "~/.local/share/emacs/lock/" "~/.local/share/emacs/tmp/")) (unless (file-directory-p dir) (make-directory dir t))) (setq lock-file-name-transforms '(("\\`/.*/\\([^/]+\\)\\'" "~/.local/share/emacs/lock/\\1" t))) (setq auto-save-file-name-transforms '((".*" "~/.local/share/emacs/auto-save/" t))) (setq backup-directory-alist '((".*" . "~/.local/share/emacs/backup/"))) (setq temporary-file-directory "~/.local/share/emacs/tmp/") (dolist (mode '(org-mode-hook term-mode-hook shell-mode-hook eshell-mode-hook)) (add-hook mode (lambda () (display-line-numbers-mode 0)))) ;; --- ;; --- Package manager --- (require 'package) (setq package-archives '(("melpa" . "https://melpa.org/packages/"))) (package-initialize) (unless package-archive-contents (package-refresh-contents)) (unless (package-installed-p 'use-package) (package-install 'use-package)) (require 'use-package) (setq use-package-always-ensure t) (dolist (pkg '(all-the-icons nerd-icons markdown-mode markdown-preview-mode)) (unless (package-installed-p pkg) (package-install pkg))) ;; --- ;; --- Theming --- (if (eq system-type 'android) (set-face-attribute 'default nil :height 140) ;; Android (progn ;; Everywhere else (set-face-attribute 'default nil :font "JetBrains Mono") (add-to-list 'default-frame-alist '(font . "JetBrains Mono-10")))) (use-package doom-themes :init (load-theme 'doom-material t)) ;; --- (use-package paren :ensure nil :init (setq show-paren-delay 0) :config (show-paren-mode +1)) (use-package dashboard :ensure t :init (setq dashboard-set-heading-icons t) (setq dashboard-set-file-icons t) (setq dashboard-center-content t) (if (eq system-type 'android) (progn ;; Android (setq dashboard-startupify-list '(dashboard-insert-banner dashboard-insert-items)) (setq dashboard-startup-banner "~/.config/emacs/banner.txt")) (progn ;; Everywhere else (setq dashboard-startupify-list '(dashboard-insert-banner dashboard-insert-banner-title dashboard-insert-items)) (setq dashboard-startup-banner "~/.config/emacs/banner.txt") (setq dashboard-banner-logo-title "✨ M'illumino d'immenso ✨"))) (setq dashboard-items '((recents . 5))) :config (dashboard-setup-startup-hook)) (setq initial-buffer-choice (lambda () (get-buffer-create dashboard-buffer-name))) (use-package evil :init (setq evil-want-integration t evil-want-keybinding nil evil-vsplit-window-right t evil-split-window-below t evil-undo-system 'undo-redo) :config (evil-mode 1)) (use-package evil-collection :after evil :config (evil-collection-init)) ;; --- Org Mode --- (use-package org-bullets) (custom-set-faces '(org-level-1 ((t (:inherit outline-1 :height 1.7)))) '(org-level-2 ((t (:inherit outline-2 :height 1.5)))) '(org-level-3 ((t (:inherit outline-3 :height 1.3)))) '(org-level-4 ((t (:inherit outline-4 :height 1.1))))) (setq org-format-latex-options (plist-put org-format-latex-options :scale 1.35)) (setq org-latex-toc-command "\\clearpage \\tableofcontents \\clearpage") (setq org-highlight-latex-and-related '(latex script entities)) (setq org-startup-with-latex-preview t) (defun my/org-mode-visual-fill () (setq visual-fill-column-width 100 visual-fill-column-center-text t) (visual-fill-column-mode 1)) (if (eq system-type 'android) (message "Android device, ignoring org-mode-visual-fill") ;; Android (progn ;; Everywhere else (use-package visual-fill-column :hook (org-mode . my/org-mode-visual-fill)))) (if (eq system-type 'android) (progn ;; Android custom org-latex-preview (setq org-format-latex-options (plist-put org-format-latex-options :scale 100)) (setq org-preview-latex-process-alist '((dvipngweb :programs ("curl") :description "dvi > png" :message "you need to install the programs: curl." :image-input-type "dvi" :image-output-type "png" :image-size-adjust (1.0 . 1.0) :latex-compiler ("curl -F \"file=@%f\" -F \"type=tex\" 0.0.0.0:8000 && curl 0.0.0.0:8000/tmp.dvi -o %O") :image-converter ("curl -F \"file=@%f\" -F \"type=dvi\" -F \"dpi=%D\" -o %O 0.0.0.0:8000 && curl 0.0.0.0:8000/tmp.png -o %O")))) (setq org-latex-create-formula-image-program 'dvipngweb))) (unless (file-directory-p "~/.local/share/emacs/ltximg/") (make-directory "~/.local/share/emacs/ltximg/")) (setq org-preview-latex-image-directory "~/.local/share/emacs/ltximg/") ;; --- ;; --- Keybinds --- (use-package general :config (general-evil-setup) (general-create-definer tavo/leader-keys :states '(normal insert visual emacs) :keymaps 'override :prefix "SPC" :global-prefix "M-SPC") (tavo/leader-keys "c" '(comment-line :wk "Comment lines") "p" 'org-latex-preview)) (global-set-key (kbd "") 'keyboard-escape-quit) (global-set-key (kbd "C-c") 'kill-this-buffer) (global-set-key (kbd "C-=") 'text-scale-increase) (global-set-key (kbd "C-+") 'text-scale-increase) (global-set-key (kbd "C--") 'text-scale-decrease) ;; Using RETURN to follow links in Org/Evil (with-eval-after-load 'evil-maps (define-key evil-motion-state-map (kbd "SPC") nil) (define-key evil-motion-state-map (kbd "RET") nil) (define-key evil-motion-state-map (kbd "TAB") nil)) (setq org-return-follows-link t) ;; --- (message "init.el loaded successfully") ;; init.el ends here