Add base configs
This commit is contained in:
parent
d41a1c171b
commit
29732f9621
13 changed files with 266 additions and 5 deletions
95
config/base-config.el
Normal file
95
config/base-config.el
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
;; use soft tabs
|
||||||
|
(setq-default indent-tabs-mode nil)
|
||||||
|
|
||||||
|
;; make prompts accept y or n
|
||||||
|
(defalias 'yes-or-no-p #'y-or-n-p)
|
||||||
|
|
||||||
|
;; no confirmation for non-existent files or buffers
|
||||||
|
(setq confirm-nonexistent-file-or-buffer nil)
|
||||||
|
|
||||||
|
;; disable audible bell
|
||||||
|
(setq ring-bell-function #'ignore)
|
||||||
|
|
||||||
|
;; scroll one line at a time
|
||||||
|
(setq mouse-wheel-scroll-amount
|
||||||
|
'(1
|
||||||
|
((shift) . 5)
|
||||||
|
((control))))
|
||||||
|
|
||||||
|
;; disable scroll acceleration
|
||||||
|
(setq mouse-wheel-progressive-speed nil)
|
||||||
|
|
||||||
|
;; reload buffers automatically when files change on disk
|
||||||
|
(use-package autorevert
|
||||||
|
:diminish auto-revert-mode
|
||||||
|
:init
|
||||||
|
;; revert buffers quietly
|
||||||
|
(setq auto-revert-verbose nil)
|
||||||
|
:config
|
||||||
|
(global-auto-revert-mode 1))
|
||||||
|
|
||||||
|
;; integrate with X clipboard
|
||||||
|
(setq select-enable-clipboard t)
|
||||||
|
|
||||||
|
;; ensure clipboard strings are saved into kill ring
|
||||||
|
(setq save-interprogram-paste-before-kill t)
|
||||||
|
|
||||||
|
;; move deleted files to trash
|
||||||
|
(setq delete-by-moving-to-trash t)
|
||||||
|
|
||||||
|
;; show keystrokes immediately
|
||||||
|
(setq echo-keystrokes 0.1)
|
||||||
|
|
||||||
|
;; add directory to buffer name if filename is not unique
|
||||||
|
(setq uniquify-buffer-name-style 'forward)
|
||||||
|
|
||||||
|
;; automatically determine major-mode for newly created buffers
|
||||||
|
(setq-default major-mode
|
||||||
|
(lambda ()
|
||||||
|
(unless buffer-file-name
|
||||||
|
(let ((buffer-file-name (buffer-name)))
|
||||||
|
(set-auto-mode t)))))
|
||||||
|
|
||||||
|
;; single space ends a sentence
|
||||||
|
(setq-default sentence-end-double-space nil)
|
||||||
|
|
||||||
|
;; default to 80 chars fill-column
|
||||||
|
(setq-default fill-column 80)
|
||||||
|
|
||||||
|
;; confirm when exiting
|
||||||
|
(setq confirm-kill-emacs #'y-or-n-p)
|
||||||
|
|
||||||
|
;; backup files
|
||||||
|
(setq make-backup-files t
|
||||||
|
backup-directory-alist `(("." . ,(expand-file-name "backup"
|
||||||
|
user-emacs-directory)))
|
||||||
|
backup-by-copying t
|
||||||
|
delete-old-versions t
|
||||||
|
version-control t
|
||||||
|
vc-make-backup-files t
|
||||||
|
kept-new-versions 6
|
||||||
|
kept-old-versions 2)
|
||||||
|
|
||||||
|
;; preserve point position when scrolling
|
||||||
|
(setq scroll-preserve-screen-position 'always)
|
||||||
|
|
||||||
|
;; always add newline at the end of the file
|
||||||
|
;; (setq require-final-newline t)
|
||||||
|
|
||||||
|
;; remember position in previously visited files
|
||||||
|
(use-package saveplace
|
||||||
|
:config
|
||||||
|
(save-place-mode 1))
|
||||||
|
|
||||||
|
;; monday is the first day of the week
|
||||||
|
(setq calendar-week-start-day 1)
|
||||||
|
|
||||||
|
;; turn off distractions
|
||||||
|
(tool-bar-mode -1)
|
||||||
|
(menu-bar-mode -1)
|
||||||
|
(scroll-bar-mode -1)
|
||||||
|
|
||||||
|
;; font
|
||||||
|
(-let [font (font-spec :name "Source Code Pro" :size 12.0)]
|
||||||
|
(set-face-attribute 'default nil :font font)
|
||||||
|
(set-frame-font font nil 't))
|
0
config/base-keybindings.el
Normal file
0
config/base-keybindings.el
Normal file
6
config/base-libs.el
Normal file
6
config/base-libs.el
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
;; Install basic convenience libraries everything else can rely upon. Must be
|
||||||
|
;; initialized first thing after `straight' setup.
|
||||||
|
(use-package dash)
|
||||||
|
(use-package dash-functional)
|
||||||
|
(use-package f)
|
||||||
|
(use-package s)
|
4
config/company.el
Normal file
4
config/company.el
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
(use-package company
|
||||||
|
:diminish company-mode abbrev-mode
|
||||||
|
:init
|
||||||
|
(add-hook 'after-init-hook 'global-company-mode))
|
1
config/diminish.el
Normal file
1
config/diminish.el
Normal file
|
@ -0,0 +1 @@
|
||||||
|
(use-package diminish)
|
9
config/eglot.el
Normal file
9
config/eglot.el
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
(use-package project
|
||||||
|
:demand 't)
|
||||||
|
|
||||||
|
(use-package eglot
|
||||||
|
:after project
|
||||||
|
:config
|
||||||
|
(add-hook 'c-mode-common-hook 'eglot-ensure)
|
||||||
|
;; shadow default ccls
|
||||||
|
(push '((c-mode c++-mode) "clangd") eglot-server-programs))
|
18
config/evil.el
Normal file
18
config/evil.el
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
(use-package evil
|
||||||
|
:init
|
||||||
|
(setq evil-want-integration t) ;; This is optional since it's already set to t by default.
|
||||||
|
(setq evil-want-keybinding nil)
|
||||||
|
:config
|
||||||
|
(evil-mode 1))
|
||||||
|
|
||||||
|
(use-package evil-collection
|
||||||
|
:after evil
|
||||||
|
:config
|
||||||
|
(evil-collection-init))
|
||||||
|
|
||||||
|
(use-package evil-escape
|
||||||
|
:after evil
|
||||||
|
:diminish evil-escape-mode
|
||||||
|
:config
|
||||||
|
(setq-default evil-escape-key-sequence "jk")
|
||||||
|
(evil-escape-mode))
|
73
config/git.el
Normal file
73
config/git.el
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
;; https://raw.githubusercontent.com/mpolden/emacs.d/master/lisp/init-git.el
|
||||||
|
(use-package git-commit
|
||||||
|
:after markdown-mode
|
||||||
|
|
||||||
|
:init
|
||||||
|
;; use gfm-mode as major mode
|
||||||
|
(setq git-commit-major-mode 'gfm-mode))
|
||||||
|
|
||||||
|
(defun magit-visit-file-other-window (&optional noselect)
|
||||||
|
"Visit current file in another window."
|
||||||
|
(interactive)
|
||||||
|
(let ((current-window (selected-window)))
|
||||||
|
(call-interactively 'magit-diff-visit-file-other-window)
|
||||||
|
(when noselect
|
||||||
|
(select-window current-window))))
|
||||||
|
|
||||||
|
(defun magit-visit-file-other-window-noselect ()
|
||||||
|
"Visit current file in another window, but don't select it."
|
||||||
|
(interactive)
|
||||||
|
(magit-visit-file-other-window t))
|
||||||
|
|
||||||
|
(use-package magit
|
||||||
|
:init
|
||||||
|
;; disable gravatars
|
||||||
|
(setq magit-revision-show-gravatars nil)
|
||||||
|
|
||||||
|
;; hide recent commits in magit-status
|
||||||
|
(setq magit-log-section-commit-count 0)
|
||||||
|
|
||||||
|
;; set the default directory for git repositories
|
||||||
|
(let ((project-dir "~/p"))
|
||||||
|
(when (and (not (boundp 'magit-repository-directories)) (file-directory-p project-dir))
|
||||||
|
(setq magit-repository-directories (list (cons project-dir 1)))))
|
||||||
|
|
||||||
|
:bind (("C-x m" . magit-status)
|
||||||
|
("C-c b" . magit-blame)
|
||||||
|
:map magit-status-mode-map
|
||||||
|
;; make C-o and o behave as in dired
|
||||||
|
("o" . magit-visit-file-other-window)
|
||||||
|
("C-o" . magit-visit-file-other-window-noselect)))
|
||||||
|
|
||||||
|
(use-package forge
|
||||||
|
:ensure t
|
||||||
|
:after magit
|
||||||
|
:init
|
||||||
|
;; limit number of topics listed in status buffer
|
||||||
|
(setq forge-topic-list-limit '(10 . 0))
|
||||||
|
:bind (;; killing in pullreq or issue section copies the url at point
|
||||||
|
:map forge-pullreq-section-map
|
||||||
|
([remap magit-delete-thing] . forge-copy-url-at-point-as-kill)
|
||||||
|
:map forge-issue-section-map
|
||||||
|
([remap magit-delete-thing] . forge-copy-url-at-point-as-kill)))
|
||||||
|
|
||||||
|
;; follow symlinks to files under version control
|
||||||
|
(setq vc-follow-symlinks t)
|
||||||
|
|
||||||
|
;; limit vc backends as this may speed up some operations, e.g. tramp
|
||||||
|
(setq vc-handled-backends '(Git))
|
||||||
|
|
||||||
|
(defun vc-git-grep-root (&optional dir)
|
||||||
|
(interactive)
|
||||||
|
(let ((search-regexp (grep-read-regexp))
|
||||||
|
(dir (or dir (vc-git-root default-directory))))
|
||||||
|
(vc-git-grep search-regexp "" dir)))
|
||||||
|
|
||||||
|
;; (use-package vc-git
|
||||||
|
;; :after grep
|
||||||
|
;; :bind (;; C-c g runs git grep in repository
|
||||||
|
;; "C-c g" . vc-git-grep-root))
|
||||||
|
|
||||||
|
(use-package smerge-mode
|
||||||
|
:init
|
||||||
|
(setq smerge-command-prefix (kbd "C-c x")))
|
17
config/ido.el
Normal file
17
config/ido.el
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
(use-package flx)
|
||||||
|
|
||||||
|
(use-package counsel ;; counsel brings in ivy and swiper as dependencies
|
||||||
|
;; needed for ivy--regex-fuzzy
|
||||||
|
:after flx
|
||||||
|
:diminish ivy-mode
|
||||||
|
:init
|
||||||
|
;; use fuzzy matching by default. Needs flx.
|
||||||
|
(setq ivy-re-builders-alist '((t . ivy--regex-fuzzy)))
|
||||||
|
|
||||||
|
:config
|
||||||
|
(setq ivy-use-virtual-buffers t)
|
||||||
|
(setq ivy-count-format "(%d/%d) ")
|
||||||
|
(ivy-mode 1)
|
||||||
|
|
||||||
|
:bind
|
||||||
|
([ remap isearch-forward ] . 'swiper))
|
0
config/magit.el
Normal file
0
config/magit.el
Normal file
9
config/markdown.el
Normal file
9
config/markdown.el
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
(use-package markdown-mode
|
||||||
|
:ensure t
|
||||||
|
:commands gfm-mode
|
||||||
|
:mode
|
||||||
|
;; use gfm mode for .md and .markdown extensions
|
||||||
|
(("\\.\\(md\\|markdown\\)\\'" . gfm-mode)
|
||||||
|
;; use gfm mode for pull request and issue buffers
|
||||||
|
("PULLREQ_EDITMSG" . gfm-mode)
|
||||||
|
("ISSUE_EDITMSG" . gfm-mode)))
|
6
config/theme.el
Normal file
6
config/theme.el
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
(use-package doom-themes)
|
||||||
|
(use-package modus-themes
|
||||||
|
:config
|
||||||
|
(load-theme 'modus-operandi t))
|
||||||
|
|
||||||
|
(setq custom-theme-allow-multiple-selections nil)
|
33
init.el
33
init.el
|
@ -2,15 +2,11 @@
|
||||||
|
|
||||||
;;; Prolog
|
;;; Prolog
|
||||||
|
|
||||||
(let ((minver "26.1"))
|
|
||||||
(when (version< emacs-version minver)
|
|
||||||
(error "Emacs v%s or higher is required." minver)))
|
|
||||||
|
|
||||||
;; don't GC during startup to save time
|
;; don't GC during startup to save time
|
||||||
(setq gc-cons-percentage 0.6)
|
(setq gc-cons-percentage 0.6)
|
||||||
(setq gc-cons-threshold most-positive-fixnum)
|
(setq gc-cons-threshold most-positive-fixnum)
|
||||||
|
|
||||||
;;; straight and use-package setup
|
;;; Straight setup with use-package integration
|
||||||
|
|
||||||
(defconst straight-use-package-by-default 't)
|
(defconst straight-use-package-by-default 't)
|
||||||
(defconst bootstrap-version 5)
|
(defconst bootstrap-version 5)
|
||||||
|
@ -25,6 +21,33 @@
|
||||||
(eval-print-last-sexp)))
|
(eval-print-last-sexp)))
|
||||||
(load bootstrap-file nil 'nomessage))
|
(load bootstrap-file nil 'nomessage))
|
||||||
|
|
||||||
|
;; call `straight-use-package' once directly to install `use-package'. Other
|
||||||
|
;; than here the integration is vice versa. I.e. `use-package' uses `straight'
|
||||||
|
;; internally to fetch packages.
|
||||||
|
(straight-use-package 'use-package)
|
||||||
|
|
||||||
|
(add-to-list 'load-path (expand-file-name "config" user-emacs-directory))
|
||||||
|
|
||||||
|
;; Base config
|
||||||
|
(load "base-libs") ;; utility libs everything else can rely upon. Load
|
||||||
|
;; this first.
|
||||||
|
(load "base-config") ;; emacs core configuration
|
||||||
|
(load "diminish")
|
||||||
|
(load "evil")
|
||||||
|
(load "ido")
|
||||||
|
(load "company")
|
||||||
|
(load "theme")
|
||||||
|
|
||||||
|
;; Tools
|
||||||
|
(load "git")
|
||||||
|
|
||||||
|
;; Languages
|
||||||
|
(load "markdown")
|
||||||
|
(load "eglot")
|
||||||
|
|
||||||
|
|
||||||
|
(load "base-keybindings") ;; load this last to ensure all bound symbols are in
|
||||||
|
;; scope and `base-keybindings' takes precedence
|
||||||
|
|
||||||
;;; Epilog
|
;;; Epilog
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue