blob: a2ac78fb82686683eca98a221fc2b93ccab12752 (
plain) (
tree)
|
|
;;; init.el --- This is where all emacs start. -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
;; use utf-8 everywhere
(set-default-coding-systems 'utf-8)
(require 'ibuffer)
(require 'imenu)
(require 'midnight)
(setq auto-save-default nil) ;; no auto save
(setq backup-inhibited t) ;; no backups
(setq confirm-kill-emacs #'yes-or-no-p) ;; ask before killing emacs
(setq create-lockfiles nil) ;; don't use a lock file
(setq cursor-in-non-selected-windows nil) ;; keep cursors and highlights in current window only
(setq delete-by-moving-to-trash t) ;; delete files by moving them to the trash
(setq highlight-nonselected-windows nil) ;; don't highlight inactive windows
(setq history-delete-duplicates t) ;; delete duplicate from history
(setq ibuffer-expert t) ;; set expert mode
(setq ibuffer-jump-offer-only-visible-buffers t)
(setq ibuffer-maybe-show-predicates '("^\\*.*\\*$"))
(setq ibuffer-use-other-window t)
(setq imenu-auto-rescan t) ;; rescan automatically
(setq initial-major-mode 'fundamental-mode) ;; default mode for the scratch buffer
(setq initial-scratch-message "") ;; makes the scratch buffer empty
(setq midnight-period (* 3600 6)) ;; clear buffer every 6 hours
(setq mode-line-default-help-echo nil) ;; don't say anything on mode-line mouseover
(setq require-final-newline t) ;; ensure a new line is present at the bottom of files
(setq ring-bell-function 'ignore) ;; really no bell
(setq sentence-end-double-space nil) ;; it matters for filling
(setq use-short-answers t) ;; use y-or-n
(setq visible-bell nil) ;; no bell
(setq bidi-display-reordering nil) ;; disable bidirectional text support for slight performance bonus
(setq column-number-mode t) ;; show column number in the mode line
;; global minor modes
(fringe-mode '(8 . 0))
(global-auto-revert-mode t)
(save-place-mode t)
(which-key-mode t)
(require 'savehist)
(savehist-mode t)
(setq history-length 100
history-delete-duplicates t
savehist-save-minibuffer-history t)
(require 'recentf)
(recentf-mode t)
(setq recentf-max-saved-items 2000
recentf-max-menu-items 200)
;; some key bindings
(global-set-key (kbd "M-j") 'join-line)
(global-set-key (kbd "C-x C-b") 'ibuffer)
(global-set-key (kbd "C-c y") 'git-link)
(global-set-key (kbd "C-c C-r") 'eval-region)
(global-set-key (kbd "C-c C-d") 'eval-defun)
(global-set-key (kbd "C-c C-b") 'eval-buffer)
(global-set-key (kbd "C-c ! b") 'flymake-show-project-diagnostics)
(global-set-key (kbd "C-c ! n") 'flymake-goto-next-error)
(global-set-key (kbd "C-c ! p") 'flymake-goto-prev-error)
;; load the PATH properly on macOS
(require 'exec-path-from-shell)
(exec-path-from-shell-initialize)
;; ensure we highlights whitespaces
(require 'whitespace)
(dolist (mode-hook '(prog-mode-hook text-mode-hook conf-mode-hook))
(add-hook mode-hook 'whitespace-mode))
(setq whitespace-style '(face trailing lines-tail))
(setq-default show-trailing-whitespace t)
(setq-default indicate-empty-lines t)
;;; dired
(require 'dired)
(setq dired-use-ls-dired t
dired-clean-up-buffers-too nil
dired-dwim-target t
dired-hide-details-hide-information-lines nil
dired-hide-details-hide-symlink-targets nil
dired-recursive-copies 'always
dired-recursive-deletes 'always
dired-no-confirm '(byte-compile chgrp chmod chown copy hardlink symlink touch))
;;; time related configurations
(require 'time)
(setq display-time-24hr-format t
display-time-interval 60
display-time-mode t
display-time-format "%H:%M %d.%m"
display-time-day-and-date t
display-time-default-load-average nil)
(setq world-clock-list t
world-clock-timer-enable t
world-clock-timer-second 60
world-clock-time-format "%R %z %A %d %B")
;; UTC => 02:42 +0000 Wednesday 20 April
;; Berkeley => 19:42 -0700 Tuesday 19 April
(setq zoneinfo-style-world-list '(("UTC" "UTC")
("America/Los_Angeles" "Berkeley")
("America/Denver" "Mountain Time")
("America/Chicago" "Central Time")
("America/New_York" "New York")
("Europe/London" "London")
("Europe/Paris" "Paris")))
;;; magit
(require 'magit)
(setq magit-diff-refine-hunk t
magit-repository-directories '(("~/workspace" . 1))
magit-clone-default-directory "~/workspace/"
magit-repolist-columns '(("Name" 25 magit-repolist-column-ident nil)
("" 3 magit-repolist-column-flag)
("Version" 25 magit-repolist-column-version
((:sort magit-repolist-version<)))
("B<U" 3 magit-repolist-column-unpulled-from-upstream
((:right-align t)
(:sort <)))
("B>U" 3 magit-repolist-column-unpushed-to-upstream
((:right-align t)
(:sort <)))
("Path" 99 magit-repolist-column-path nil))
magit-repolist-column-flag-alist '((magit-untracked-files . "N")
(magit-unstaged-files . "U")
(magit-staged-files . "S")))
;; show ANSI colors in the process buffer, so it's easier to read what's going on
;; for some reasons if it's in the `:custom' section it does not get set
(setq magit-process-apply-ansi-colors t)
;;; git-link
(require 'git-link)
(setq git-link-open-in-browser t)
;; FIXME sets up roblox git enterprise as a git-link handler
(with-eval-after-load 'git-link
(add-to-list 'git-link-remote-alist '("github\\.rblx\\.com" git-link-github))
(add-to-list 'git-link-commit-remote-alist '("github\\.rblx\\.com" git-link-commit-github)))
;;; rg
(require 'rg)
(setq rg-group-result t
rg-show-columns t
rg-align-line-number-field-length 3
rg-align-column-number-field-length 3
rg-align-line-column-separator "#"
rg-align-position-content-separator "|"
rg-hide-command nil
rg-align-position-numbers t
rg-command-line-flags '("--follow"))
;;; project
(require 'project)
(setq project-mode-line t
project-switch-commands '((project-find-file "Find file" f)
(project-dired "Dired" d)
(project-eshell "Eshell" e)
(magit-project-status "Magit" ?m)))
;;; prog mode related
(add-hook 'prog-mode-hook 'electric-pair-mode)
(add-hook 'prog-mode-hook 'flymake-mode)
;; compile mode
(add-hook 'compilation-filter-hook 'ansi-color-compilation-filter)
(setq compilation-always-kill t
compilation-context-lines 10
compilation-disable-input t
compilation-scroll-output 'first-error
compilation-scroll-output t
compilation-skip-threshold 2
compilation-ask-about-save nil)
;; elisp
(add-hook 'emacs-lisp-mode-hook 'eldoc-mode)
(add-hook 'emacs-lisp-mode-hook 'flymake-mode)
(setq eldoc-idle-delay 1
eldoc-documentation-strategy #'eldoc-documentation-default
eldoc-echo-area-use-multiline-p nil)
;; direnv
(require 'direnv)
(direnv-mode t)
(setq direnv-always-show-summary nil)
;; eglot
(require 'eglot)
(add-hook 'python-mode-hook 'eglot-ensure)
(add-hook 'go-mode-hook 'eglot-ensure)
(add-hook 'nix-mode-hook 'eglot-ensure)
(setq eglot-send-changes-idle-time 0.1
eglot-autoshutdown t)
(setq-default eglot-workspace-configuration
'(:pylsp (:plugins (:ruff (:enabled t)))
:nil (:formatting (:command ["nixfmt"]))
:gopls (:usePlaceholders t
:staticcheck t
:completeUnimported t
:matcher "CaseSensitive")))
;; uses https://github.com/nix-community/nixd for the LSP server instead of rnix
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs '(nix-mode . ("nil"))))
;; flymake
(require 'flymake)
(setq flymake-start-on-save-buffer t
flymake-fringe-indicator-position 'left-fringe
flymake-suppress-zero-counters t
flymake-no-changes-timeout 9999
elisp-flymake-byte-compile-load-path load-path)
;;; completion
(require 'consult)
(require 'consult-imenu)
(require 'consult-compile)
(require 'corfu)
(require 'corfu-popupinfo)
(require 'cape)
(require 'marginalia)
(require 'orderless)
(require 'vertico)
(global-corfu-mode t)
(corfu-popupinfo-mode t)
(marginalia-mode t)
(vertico-mode t)
(setq corfu-auto t)
(setq completion-styles '(orderless basic)
completion-category-defaults nil)
(bind-key "C-x b" #'consult-buffer)
(bind-key "C-x r b" #'consult-bookmark)
(bind-key "C-x p b" #'consult-project-buffer)
(bind-key "C-c i" #'consult-imenu)
(bind-key "M-g e" #'consult-compile-error)
(bind-key "M-g M-g" #'consult-goto-line)
(bind-key "M-g m" #'consult-mark)
(bind-key "M-g k" #'consult-global-mark)
(add-hook 'after-init-mode 'global-corfu-mode)
(add-hook 'after-init-mode 'vertico-mode)
;;; theming
(require-theme 'modus-themes)
(setq modus-themes-italic-constructs t
modus-themes-bold-constructs t
modus-themes-mixed-fonts t
modus-themes-variable-pitch-ui nil
modus-themes-prompts '(italic bold)
modus-themes-completions
'((matches . (extrabold))
(selection . (semibold italic text-also))))
(load-theme 'modus-operandi-tinted :no-confirm)
;;; server
(require 'server)
(unless (server-running-p)
(server-start))
;;; early-init.el ends here
;; byte-compile-warnings: (not docstrings lexical noruntime)
;; End:
|