2022-07-28 13:14:47 +02:00
|
|
|
;; set up package infrastructure
|
|
|
|
|
|
|
|
(require 'use-package)
|
|
|
|
(package-initialize)
|
|
|
|
|
2021-08-19 16:19:21 +02:00
|
|
|
;; Set default font and fallback font via set-fontset-font
|
|
|
|
(let ((mono-font "Bitstream Vera Sans Mono-12")
|
|
|
|
(emoji-font "Noto Color Emoji-12"))
|
|
|
|
(setq default-frame-alist `((font . ,mono-font)))
|
|
|
|
(set-frame-font mono-font t t)
|
|
|
|
(set-fontset-font t nil emoji-font))
|
|
|
|
|
|
|
|
(setq inhibit-startup-message t
|
|
|
|
display-time-24hr-format t
|
|
|
|
select-enable-clipboard t)
|
|
|
|
|
|
|
|
;; Reload files
|
|
|
|
(global-auto-revert-mode 1)
|
|
|
|
|
|
|
|
;; Indent
|
2022-01-17 00:33:11 +01:00
|
|
|
(setq-default indent-tabs-mode nil)
|
2022-03-01 16:50:44 +01:00
|
|
|
(setq tab-width 2
|
|
|
|
css-indent-offset tab-width)
|
2021-08-19 16:19:21 +02:00
|
|
|
|
|
|
|
;; UTF-8
|
|
|
|
(setq locale-coding-system 'utf-8)
|
|
|
|
(set-terminal-coding-system 'utf-8)
|
|
|
|
(set-keyboard-coding-system 'utf-8)
|
|
|
|
(set-selection-coding-system 'utf-8)
|
|
|
|
(prefer-coding-system 'utf-8)
|
|
|
|
|
|
|
|
;; Disable unnecessary GUI elements
|
|
|
|
(scroll-bar-mode 0)
|
|
|
|
(menu-bar-mode 0)
|
|
|
|
(tool-bar-mode 0)
|
|
|
|
|
|
|
|
(add-hook 'after-make-frame-functions
|
|
|
|
(lambda (frame) (scroll-bar-mode 0)))
|
|
|
|
|
2021-08-24 14:20:08 +02:00
|
|
|
;; don't center on cursor when scrolling
|
2021-08-19 16:19:21 +02:00
|
|
|
(setq scroll-conservatively 1)
|
|
|
|
|
|
|
|
;; type less
|
|
|
|
(defalias 'yes-or-no-p 'y-or-n-p)
|
|
|
|
|
|
|
|
;; Extra settings when graphical session
|
|
|
|
(when window-system
|
|
|
|
(setq frame-title-format '(buffer-file-name "%f" ("%b")))
|
|
|
|
(mouse-wheel-mode t)
|
|
|
|
(blink-cursor-mode -1))
|
|
|
|
|
2022-01-17 14:06:05 +01:00
|
|
|
;; /tmp is a tmpfs, but we may want to recover from power loss
|
|
|
|
(custom-set-variables
|
|
|
|
`(temporary-file-directory ,(concat (getenv "HOME") "/.emacs/tmp")))
|
|
|
|
|
2021-08-19 16:19:21 +02:00
|
|
|
(setq auto-save-file-name-transforms
|
|
|
|
`((".*" ,temporary-file-directory t)))
|
|
|
|
(setq backup-directory-alist
|
|
|
|
`((".*" . ,temporary-file-directory)))
|
2022-01-17 13:05:12 +01:00
|
|
|
(setq undo-tree-history-directory-alist
|
|
|
|
`((".*" . ,temporary-file-directory)))
|
2022-01-17 00:31:15 +01:00
|
|
|
(setq backup-by-copying t)
|
|
|
|
(setq create-lockfiles nil)
|
2021-08-19 16:19:21 +02:00
|
|
|
|
2022-01-17 13:10:07 +01:00
|
|
|
;; save history
|
|
|
|
(savehist-mode)
|
|
|
|
(setq savehist-additional-variables '(search-ring regexp-search-ring magit-cl-history))
|
|
|
|
|
2021-08-19 16:19:21 +02:00
|
|
|
;; buffers
|
2022-05-09 15:43:02 +02:00
|
|
|
|
|
|
|
;; performance migitations
|
|
|
|
(global-so-long-mode)
|
|
|
|
|
2021-08-19 16:19:21 +02:00
|
|
|
;; unique component should come first for better completion
|
|
|
|
(setq uniquify-buffer-name-style 'forward)
|
|
|
|
|
2022-01-17 00:33:33 +01:00
|
|
|
;; completions
|
|
|
|
(ido-mode 1)
|
|
|
|
(setq ido-enable-flex-matching t)
|
|
|
|
(ido-everywhere)
|
|
|
|
(fido-mode)
|
|
|
|
|
2021-08-19 16:19:21 +02:00
|
|
|
;; Display column numbers
|
|
|
|
(column-number-mode t)
|
|
|
|
(setq-default fill-column 80)
|
|
|
|
(setq display-fill-column-indicator-column t)
|
|
|
|
(add-hook 'prog-mode-hook #'display-fill-column-indicator-mode)
|
|
|
|
|
|
|
|
;; whitespace
|
|
|
|
(setq whitespace-style '(face trailing tabs)
|
|
|
|
whitespace-line-column fill-column)
|
|
|
|
(add-hook 'prog-mode-hook #'whitespace-mode)
|
2022-01-17 00:34:02 +01:00
|
|
|
(setq-default indicate-empty-lines t)
|
|
|
|
(setq-default indicate-buffer-boundaries 'left)
|
2022-01-17 00:34:24 +01:00
|
|
|
(setq sentence-end-double-space nil)
|
2021-08-19 16:19:21 +02:00
|
|
|
|
|
|
|
;;; Configure built in modes
|
|
|
|
|
|
|
|
;; Perl
|
|
|
|
(setq perl-indent-level 2)
|
|
|
|
(setq perl-continued-statement-offset 0)
|
|
|
|
(setq perl-continued-brace-offset 0)
|
|
|
|
|
2022-02-02 14:02:28 +01:00
|
|
|
;; org mode
|
|
|
|
|
|
|
|
(setq org-clock-persist 'history)
|
|
|
|
(org-clock-persistence-insinuate)
|
|
|
|
|
2022-02-26 22:06:37 +01:00
|
|
|
(let ((org-folder (concat (getenv "HOME") "/files/sync/org")))
|
|
|
|
(setq org-agenda-files (directory-files-recursively org-folder "\\.org$")
|
2022-03-01 18:56:58 +01:00
|
|
|
org-default-notes-file (concat org-folder "/inbox.org")
|
2023-04-29 14:58:26 +02:00
|
|
|
initial-buffer-choice org-default-notes-file
|
|
|
|
org-refile-targets '((org-agenda-files . (:maxlevel . 2)))))
|
2022-02-26 22:06:37 +01:00
|
|
|
|
2022-05-28 00:23:50 +02:00
|
|
|
;; latex
|
|
|
|
|
|
|
|
(defun latex-word-count ()
|
|
|
|
"Calls texcount on the file the current buffer points to and displays the result."
|
|
|
|
(interactive)
|
|
|
|
(save-buffer)
|
|
|
|
(let* ((file (buffer-file-name)) ; needs to happen outside with-current-buffer
|
|
|
|
(word-count
|
|
|
|
(with-output-to-string
|
|
|
|
(with-current-buffer standard-output
|
|
|
|
(call-process "texcount" nil t nil "-brief" "-utf8" file)))))
|
|
|
|
(message (string-trim-right word-count))))
|
|
|
|
|
2022-05-09 15:44:24 +02:00
|
|
|
;; ediff
|
2023-03-27 19:24:55 +02:00
|
|
|
;; doesn't create new window for ediff controls which I always open accidentally
|
2022-05-09 15:44:24 +02:00
|
|
|
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
|
|
|
|
|
2022-05-09 15:45:00 +02:00
|
|
|
;; man
|
|
|
|
(setq Man-notify-method 'pushy) ; display man page in current window
|
|
|
|
|
2022-05-10 16:13:22 +02:00
|
|
|
;; shell
|
|
|
|
|
|
|
|
; default, but allows ';' as prompt
|
|
|
|
(setq shell-prompt-pattern "^[^#$%>;\n]*[#$%>;] *")
|
|
|
|
|
2022-05-10 16:16:28 +02:00
|
|
|
;; projects (see also evil config)
|
|
|
|
|
2022-05-25 20:56:51 +02:00
|
|
|
(defun project-magit ()
|
|
|
|
"Run magit in the current project dir"
|
|
|
|
(interactive)
|
|
|
|
(magit (project-root (project-current t))))
|
|
|
|
|
|
|
|
(define-key project-prefix-map (kbd "G") 'project-magit)
|
|
|
|
|
2022-05-10 16:16:28 +02:00
|
|
|
(setq project-switch-commands
|
|
|
|
'((project-find-file "Find file")
|
|
|
|
(project-find-regexp "Find regexp")
|
|
|
|
(project-dired "Dired")
|
2022-05-25 20:56:51 +02:00
|
|
|
(project-shell "Shell")
|
|
|
|
(project-magit "Magit")))
|
2022-05-10 16:16:28 +02:00
|
|
|
|
2021-08-19 16:19:21 +02:00
|
|
|
;;; Configure packages
|
|
|
|
(use-package undo-tree
|
|
|
|
:config
|
2022-01-17 13:05:12 +01:00
|
|
|
(global-undo-tree-mode)
|
|
|
|
(setq undo-tree-auto-save-history t))
|
2021-08-19 16:19:21 +02:00
|
|
|
|
|
|
|
(use-package magit
|
|
|
|
:after evil
|
|
|
|
:config
|
|
|
|
; reset (buffer-local) fill-column value to emacs' default
|
|
|
|
; gerrit doesn't like 80 column commit messages…
|
|
|
|
(add-hook 'git-commit-mode-hook (lambda () (setq fill-column 72)))
|
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>gr") 'magit-status))
|
2022-01-16 00:38:08 +01:00
|
|
|
(use-package tvl
|
|
|
|
:after magit
|
|
|
|
:custom tvl-depot-path (concat (getenv "HOME") "/src/depot"))
|
2021-08-19 16:19:21 +02:00
|
|
|
|
|
|
|
(setq ediff-split-window-function 'split-window-horizontally)
|
|
|
|
|
|
|
|
(use-package evil
|
|
|
|
:init
|
|
|
|
(setq evil-want-integration t)
|
|
|
|
(setq evil-want-keybinding nil)
|
|
|
|
(setq evil-shift-width 2)
|
|
|
|
(setq evil-split-window-below t)
|
|
|
|
(setq evil-split-window-right t)
|
|
|
|
(setq evil-undo-system 'undo-tree)
|
|
|
|
:config
|
|
|
|
(evil-mode 1)
|
|
|
|
(evil-set-leader 'normal ",") ;; TODO(sterni): space would be nice, but…
|
|
|
|
(evil-set-leader 'visual ",")
|
|
|
|
;; buffer management
|
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>bk") 'kill-buffer)
|
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>bb") 'switch-to-buffer)
|
2022-05-26 13:18:36 +02:00
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>bo") 'switch-to-buffer-other-window)
|
2022-01-17 00:33:44 +01:00
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>bl") 'list-buffers)
|
2022-05-09 15:45:16 +02:00
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>br") 'revert-buffer)
|
2022-05-09 15:43:40 +02:00
|
|
|
;; window management: C-w hjkl is annoying in neo
|
|
|
|
(define-key evil-window-map (kbd "<left>") 'evil-window-left)
|
|
|
|
(define-key evil-window-map (kbd "<right>") 'evil-window-right)
|
|
|
|
(define-key evil-window-map (kbd "<up>") 'evil-window-up)
|
|
|
|
(define-key evil-window-map (kbd "<down>") 'evil-window-down)
|
2022-05-10 16:16:28 +02:00
|
|
|
;; projects
|
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>pf") 'project-find-file)
|
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>pg") 'project-find-regexp)
|
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>pd") 'project-dired)
|
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>ps") 'project-shell)
|
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>pR") 'project-query-replace-regexp)
|
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>pK") 'project-kill-buffers)
|
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>pp") 'project-switch-project)
|
2021-08-19 16:19:21 +02:00
|
|
|
;; emacs
|
|
|
|
(evil-define-key 'visual 'global (kbd "<leader>ee") 'eval-region)
|
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>ee") 'eval-last-sexp)
|
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>ep") 'eval-print-last-sexp)
|
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>eh") 'help)
|
2022-05-10 16:16:54 +02:00
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>em") 'man)
|
2022-05-10 20:14:46 +02:00
|
|
|
(evil-define-key '(normal visual) 'global (kbd "<leader>eu") 'browse-url-at-point)
|
2022-05-22 21:45:28 +02:00
|
|
|
(evil-define-key '(normal visual) 'global (kbd "<leader>ef") 'ffap)
|
2021-08-19 16:19:21 +02:00
|
|
|
;; modify what is displayed
|
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>dw")
|
|
|
|
(lambda ()
|
|
|
|
(interactive)
|
|
|
|
(whitespace-mode 'toggle)
|
|
|
|
(display-fill-column-indicator-mode 'toggle)))
|
2022-02-26 22:06:37 +01:00
|
|
|
;; org-mode
|
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>oa") 'org-agenda)
|
2022-05-23 19:08:16 +02:00
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>oc") 'org-capture))
|
2021-08-19 16:19:21 +02:00
|
|
|
|
|
|
|
(use-package evil-collection
|
|
|
|
:after evil
|
|
|
|
:config
|
|
|
|
(evil-collection-init))
|
|
|
|
|
2022-01-17 00:32:11 +01:00
|
|
|
;; parens
|
2021-08-19 16:19:21 +02:00
|
|
|
(use-package rainbow-delimiters
|
2022-01-17 00:32:11 +01:00
|
|
|
:hook ((prog-mode . rainbow-delimiters-mode)))
|
|
|
|
|
|
|
|
(setq show-paren-delay 0)
|
|
|
|
(show-paren-mode)
|
|
|
|
|
|
|
|
(use-package paredit
|
|
|
|
:hook ((emacs-lisp-mode . paredit-mode)
|
|
|
|
(lisp-mode . paredit-mode)
|
|
|
|
(ielm-mode . paredit-mode)
|
|
|
|
(lisp-interaction-mode . paredit-mode)))
|
2021-08-19 16:19:21 +02:00
|
|
|
|
2022-05-25 09:24:46 +02:00
|
|
|
(use-package which-key :config (which-key-mode t))
|
|
|
|
|
2021-08-19 16:19:21 +02:00
|
|
|
(use-package nix-mode :mode "\\.nix\\'")
|
|
|
|
(use-package nix-drv-mode :mode "\\.drv\\'")
|
|
|
|
|
2022-03-12 13:33:55 +01:00
|
|
|
(use-package direnv
|
|
|
|
:config (direnv-mode))
|
|
|
|
|
2022-05-12 18:33:50 +02:00
|
|
|
(use-package editorconfig
|
|
|
|
:config (editorconfig-mode 1))
|
|
|
|
|
2021-08-19 16:19:21 +02:00
|
|
|
(use-package haskell-mode)
|
2022-12-23 15:23:29 +01:00
|
|
|
(use-package flycheck
|
|
|
|
:init (global-flycheck-mode))
|
2022-03-12 13:33:55 +01:00
|
|
|
(use-package lsp-mode
|
|
|
|
:hook ((haskell-mode . lsp-deferred))
|
2022-05-26 13:42:52 +02:00
|
|
|
:commands (lsp lsp-deferred)
|
2022-05-26 14:09:57 +02:00
|
|
|
:custom
|
|
|
|
lsp-modeline-code-actions-segments '() ; using lsp-ui-sideline instead
|
2022-05-26 13:42:52 +02:00
|
|
|
:config
|
|
|
|
(evil-define-key 'normal 'global
|
|
|
|
(kbd "<leader>lwr") 'lsp-workspace-restart
|
|
|
|
(kbd "<leader>lwq") 'lsp-workspace-shutdown
|
|
|
|
(kbd "<leader>la=") 'lsp-format-buffer
|
|
|
|
(kbd "<leader>lar") 'lsp-rename
|
|
|
|
(kbd "<leader>laa") 'lsp-execute-code-action))
|
|
|
|
(use-package lsp-ui
|
|
|
|
:after lsp-mode
|
|
|
|
:custom
|
|
|
|
lsp-ui-doc-enable t
|
|
|
|
lsp-ui-doc-border "DimGray"
|
|
|
|
lsp-ui-doc-delay 0.5
|
|
|
|
:config
|
|
|
|
(set-face-background 'lsp-ui-doc-background "WhiteSmoke")
|
2022-05-26 14:09:57 +02:00
|
|
|
(set-face-foreground 'lsp-ui-sideline-code-action "SaddleBrown")
|
|
|
|
(setq lsp-ui-sideline-code-actions-prefix "🔨 "
|
2022-12-23 15:23:29 +01:00
|
|
|
lsp-ui-sideline-show-diagnostics nil
|
2022-05-26 14:09:57 +02:00
|
|
|
lsp-ui-sideline-show-code-actions t) ; is :custom, but won't take effect?
|
2022-05-26 13:42:52 +02:00
|
|
|
(evil-define-key 'normal lsp-ui-mode-map
|
|
|
|
;; TODO(sterni): emulate using xref for non-lsp?
|
|
|
|
(kbd "<leader>lgr") 'lsp-ui-peek-find-references
|
|
|
|
(kbd "<leader>lgd") 'lsp-ui-peek-find-definitions
|
|
|
|
(kbd "<leader>lc") 'lsp-ui-flycheck-list))
|
2022-05-25 20:59:31 +02:00
|
|
|
(use-package lsp-haskell
|
|
|
|
:after lsp-mode
|
|
|
|
:custom
|
|
|
|
lsp-haskell-formatting-provider "ormolu")
|
2022-03-12 13:33:55 +01:00
|
|
|
|
2021-08-19 16:19:21 +02:00
|
|
|
(use-package urweb-mode)
|
2021-09-06 16:24:00 +02:00
|
|
|
(use-package bqn-mode
|
|
|
|
:mode "\\.bqn\\'"
|
|
|
|
:custom bqn-mode-map-prefix "C-s-") ; probably rather using C-\
|
2021-08-19 16:19:21 +02:00
|
|
|
(use-package yaml-mode)
|
|
|
|
(use-package dockerfile-mode)
|
2021-10-11 15:02:19 +02:00
|
|
|
(use-package jq-mode
|
|
|
|
:config (add-to-list 'auto-mode-alist '("\\.jq\\'" . jq-mode)))
|
2021-09-14 23:38:42 +02:00
|
|
|
(use-package rust-mode)
|
2021-08-19 16:19:21 +02:00
|
|
|
(use-package sly
|
|
|
|
:after evil
|
2022-01-17 00:32:11 +01:00
|
|
|
:hook ((sly-mrepl-mode . (lambda ()
|
|
|
|
(enable-paredit-mode)
|
|
|
|
(rainbow-delimiters-mode-enable))))
|
2021-08-19 16:19:21 +02:00
|
|
|
:config
|
2022-01-17 00:31:36 +01:00
|
|
|
(evil-define-key '(normal insert) sly-mrepl-mode-map (kbd "C-r") 'isearch-backward))
|
2021-08-19 16:19:21 +02:00
|
|
|
|
2022-05-22 13:33:17 +02:00
|
|
|
; TODO(sterni): https://github.com/NixOS/nixpkgs/pull/173893/files
|
|
|
|
; (use-package ada-mode)
|
2021-08-19 16:19:21 +02:00
|
|
|
|
|
|
|
(use-package rainbow-mode)
|
|
|
|
(use-package hl-todo
|
|
|
|
:hook ((prog-mode . hl-todo-mode))
|
|
|
|
:config
|
|
|
|
(setq hl-todo-keyword-faces
|
|
|
|
'(("TODO" . "#FF0000")
|
|
|
|
("FIXME" . "#FF0000")
|
|
|
|
("HACK" . "#7f7f7f")
|
|
|
|
("XXX" . "#aa0000"))))
|
|
|
|
|
|
|
|
(use-package markdown-mode
|
|
|
|
:commands (markdown-mode gfm-mode)
|
|
|
|
:mode (("\\.md\\'" . markdown-mode)))
|
|
|
|
(use-package adoc-mode
|
|
|
|
:mode (("\\.adoc\\'" . adoc-mode)))
|
2022-01-11 00:21:21 +01:00
|
|
|
(use-package languagetool
|
|
|
|
:after evil
|
|
|
|
:custom
|
|
|
|
languagetool-java-arguments '("-Dfile.encoding=UTF-8")
|
|
|
|
languagetool-default-language "en-GB"
|
|
|
|
languagetool-mother-tongue "de-DE"
|
|
|
|
:config
|
2022-05-25 21:42:48 +02:00
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>mll") 'languagetool-check)
|
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>mlc") 'languagetool-correct-at-point)
|
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>mls") 'languagetool-set-language)
|
2022-05-26 13:28:30 +02:00
|
|
|
(evil-define-key 'normal 'global (kbd "<leader>mlr") 'languagetool-clear-suggestions)
|
|
|
|
;; Fill background of issues instead of just underlining to make it easier to read
|
|
|
|
(set-face-background 'languagetool-issue-default "yellow")
|
|
|
|
(set-face-background 'languagetool-issue-misspelling "red"))
|
2021-08-19 16:19:21 +02:00
|
|
|
|
2022-03-24 11:27:21 +01:00
|
|
|
(unless (server-running-p)
|
|
|
|
(server-start))
|
|
|
|
|
2022-05-23 19:08:16 +02:00
|
|
|
(require 'subscriptions) ; elfeed config
|
2021-12-14 15:36:20 +01:00
|
|
|
(require 'nix-inject)
|
2021-08-19 16:19:21 +02:00
|
|
|
|
|
|
|
(provide 'init)
|