;; --- FUNCTIONS --- (defun load-if-exists (filename) (when (file-exists-p filename) (load-file filename))) (defun bab/disable-line-numbers (&optional dummy dummy2) (display-line-numbers-mode -1)) (defun bab/sidebar-toggle () "Toggle both `dired-sidebar' and `ibuffer-sidebar'." (interactive) (dired-sidebar-toggle-sidebar) (ibuffer-sidebar-toggle-sidebar)) ;; --- BUG WORKAROUNDS --- ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=34341 ;; Affects ability to use the gnu package repository on gnutls 3.6. ;; Should recheck when emacs >26 is out. (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3") ;; https://stackoverflow.com/questions/26108655/ ;; https://lists.gnu.org/archive/html/bug-gnu-emacs/2014-12/msg00781.html ;; Apparently the gnu package repository has had unverifiable ;; signatures since 2014 and nobody cares ¯\_(ツ)_/¯ (setq package-check-signature nil) ;; --- TERMINAL SUPPORT --- (add-to-list 'term-file-aliases '("st-256color" . "tmux-256color")) ;; --- PACKAGE REPOSITORIES --- (require 'package) (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/") ("melpa" . "https://melpa.org/packages/"))) (package-initialize) (require 'use-package) (require 'whitespace) (require 'yasnippet) (require 'evil) ;; --- GLOBAL MODES --- (evil-mode 1) ;; Make emacs usable (global-hl-line-mode 1) ;; Highlight the line containing the cursor (show-paren-mode 1) ;; Highlight matching parenthesis (use-package ivy :config (setq ivy-use-virtual-buffers t enable-recursive-minibuffers t) (ivy-mode 1)) (use-package flycheck :ensure t :config (add-to-list 'display-buffer-alist `(,(rx bos "*Flycheck errors*" eos) (display-buffer-reuse-window display-buffer-in-side-window) (side . bottom) (reusable-frames . visible) (window-height . 0.33))) :init (global-flycheck-mode)) ;; --- ORG MODE --- (use-package org-ql :demand t :mode (("\\.org$" . org-mode)) :init (add-to-list 'auto-mode-alist `(,(expand-file-name "~/org/") . org-mode)) :bind (("C-c a" . org-agenda)) :hook (org-agenda-finalize . bab/disable-line-numbers) :config (org-super-agenda-mode 1) (load-file "~/.emacs.d/org-mode.el")) (use-package calfw-org :demand t) ;; --- PROJECTS --- (use-package projectile :demand t :config (setq projectile-completion-system 'ivy) (projectile-mode 1) :bind-keymap ("C-c p" . projectile-command-map)) (use-package counsel-projectile :config (counsel-projectile-mode 1) :after (ivy projectile)) ;; --- GIT INTEGRATION --- (use-package magit :commands (magit-status) :bind (("" . magit-status)) :hook (magit-status-mode . bab/disable-line-numbers)) ;; --- FILE TREE / BUFFER LIST --- (use-package projectile-speedbar :bind ("" . projectile-speedbar-toggle) :hook (speedbar-mode . bab/disable-line-numbers)) ;; --- AUTO-COMPLETE --- (use-package company :config (global-company-mode) (require 'color) (let ((bg "midnight blue")) (set-face-attribute 'company-tooltip nil :background bg) (set-face-attribute 'company-scrollbar-bg nil :background (color-lighten-name bg 20)) (set-face-attribute 'company-scrollbar-fg nil :background (color-lighten-name bg 40))) ) (use-package company-posframe :after company :config (setq company-posframe-show-indicator nil company-posframe-quickhelp-delay nil) (company-posframe-mode 1) ) (use-package company-c-headers :after company :config (push 'company-c-headers company-backends)) (use-package company-lsp :after company :config (push 'company-lsp company-backends)) ;; --- LANGUAGE SERVERS --- (use-package lsp-mode :hook (typescript-mode . lsp-deferred) :commands (lsp lsp-deferred)) (use-package lsp-ui :hook (lsp-mode . lsp-ui-mode)) (use-package company-lsp :commands company-lsp) ;; --- AUTO-FORMAT ON SAVE --- (use-package prettier-js :config (setq prettier-js-args '("--trailing-comma" "all" "--use-tabs" "true" "--print-width" "110" "--arrow-parens" "avoid" "--end-of-line" "auto")) :hook (typescript-mode . prettier-js-mode)) ;; --- THEME --- (use-package doom-themes :config (setq doom-themes-enable-bold t doom-themes-enable-italic t) (load-theme 'doom-palenight t) (doom-themes-visual-bell-config) (doom-themes-neotree-config) (doom-themes-org-config)) ;; --- TODO --- ;;(require 'undo-tree) ;; --- POWERLINE --- (require 'telephone-line) (telephone-line-mode 1) ;; --- WHITESPACE --- ;; Show whitespace for prog-mode, but not other modes (define-global-minor-mode bab/global-whitespace-mode whitespace-mode (lambda () (when (derived-mode-p 'prog-mode) (whitespace-mode)))) (bab/global-whitespace-mode 1) ;; --- INDENTATION --- ;; Two callable functions for enabling/disabling tabs in Emacs (defun disable-tabs () (setq indent-tabs-mode nil)) (defun enable-tabs () (local-set-key (kbd "TAB") 'tab-to-tab-stop) (setq indent-tabs-mode t)) ;; Hooks to Enable Tabs (add-hook 'prog-mode-hook 'enable-tabs) ;; Hooks to Disable Tabs ;; Using tabs in lisp just leads to mixing tabs and spaces, which is yucky (add-hook 'lisp-mode-hook 'disable-tabs) (add-hook 'emacs-lisp-mode-hook 'disable-tabs) ;; --- GENERAL PREFERENCES --- (setq-default ;; --- THEME CONFIGURATION --- ;;dracula-enlarge-headings nil ;; -- TABS AND INDENTATION -- ;; Set tab stops to every four spaces tab-width 4 ;; Tab key indents if cursor at start of line, otherwise inserts tab character tab-always-indent nil ;; Backspace deletes one whole tab character backward-delete-char-untabify-method nil ;; --- MOUSE --- ;; Don't speed up during continued mouse wheel scrolling mouse-wheel-progressive-speed nil ;; -- C LANGUAGE -- ;; Overall tab and brace placement style c-default-style "linux" ;; Indent width c-basic-offset 4 ;; -- LISP -- inferior-lisp-program "sbcl" ;; -- WHITESPACE -- ;; Clean up trailing whitespace automatically on save whitespace-action '(auto-cleanup) ;; Configure what to highlight. ;; Main difference from default is that for overlong lines, ;; we only highlight the overlong tail, not the whole line whitespace-style '(face trailing tabs spaces lines-tail empty indentation space-after-tab space-before-tab space-mark tab-mark) ;; -- MISC -- ;; Display line numbers, relative to the current line display-line-numbers 'relative ;; Don't show the emacs startup screen inhibit-startup-screen t ) (let ((fg "RoyalBlue4") (bg 'unspecified) (faces '(whitespace-hspace whitespace-newline whitespace-space whitespace-tab))) (dolist (face faces) (set-face-attribute face nil :foreground fg :background bg))) (load-if-exists "~/.emacs.d/local.el") (setq custom-file "~/.emacs.d/custom.el") (load-file custom-file)