diff options
author | Lars Wirzenius <liw@liw.fi> | 2023-05-09 19:18:00 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2023-05-09 19:18:00 +0300 |
commit | d58536c34b1bdea89e76e7ceb1f2e57f433a5203 (patch) | |
tree | 4b7e69f1bcbd4b7177e8f9284762b5f8072d425c /emacs.d | |
parent | 801d395929f69a290b9e5581c61608c34d59dfe0 (diff) | |
download | liw-dot-files-d58536c34b1bdea89e76e7ceb1f2e57f433a5203.tar.gz |
update Emacs config; should work on bookworm too now
Diffstat (limited to 'emacs.d')
-rw-r--r-- | emacs.d/custom.el | 2 | ||||
l--------- | emacs.d/emacs.d | 1 | ||||
-rw-r--r-- | emacs.d/init.el | 258 |
3 files changed, 83 insertions, 178 deletions
diff --git a/emacs.d/custom.el b/emacs.d/custom.el index 466c236..4aef9ee 100644 --- a/emacs.d/custom.el +++ b/emacs.d/custom.el @@ -4,7 +4,7 @@ ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(package-selected-packages - '(flycheck lsp-mode shfmt editorconfig tab-bar-mode yaml-mode tabbar session pod-mode muttrc-mode mutt-alias magit initsplit htmlize graphviz-dot-mode go-mode folding eproject diminish debian-el csv-mode color-theme-modern browse-kill-ring boxquote bm bar-cursor apache-mode use-package rustic racer python-mode modus-operandi-theme lsp-ui flycheck-rust flycheck-color-mode-line company blacken))) + '(editorconfig flycheck-color-mode-line flycheck-rust flycheck lsp-ui lsp-mode rustic shfmt python-mode blacken use-package yaml-mode tabbar session pod-mode muttrc-mode mutt-alias markdown-mode magit initsplit htmlize graphviz-dot-mode go-mode folding eproject diminish debian-el csv-mode company color-theme-modern browse-kill-ring boxquote bm bar-cursor apache-mode))) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. diff --git a/emacs.d/emacs.d b/emacs.d/emacs.d deleted file mode 120000 index 4fd40fd..0000000 --- a/emacs.d/emacs.d +++ /dev/null @@ -1 +0,0 @@ -/home/liw/liw-dot-files/emacs.d
\ No newline at end of file diff --git a/emacs.d/init.el b/emacs.d/init.el index f25de3c..df32465 100644 --- a/emacs.d/init.el +++ b/emacs.d/init.el @@ -1,63 +1,105 @@ -;;;; package -- Summary -;;;; Commentary: -;;; My Emacs init +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Lars Wirzenius Emacs config. I have no idea what I'm doing, I've +;; cobbled this up from snippets on the net. -;;; Code: - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Initialise package system. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Set up packaging system. (require 'package) -(setq package-archives - '(("gnu" . "https://elpa.gnu.org/packages/") - ("melpa" . "https://melpa.org/packages/"))) - -(package-initialize) +(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/")) +(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) -;; Run this manually from time to time to update package lists. +;; Uncomment this to force Emacs to update its package lists. +;; Keep it commented to make startup faster. ;(package-refresh-contents) -;; use-package for easier configuration - (unless (package-installed-p 'use-package) (package-install 'use-package)) (require 'use-package) (setq use-package-always-ensure t) -;; Put customization in its own file. +;; I don't want Emacs modifying my config file, so I tell it to save +;; custom options elsewhere. + (setq custom-file "~/.emacs.d/custom.el") (load custom-file) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Some UI / behavior customizations. + +(setq inhibit-startup-screen t) + +(tab-bar-mode t) +(setq tab-bar-new-tab-to 'rightmost) + +(tool-bar-mode 0) + +(column-number-mode t) +(setq column-number-indicator-zero-based nil) + +(global-display-line-numbers-mode) +(set-face-attribute 'line-number nil + :height 0.8) +(set-face-attribute 'line-number-current-line nil + :foreground "#ff0000") + +(setq select-enable-clipboard t) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Packages I like. +(setq buffers-menu-show-directories t) -;; Major mode for editing Apache configuration files. -(use-package apache-mode) +(set-default 'truncate-lines t) -;; Hide some mode line displays that are just noise. -(use-package diminish) +(add-hook 'text-mode-hook 'hl-line-mode) +(add-hook 'prog-mode-hook 'hl-line-mode) -;; Major mode for GraphViz dot files. -(use-package graphviz-dot-mode) +(global-set-key (kbd "<f5>") 'compile) +(global-set-key (kbd "C-<f5>") 'recompile) +(global-unset-key "\C-x\C-b") + +(when (display-graphic-p) + (global-unset-key "\C-x\C-c") + (global-unset-key "\C-z") + (global-unset-key "\C-_") + (global-unset-key (kbd "\C-x\C-z")) + (global-unset-key (kbd "<insert>")) + (global-set-key (kbd "C-=") 'text-scale-adjust) + (global-set-key (kbd "C-+") 'text-scale-adjust) + (global-set-key (kbd "C--") 'text-scale-adjust) + (global-set-key (kbd "C-0") 'text-scale-adjust) +) + +(setq-default indent-tabs-mode nil) + +(setq make-backup-files nil) + +(setq text-mode-hook (quote (turn-on-auto-fill text-mode-hook-identify))) + +(setq sentence-end-double-space nil) + +(set-face-attribute 'default nil + :height 130 + :family "Hack") + +(setq ispell-dictionary "en_US") + +(add-hook 'text-mode-hook 'show-paren-mode) +(add-hook 'prog-mode-hook 'show-paren-mode) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Packages I like, with their configuration. -;; Use git from Emacs. (use-package magit :config (global-set-key (kbd "C-x g") 'magit-status)) +(setq vc-handled-backends nil) -;; Use the black Python source formatter to format Emacs buffers. (use-package blacken) - -;; Major mode for Python source code. (use-package python-mode :config (py-underscore-word-syntax-p-off) - (add-hook 'python-mode-hook 'blacken-mode) -) + (add-hook 'python-mode-hook 'blacken-mode)) -;; Major mode for YAML files. (use-package yaml-mode :config (add-to-list 'auto-mode-alist '("\\.ick\\'" . yaml-mode)) @@ -66,183 +108,48 @@ (add-to-list 'auto-mode-alist '("\\.yaml\\'" . yaml-mode)) (add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode))) -;; Major mode for Markdown text files. (use-package markdown-mode :config (add-to-list 'auto-mode-alist '("NEWS" . markdown-mode)) (add-to-list 'auto-mode-alist '("README" . markdown-mode)) (add-to-list 'auto-mode-alist '("\\.mdwn\\'" . markdown-mode))) -;; Major mode for formatting shell scripts. (use-package shfmt :config (add-hook 'sh-mode-hook 'shfmt-on-save-mode)) -;; Major mode for edit source code in the Rust language. -(use-package rustic - :ensure - :bind (:map rustic-mode-map - ("M-j" . lsp-ui-imenu) - ("M-?" . lsp-find-references) - ("C-c C-c l" . flycheck-list-errors) - ("C-c C-c a" . lsp-execute-code-action) - ("C-c C-c r" . lsp-rename) - ("C-c C-c q" . lsp-workspace-restart) - ("C-c C-c Q" . lsp-workspace-shutdown) - ("C-c C-c s" . lsp-rust-analyzer-status)) - :config - ;; uncomment for less flashiness - ;; (setq lsp-eldoc-hook nil) - ;; (setq lsp-enable-symbol-highlighting nil) - ;; (setq lsp-signature-auto-activate nil) - - ;; en/disable rustfmt on save - (setq rustic-format-on-save t)) +(use-package rustic) -;; Mode for using the Rust Language Server Protocol for nicer Rust -;; editing. (use-package lsp-mode - :ensure :commands lsp :custom - ;; what to use when checking on-save. "check" is default, I prefer clippy (lsp-rust-analyzer-cargo-watch-command "clippy") (lsp-eldoc-render-all t) (lsp-idle-delay 0.6) - (lsp-rust-analyzer-server-display-inlay-hints t) :config (add-hook 'lsp-mode-hook 'lsp-ui-mode)) -;; UI for lsp-mode. (use-package lsp-ui - :ensure :commands lsp-ui-mode :custom (lsp-ui-peek-always-show t) (lsp-ui-sideline-show-hover t) (lsp-ui-doc-enable nil)) -;; Text completion framework for Emacs. (use-package company :config (setq company-tooltip-align-annotations t)) -;; Minor mode for on-the-fly checks for various types of files. (use-package flycheck :config (setq-default flycheck-disabled-checkers '(python-pylint))) -;; Flycheck for the Rust language. (use-package flycheck-rust) -;; Minor mode to color mode line based on how happy flycheck is. (use-package flycheck-color-mode-line) (eval-after-load 'flycheck '(add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode)) -;; UI theme for Emacs. -;(use-package modus-operandi-theme -; :config -; (setq modus-operandi-theme-slanted-constructs t) -; (setq modus-operandi-theme-bold-constructs t) -; (load-theme 'modus-operandi t)) - -;; Show trailing whitespace. -(require 'whitespace) -(global-whitespace-mode t) -(setq whitespace-style '(face trailing)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; UI tweaks. - -;; Use tab bar. -(tab-bar-mode) -(setq tab-bar-new-tab-to 'right) - -;; Don't show help at startup -(setq inhibit-startup-screen t) - -;; Disable tool bar in windows. -(tool-bar-mode 0) - -;; Show column numbers in the mode line. -(column-number-mode t) -(setq column-number-indicator-zero-based nil) - -;; Show line number before line. -(global-display-line-numbers-mode) -(set-face-attribute 'line-number nil - :height 0.8) -(set-face-attribute 'line-number-current-line nil - :foreground "#ff0000") - -;; Enable X CLIPBOARD selection, instead of PRIMARY. -(setq select-enable-clipboard t) - -;; Show directories in the Buffers menu. -(setq buffers-menu-show-directories t) - -;; Don't line wrap long lines. -(set-default 'truncate-lines t) - -;; Highlight current line. -(add-hook 'text-mode-hook 'hl-line-mode) -(add-hook 'prog-mode-hook 'hl-line-mode) - -;; Key bindings -(global-set-key (kbd "<f5>") 'compile) -(global-set-key (kbd "C-<f5>") 'recompile) -(global-unset-key "\C-x\C-b") - -(when (display-graphic-p) - (global-unset-key "\C-x\C-c") - (global-unset-key "\C-z") - (global-unset-key "\C-_") - (global-unset-key (kbd "\C-x\C-z")) - (global-unset-key (kbd "<insert>")) - (global-set-key (kbd "C-=") 'text-scale-adjust) - (global-set-key (kbd "C-+") 'text-scale-adjust) - (global-set-key (kbd "C--") 'text-scale-adjust) - (global-set-key (kbd "C-0") 'text-scale-adjust) -) - -(use-package editorconfig - :ensure t - :config - (editorconfig-mode 1)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Other tweaks. - -;; Prevent Extraneous Tabs -(setq-default indent-tabs-mode nil) - -;; Do not make backup files when saving. -(setq make-backup-files nil) - -;; Turn on auto-fill-mode in all text modes automatically. -(setq text-mode-hook (quote (turn-on-auto-fill text-mode-hook-identify))) - -;; Don't require double spaces to end sentences. -(setq sentence-end-double-space nil) - -;; Base font size. -(set-face-attribute 'default nil - :height 130 - :family "Hack") - -;; Set default dictionary. -(setq ispell-dictionary "en_US") - -;; Turn on flyspell spell checking. -(require 'flyspell) -(add-hook 'text-mode-hook 'flyspell-mode) -(add-hook 'prog-mode-hook 'flyspell-prog-mode) -(set-face-attribute 'flyspell-incorrect nil - :foreground "#ff0000") - - -;; Turn on flycheck mode for program code. (add-hook 'prog-mode-hook 'flycheck-mode) (add-hook 'yaml-mode-hook 'flycheck-mode) (add-hook 'markdown-mode-hook 'flycheck-mode) @@ -251,16 +158,15 @@ :underline "#ff0000" :foreground "#ff0000") -;; Show current function. -(add-hook 'prog-mode-hook 'which-function-mode) - -;; Show matching parens. -(add-hook 'text-mode-hook 'show-paren-mode) -(add-hook 'prog-mode-hook 'show-paren-mode) +(require 'flyspell) +(add-hook 'text-mode-hook 'flyspell-mode) +(add-hook 'prog-mode-hook 'flyspell-prog-mode) +(set-face-attribute 'flyspell-incorrect nil + :foreground "#ff0000") -;; Disable vc-mode: I prefer magit, and I only use git. -(setq vc-handled-backends nil) +(use-package editorconfig + :config + (editorconfig-mode 1)) (provide 'init) -;;; init.el ends here |