(setq gc-cons-threshold 100000000) (add-to-list 'load-path "~/.emacs.d/lisp/") (require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (package-initialize) ;; disable menu bar, tool bar, scroll bar and savehist (menu-bar-mode -1) (tool-bar-mode -1) (scroll-bar-mode -1) (savehist-mode -1) ;; evil-mode (package-install 'evil) (evil-mode) ;; undo-tree (package-install 'undo-tree) (global-undo-tree-mode) (evil-set-undo-system 'undo-tree) ;; basic key binds (global-set-key (kbd "C-`") 'other-window) (global-set-key (kbd "C-c c") 'compile) (global-set-key (kbd "C-c r") 'recompile) (global-set-key (kbd "C-c k") 'kill-current-buffer) ;; some packages (package-install 'nerd-icons) (package-install 'sudo-edit) ;; modes (require 'cc-mode) (package-install 'd-mode) (package-install 'git-modes) (package-install 'json-mode) (package-install 'lua-mode) (package-install 'markdown-mode) (package-install 'nix-mode) (package-install 'yaml-mode) ;; hooks (defun indent-common-hook () ;; turn off smart indent (electric-indent-mode -1) ;; set indent width to 4 spaces (setq tab-width 4 c-basic-offset 4 c-syntactic-indentation nil c-ts-mode-indent-offset 4 lua-indent-level 4)) (defun indent-tab-hook () (indent-common-hook) (setq indent-tabs-mode t)) (defun indent-spc-hook () (indent-common-hook) (setq indent-tabs-mode nil)) (add-hook 'prog-mode-hook 'display-line-numbers-mode) (add-hook 'text-mode-hook 'hl-line-mode) (add-hook 'prog-mode-hook 'indent-tab-hook) (add-hook 'sgml-mode-hook 'indent-spc-hook) (defun lisp-hook () (indent-spc-hook) (keymap-local-set "C-c l" 'common-lisp-hyperspec)) (add-hook 'lisp-mode-hook 'lisp-hook) (add-hook 'lisp-data-mode-hook 'lisp-hook) (setq fill-column 74) (add-hook 'mail-mode-hook 'auto-fill-mode) (add-hook 'markdown-mode-hook 'auto-fill-mode) (add-hook 'nroff-mode-hook 'auto-fill-mode) (add-hook 'nroff-mode-hook 'variable-pitch-mode) ;; file extensions (add-to-list 'auto-mode-alist '("\\.eml\\'" . mail-mode)) (add-to-list 'auto-mode-alist '("\\.scd\\'" . markdown-mode)) (add-to-list 'auto-mode-alist '("\\.3lua\\'" . nroff-mode)) ;; treesitter modes (setq major-mode-remap-alist '((c-mode . c-ts-mode) (c++-mode . c++-ts-mode) (sh-mode . bash-ts-mode))) ;; fix to make d-mode highlight primitive types properly (font-lock-add-keywords 'd-mode '(("\\<\\(bool\\|byte\\|ubyte\\|char\\|delegate\\|double\\|float\\|function\\|int\\|long\\|short\\|uint\\|ulong\\|ushort\\|cent\\|ucent\\|real\\|ireal\\|idouble\\|ifloat\\|creal\\|cfloat\\|cdouble\\|wchar\\|dchar\\|void\\|string\\|wstring\\|dstring\\|__vector\\|Runtime\\|Thread\\)\\>" . 'font-lock-type-face))) ;; highlight colours (package-install 'rainbow-mode) (add-hook 'prog-mode-hook 'rainbow-mode) ;; rainbow parens in lisp-mode (package-install 'rainbow-delimiters) (add-hook 'lisp-mode-hook 'rainbow-delimiters-mode) (add-hook 'lisp-data-mode-hook 'rainbow-delimiters-mode) ;; modernize org-mode (package-install 'org-modern) (add-hook 'org-mode-hook 'org-modern-mode) ;; create a TOC on saving an org document (package-install 'toc-org) (add-hook 'org-mode-hook 'toc-org-mode) ;; enable spell checking in org mode (add-hook 'org-mode-hook #'(lambda () (flyspell-mode))) ;; minibuffer completion (package-install 'marginalia) (package-install 'vertico) (marginalia-mode) (vertico-mode) ;; company completion + eglot (package-install 'company) (require 'company) (require 'eglot) (add-hook 'after-init-hook 'global-company-mode) (add-hook 'prog-mode-hook 'eglot-ensure) (add-to-list 'eglot-server-programs `(d-mode . ("~/.local/bin/serve-d"))) (setq company-begin-commands '(self-insert-command) company-idle-delay .1 company-minimum-prefix-length 2 company-show-numbers t company-tooltip-align-annotations 't) (setq read-buffer-completion-ignore-case t read-file-name-completion-ignore-case t completion-ignore-case t) ;; diff information in the gutter (package-install 'diff-hl) (global-diff-hl-mode) (add-hook 'magit-pre-refresh-hook 'diff-hl-magit-pre-refresh) (add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh) ;; editorconfig (package-install 'editorconfig) (editorconfig-mode) ;; which-key ;; shows available key binds (package-install 'which-key) (which-key-mode) (setq which-key-side-window-location 'bottom which-key-sort-order 'which-key-key-order-alpha 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 t which-key-separator " ") ;; image-dired (package-install 'image-dired) (global-set-key (kbd "C-c i") 'image-dired) (add-hook 'image-dired-thumbnail-mode-hook #'(lambda () (keymap-local-set "M-RET" 'image-dired-display-this))) ;; magit (package-install 'magit) (global-set-key (kbd "C-c b") 'magit-blame) ;; fonts (let ((font-fixed "Roboto Mono") (font-varpt "Roboto")) (add-to-list 'default-frame-alist '(font . "Roboto Mono")) (set-face-attribute 'default t :height 140) (set-face-attribute 'fixed-pitch t :family font-fixed) (set-face-attribute 'variable-pitch t :family font-varpt) (set-face-attribute 'fixed-pitch-serif t :family font-fixed :weight 'regular)) ;; make comments italic (set-face-attribute 'font-lock-comment-face t :slant 'italic) (set-face-attribute 'font-lock-keyword-face t :slant 'italic) (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. '(custom-button ((t (:background "#181825" :foreground "white" :box (:line-width (1 . 1) :color "#11111b" :style flat-button))))) '(custom-button-mouse ((t (:background "#11111b" :foreground "white")))) '(custom-button-pressed ((t (:inherit custom-button-mouse :box (:line-width (1 . 1) :color "#11111b"))))) '(help-key-binding ((t (:inherit fixed-pitch :background "#181825" :foreground "#89b4fa" :box (:line-width (-1 . -1) :color "#11111b"))))) '(link ((t (:foreground "#89b4fa" :underline t)))) '(widget-field ((t (:extend t :background "#181825" :box (:line-width (1 . 1) :color "#11111b")))))) (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. '(package-selected-packages '(image-dired breadcrumb nyan-mode simple-modeline catppuccin-theme magit which-key editorconfig diff-hl company vertico marginalia toc-org org-modern rainbow-delimiters rainbow-mode yaml-mode nix-mode markdown-mode lua-mode json-mode git-modes d-mode sudo-edit nerd-icons undo-tree evil))) ;; catppuccin theme (package-install 'catppuccin-theme) (setq catppuccin-flavor 'mocha) (load-theme 'catppuccin :no-confirm) ;; alpha (add-to-list 'default-frame-alist '(alpha-background . 96)) ;; simple-modeline (package-install 'simple-modeline) (simple-modeline-mode) (column-number-mode) ;; nyan-mode (package-install 'nyan-mode) (setq nyan-animate-nyancat t) (nyan-mode) ;; modeline segments (setq simple-modeline-segments ;; left side (let ((separator (lambda () (format " ")))) '((simple-modeline-segment-modified simple-modeline-segment-buffer-name simple-modeline-segment-position separator nyan-create (lambda () (format " ")) (lambda () (format "%d" (count-lines (point-min) (point-max))))) ;; right side (simple-modeline-segment-vc separator simple-modeline-segment-encoding simple-modeline-segment-eol separator simple-modeline-segment-major-mode)))) ;; breadcrumbs (package-install 'breadcrumb) (setq breadcrumb-project-crumb-separator "  " breadcrumb-imenu-crumb-separator "  ") (add-hook 'prog-mode-hook #'(lambda () (setq header-line-format '( " " (:eval (breadcrumb-project-crumbs)) " : " (:eval (breadcrumb-imenu-crumbs)))))) ;; misc ;; guess the major mode from file name (setq-default major-mode (lambda () (unless buffer-file-name (let ((buffer-file-name (buffer-name))) (set-auto-mode))))) ;; save files and your position in them (save-place-mode) (recentf-mode) ;; show opening paren context if it's offscreen (setq show-paren-context-when-offscreen 'overlay) ;; frames/windows resize pixelwise (setq frame-resize-pixelwise t window-resize-pixelwise t)