init.el/README.org

232 lines
5.8 KiB
Org Mode
Raw Normal View History

2024-09-06 05:08:40 -04:00
#+TITLE: Emacs Configuration
#+AUTHOR: frosty
#+EMAIL: passedgoandgot200@gmail.com
#+OPTIONS: num:nil
2024-09-06 05:33:33 -04:00
* Package Bootstrapping
2024-09-06 05:08:40 -04:00
#+BEGIN_SRC emacs-lisp
2024-09-06 05:33:33 -04:00
;; Add MELPA to the repositories list
2024-09-06 05:08:40 -04:00
(require 'package)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/") t)
2024-09-06 05:33:33 -04:00
;; Load packages list
2024-09-06 05:08:40 -04:00
(package-initialize)
2024-09-06 05:33:33 -04:00
;; Setup `use-package'
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-when-compile
(require 'use-package))
#+END_SRC
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
* Look and Feel
#+BEGIN_SRC emacs-lisp
2024-09-06 05:08:40 -04:00
;; Set the theme
2024-09-06 05:33:33 -04:00
(use-package ample-theme
:ensure t
:config (load-theme 'ample t))
2024-09-06 05:08:40 -04:00
;; Disable menu bar
(menu-bar-mode -1)
;; Disable tool bar
(tool-bar-mode -1)
;; Disable scroll bars
(toggle-scroll-bar -1)
;; Disable splash screen
(setq inhibit-startup-screen t)
;; Display line numbers
(global-display-line-numbers-mode 1)
(setq-default display-line-numbers-width 3)
;; Highlight current line
(global-hl-line-mode 1)
;; Show trailing whitespace
(setq-default show-trailing-whitespace t)
;; Flash mode line on bell
2024-09-06 05:33:33 -04:00
(use-package mode-line-bell
:ensure t
:config (mode-line-bell-mode))
#+END_SRC
#+BEGIN_SRC emacs-lisp
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;;; Buffer input and interaction
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;; Better mouse scrolling
(setq mouse-wheel-progressive-speed nil)
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;; Use short yes/no answers
(setq-default use-short-answers t)
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;; Auto-pair parenthesis
(electric-pair-mode 1)
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;; VIM emulation
(unless (package-installed-p 'evil)
(package-install 'evil))
(setq
;; Scroll up with C-u
evil-want-C-u-scroll t
;; Yank to EOL with Y
evil-want-Y-yank-to-eol t
;; Create split windows below
evil-split-window-below t
;; Create vsplit windows to the right
evil-vsplit-window-right t)
(require 'evil)
(evil-mode 1)
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;; Automatically trim trailing whitespace on save
(add-hook 'before-save-hook 'delete-trailing-whitespace)
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;;; General interface
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;; Completion UI
(unless (package-installed-p 'vertico)
(package-install 'vertico))
(require 'vertico)
(vertico-mode 1)
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;; Improve directory navigation
(define-key vertico-map (kbd "RET") #'vertico-directory-enter)
(define-key vertico-map (kbd "DEL") #'vertico-directory-delete-word)
(define-key vertico-map (kbd "M-d") #'vertico-directory-delete-char)
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;;; Extended completion utilities
(unless (package-installed-p 'consult)
(package-install 'consult))
(global-set-key [rebind switch-to-buffer] #'consult-buffer)
(global-set-key (kbd "C-c j") #'consult-line)
(global-set-key (kbd "C-c i") #'consult-imenu)
(setq read-buffer-completion-ignore-case t
read-file-name-completion-ignore-case t
completion-ignore-case t)
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;;; LSP Support
(unless (package-installed-p 'eglot)
(package-install 'eglot))
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;; Enable LSP support by default in programming buffers
(add-hook 'prog-mode-hook #'eglot-ensure)
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;; Create a memorable alias for `eglot-ensure'.
(defalias 'start-lsp-server #'eglot)
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;; Completion style
(unless (package-installed-p 'orderless)
(package-install 'orderless))
(require 'orderless)
(setq completion-styles '(orderless basic)
completion-category-overrides '((file (styles basic partial-completion))))
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;; Persist history over restarts
(require 'savehist)
(savehist-mode 1)
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;;; Inline static analysis
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;; Enabled inline static analysis
(add-hook 'prog-mode-hook #'flymake-mode)
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;; Display messages when idle, without prompting
(setq help-at-pt-display-when-idle t)
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;; Message navigation bindings
(with-eval-after-load 'flymake
(define-key flymake-mode-map (kbd "C-c n") #'flymake-goto-next-error)
(define-key flymake-mode-map (kbd "C-c p") #'flymake-goto-prev-error))
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;;; Pop-up completion
(unless (package-installed-p 'corfu)
(package-install 'corfu))
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;; Enable autocompletion by default in programming buffers
(add-hook 'prog-mode-hook #'corfu-mode)
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;; Enable automatic completion.
(setq corfu-auto t)
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;;; Git client
(unless (package-installed-p 'magit)
(package-install 'magit))
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;; Bind the `magit-status' command to a convenient key.
(global-set-key (kbd "C-c g") #'magit-status)
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;;; Indication of local VCS changes
(unless (package-installed-p 'diff-hl)
(package-install 'diff-hl))
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;; Enable `diff-hl' support by default in programming buffers
(add-hook 'prog-mode-hook #'diff-hl-mode)
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;;; Go Support
(unless (package-installed-p 'go-mode)
(package-install 'go-mode))
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;;; JSON Support
(unless (package-installed-p 'json-mode)
(package-install 'json-mode))
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;;; Lua Support
(unless (package-installed-p 'lua-mode)
(package-install 'lua-mode))
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;;; Rust Support
(unless (package-installed-p 'rust-mode)
(package-install 'rust-mode))
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;;; YAML Support
(unless (package-installed-p 'yaml-mode)
(package-install 'yaml-mode))
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;;; Markdown support
(unless (package-installed-p 'markdown-mode)
(package-install 'markdown-mode))
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;;; EditorConfig support
(unless (package-installed-p 'editorconfig)
(package-install 'editorconfig))
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;; Enable EditorConfig
(editorconfig-mode t)
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;;; In-Emacs Terminal Emulation
(unless (package-installed-p 'eat)
(package-install 'eat))
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;; Close the terminal buffer when the shell terminates.
(setq eat-kill-buffer-on-exit t)
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;; Enable mouse-support.
(setq eat-enable-mouse t)
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;;; Jump to arbitrary positions
(unless (package-installed-p 'avy)
(package-install 'avy))
(global-set-key (kbd "C-c z") #'avy-goto-word-1)
2024-09-06 05:08:40 -04:00
2024-09-06 05:33:33 -04:00
;; Store automatic customisation options elsewhere
(setq custom-file (locate-user-emacs-file "custom.el"))
(when (file-exists-p custom-file)
(load custom-file))
2024-09-06 05:08:40 -04:00
#+END_SRC