2019-03-19 20:49:29 +01:00
|
|
|
;;; init.el --- tastytea's Emacs init file.
|
2019-04-25 23:23:27 +02:00
|
|
|
;; Time-stamp: <2019-04-25T21:04:24+00:00>
|
2019-03-19 20:49:29 +01:00
|
|
|
|
2019-03-19 00:12:11 +01:00
|
|
|
;;; Commentary:
|
2019-04-08 23:52:19 +02:00
|
|
|
;; I am using this file with Emacs 26, but most of it will probably work with
|
|
|
|
;; Emacs 24 and above.
|
2019-03-19 20:49:29 +01:00
|
|
|
|
2019-03-19 00:12:11 +01:00
|
|
|
;;; Code:
|
2019-03-19 01:43:28 +01:00
|
|
|
;;;;;;;;;;;;;;;;;;;; Packages ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2019-03-19 00:12:11 +01:00
|
|
|
(require 'package)
|
2019-03-25 17:04:41 +01:00
|
|
|
(add-to-list 'package-archives
|
|
|
|
'("melpa-stable" . "https://stable.melpa.org/packages/") t)
|
2019-03-19 00:12:11 +01:00
|
|
|
(add-to-list 'package-archives
|
2019-03-19 08:04:53 +01:00
|
|
|
'("melpa" . "https://melpa.org/packages/") t)
|
2019-03-26 19:11:45 +01:00
|
|
|
(setq package-archive-priorities '(("gnu" . 1)
|
|
|
|
("melpa-stable" . 2)
|
|
|
|
("melpa" . 3)))
|
2019-03-19 00:12:11 +01:00
|
|
|
(package-initialize)
|
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Add path for custom packages.
|
2019-03-19 00:12:11 +01:00
|
|
|
(add-to-list 'load-path "~/.emacs.d/custom-packages/")
|
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Install use-package if necessary.
|
2019-03-19 00:12:11 +01:00
|
|
|
(unless (package-installed-p 'use-package)
|
|
|
|
(package-refresh-contents)
|
|
|
|
(package-install 'use-package))
|
|
|
|
|
|
|
|
(eval-when-compile
|
|
|
|
(require 'use-package))
|
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Always install packages if they are not present.
|
2019-03-19 00:12:11 +01:00
|
|
|
(require 'use-package-ensure)
|
|
|
|
(setq use-package-always-ensure t)
|
|
|
|
|
2019-03-21 12:48:26 +01:00
|
|
|
;; autocompile files as needed.
|
|
|
|
(use-package auto-compile
|
2019-04-07 01:30:47 +02:00
|
|
|
:custom
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Use uncompiled file if it is newer than the compiled one.
|
2019-04-07 01:30:47 +02:00
|
|
|
(load-prefer-newer t)
|
2019-03-21 12:48:26 +01:00
|
|
|
:config
|
|
|
|
(auto-compile-on-load-mode))
|
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; ;; Benchmark for startup-file.
|
2019-03-19 00:12:11 +01:00
|
|
|
;; (use-package benchmark-init
|
|
|
|
;; :config
|
|
|
|
;; ;; To disable collection of benchmark data after init is done.
|
|
|
|
;; (add-hook 'after-init-hook 'benchmark-init/deactivate))
|
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Update packages if at least 7 days have passed.
|
2019-03-19 00:12:11 +01:00
|
|
|
(use-package auto-package-update
|
2019-03-22 09:03:23 +01:00
|
|
|
:custom
|
|
|
|
(auto-package-update-delete-old-versions t)
|
|
|
|
(auto-package-update-interval 7)
|
|
|
|
(auto-package-update-hide-results nil)
|
2019-03-19 00:12:11 +01:00
|
|
|
:config
|
|
|
|
(auto-package-update-maybe))
|
|
|
|
|
2019-03-19 01:43:28 +01:00
|
|
|
;;;;;;;;;;;;;;;;;;;; Global variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Determine if we run on a slow computer.
|
2019-03-19 00:12:11 +01:00
|
|
|
(defvar slow-computer nil)
|
|
|
|
(if (member (system-name) '("steuerbeamter" "azimuth" "localhost"))
|
|
|
|
(setq slow-computer t)) ; localhost is schnibble
|
|
|
|
|
2019-03-30 12:29:09 +01:00
|
|
|
;; Show manpages and error messages from compilers in English.
|
2019-03-30 00:22:47 +01:00
|
|
|
(setenv "LANG" "en_US.utf8")
|
|
|
|
|
2019-03-19 02:18:58 +01:00
|
|
|
;;;;;;;;;;;;;;;;;;;; Configure some essential things ;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Set garbage collection threshold to 100 MiB (or 20 MiB) to speed up init.
|
|
|
|
;; It is reset at the end of the file.
|
2019-03-22 02:55:59 +01:00
|
|
|
(if slow-computer
|
|
|
|
(setq gc-cons-threshold (* 20 1024 1024))
|
|
|
|
(setq gc-cons-threshold (* 100 1024 1024)))
|
|
|
|
|
2019-04-24 22:42:56 +02:00
|
|
|
(use-package emacs
|
|
|
|
:init
|
|
|
|
;; Banish customizations to another file.
|
|
|
|
(setq custom-file (concat user-emacs-directory "custom.el"))
|
2019-04-24 23:22:05 +02:00
|
|
|
|
2019-04-24 22:42:56 +02:00
|
|
|
:custom
|
|
|
|
(inhibit-startup-screen t)
|
|
|
|
(inhibit-startup-echo-area-message t)
|
|
|
|
|
|
|
|
(backup-directory-alist ; Save backups in ~/.emacs.d/backups/.
|
|
|
|
`(("." . ,(concat user-emacs-directory "backups"))))
|
|
|
|
(delete-old-versions t) ; Delete old backups.
|
|
|
|
(kept-new-versions 6) ; Keep 6 newest backups.
|
|
|
|
(backup-by-copying t) ; Copy to backup folder.
|
|
|
|
(version-control t) ; Append version numbers to file names.
|
|
|
|
(auto-save-file-name-transforms ; Save auto-saves in ~/.emacs.d/backups/.
|
|
|
|
`((".*" ,(concat user-emacs-directory "backups/") t)))
|
|
|
|
|
|
|
|
(user-full-name "tastytea")
|
|
|
|
(user-mail-address "tastytea@tastytea.de")
|
2019-04-24 23:22:05 +02:00
|
|
|
(mouse-wheel-scroll-amount '(1 ((shift) . 1))) ; Scroll 1 line at a time.
|
2019-04-24 22:42:56 +02:00
|
|
|
;; Paste text where the cursor is, not where the mouse is.
|
|
|
|
(mouse-yank-at-point t)
|
|
|
|
(initial-scratch-message nil) ; Make scratch buffer empty,
|
|
|
|
(initial-major-mode 'text-mode) ; and select text-mode.
|
|
|
|
(require-final-newline t) ; Always add newline at end of file.
|
|
|
|
|
|
|
|
:config
|
|
|
|
(defalias 'yes-or-no-p 'y-or-n-p) ; Just type y/n instead of yes/no.
|
2019-03-19 01:43:28 +01:00
|
|
|
|
2019-04-24 22:42:56 +02:00
|
|
|
(defun my/set-fill-column-80 ()
|
|
|
|
"Set fill-column to 80."
|
|
|
|
(set-fill-column 80))
|
|
|
|
|
|
|
|
;; kill-region (cut) and kill-ring-save (copy) act on the current line if no
|
|
|
|
;; text is visually selected.
|
|
|
|
;; https://www.emacswiki.org/emacs/WholeLineOrRegion
|
|
|
|
(put 'kill-ring-save 'interactive-form
|
|
|
|
'(interactive
|
|
|
|
(if (use-region-p)
|
|
|
|
(list (region-beginning) (region-end))
|
|
|
|
(list (line-beginning-position) (line-beginning-position 2)))))
|
|
|
|
(put 'kill-region 'interactive-form
|
|
|
|
'(interactive
|
|
|
|
(if (use-region-p)
|
|
|
|
(list (region-beginning) (region-end))
|
|
|
|
(list (line-beginning-position) (line-beginning-position 2)))))
|
|
|
|
|
|
|
|
(delete-selection-mode t) ; Delete selection when you start to write.
|
|
|
|
(savehist-mode t) ; Save minibuffer history.
|
|
|
|
|
|
|
|
:hook
|
|
|
|
(prog-mode . my/set-fill-column-80)
|
|
|
|
(conf-mode . my/set-fill-column-80)
|
|
|
|
(text-mode . auto-fill-mode)) ; Enable word-wrapping at fill-column.
|
2019-03-19 00:12:11 +01:00
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Save cursor position.
|
2019-03-21 12:48:26 +01:00
|
|
|
(use-package saveplace
|
|
|
|
:config
|
|
|
|
(save-place-mode t))
|
2019-03-19 00:12:11 +01:00
|
|
|
|
2019-04-24 22:42:56 +02:00
|
|
|
;; Scroll before cursor has reached top/bottom.
|
|
|
|
;; Way too slow with fci-mode, highlight-indent-guides, or whitespace-mode.
|
2019-03-28 21:25:55 +01:00
|
|
|
;; (use-package smooth-scrolling
|
|
|
|
;; :config
|
|
|
|
;; (smooth-scrolling-mode 1))
|
2019-03-20 22:31:10 +01:00
|
|
|
|
2019-04-24 22:42:56 +02:00
|
|
|
;; ;; Never recenter cursor while scrolling.
|
|
|
|
;; (setq scroll-conservatively 101)
|
2019-04-24 22:03:52 +02:00
|
|
|
|
2019-03-19 00:12:11 +01:00
|
|
|
;;;;;;;;;;;;;;;;;;;; Keybindings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2019-03-22 06:28:59 +01:00
|
|
|
(use-package bind-key
|
2019-04-10 14:42:57 +02:00
|
|
|
:init
|
|
|
|
(defun my/delete-word (arg)
|
|
|
|
"Delete characters forward until encountering the end of a word.
|
|
|
|
With argument, do this that many times."
|
|
|
|
(interactive "p")
|
|
|
|
(if (use-region-p)
|
|
|
|
(delete-region (region-beginning) (region-end))
|
|
|
|
(delete-region (point) (progn (forward-word arg) (point)))))
|
|
|
|
|
|
|
|
(defun my/backward-delete-word (arg)
|
|
|
|
"Delete characters backward until encountering the end of a word.
|
|
|
|
With argument, do this that many times."
|
|
|
|
(interactive "p")
|
|
|
|
(my/delete-word (- arg)))
|
2019-03-22 06:28:59 +01:00
|
|
|
:config
|
|
|
|
(bind-keys
|
|
|
|
;; Switch window
|
2019-04-10 14:42:57 +02:00
|
|
|
("C-<tab>" . other-window)
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Reduce whitespace around cursor to 0 or 1, according to context.
|
2019-04-10 14:42:57 +02:00
|
|
|
("C-S-<delete>" . fixup-whitespace)
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Scroll without moving the cursor.
|
2019-04-10 14:42:57 +02:00
|
|
|
("M-<down>" . scroll-up-line)
|
|
|
|
("M-<up>" . scroll-down-line)
|
|
|
|
;; Delete words without storing them in the kill buffer.
|
|
|
|
("C-<delete>" . my/delete-word)
|
|
|
|
("C-<backspace>" . my/backward-delete-word)))
|
2019-03-19 00:12:11 +01:00
|
|
|
|
2019-03-31 19:26:14 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;; Programming / general ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Online documentation mode.
|
2019-03-21 12:48:26 +01:00
|
|
|
(use-package eldoc
|
|
|
|
:hook
|
|
|
|
(prog-mode . turn-on-eldoc-mode))
|
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Syntax checking with many plugins.
|
2019-03-22 23:23:51 +01:00
|
|
|
(unless slow-computer
|
|
|
|
(use-package flycheck
|
|
|
|
:config
|
|
|
|
(global-flycheck-mode)))
|
2019-03-19 01:34:36 +01:00
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Autocompletion mode with many plugins.
|
2019-03-22 23:23:51 +01:00
|
|
|
(unless slow-computer
|
|
|
|
(use-package company
|
2019-04-11 18:25:06 +02:00
|
|
|
:custom
|
|
|
|
;; Show suggestions after entering one character.
|
|
|
|
(company-minimum-prefix-length 1)
|
|
|
|
;; Wrap around at end/beginning of list.
|
|
|
|
(company-selection-wrap-around t)
|
|
|
|
;; Align annotation to the right border.
|
|
|
|
(company-tooltip-align-annotations t)
|
2019-04-01 01:07:09 +02:00
|
|
|
:bind
|
|
|
|
(:map company-active-map
|
|
|
|
("<return>" . nil) ; Disable completion on return.
|
|
|
|
("RET" . nil) ; https://emacs.stackexchange.com/a/13290
|
|
|
|
("<tab>" . company-complete-selection) ; Make tab work in lists.
|
|
|
|
("TAB" . company-complete-selection))
|
2019-03-22 23:23:51 +01:00
|
|
|
:hook
|
|
|
|
(after-init . global-company-mode)))
|
2019-03-19 01:34:36 +01:00
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Fuzzy autocompletion for company.
|
2019-03-19 00:12:11 +01:00
|
|
|
(use-package company-flx
|
|
|
|
:after company
|
|
|
|
:config
|
|
|
|
(company-flx-mode +1))
|
|
|
|
|
2019-04-11 18:25:06 +02:00
|
|
|
(use-package company-statistics
|
|
|
|
:after company
|
|
|
|
:hook
|
|
|
|
(after-init-hook . company-statistics-mode))
|
|
|
|
|
2019-03-31 18:52:08 +02:00
|
|
|
;; Set default indentation.
|
2019-03-19 01:34:36 +01:00
|
|
|
(setq-default indent-tabs-mode nil
|
|
|
|
tab-width 4)
|
2019-03-31 18:52:08 +02:00
|
|
|
|
|
|
|
;; Guess indentation.
|
|
|
|
(use-package dtrt-indent
|
|
|
|
:hook
|
|
|
|
(prog-mode . dtrt-indent-mode))
|
2019-03-19 01:34:36 +01:00
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Automatic project management.
|
2019-03-22 23:23:51 +01:00
|
|
|
(unless slow-computer
|
|
|
|
(use-package projectile
|
|
|
|
:after neotree
|
2019-04-07 01:30:47 +02:00
|
|
|
:init
|
|
|
|
(defun my/projectile-kill-buffers-and-change-tabbar-grouping ()
|
|
|
|
"Kill project buffers and change tabbar-ruler grouping to user-buffers."
|
2019-04-08 21:30:37 +02:00
|
|
|
(interactive)
|
2019-04-07 01:30:47 +02:00
|
|
|
(projectile-kill-buffers)
|
2019-04-08 21:30:37 +02:00
|
|
|
(tabbar-ruler-group-user-buffers)
|
|
|
|
(neotree-hide))
|
2019-04-14 03:40:17 +02:00
|
|
|
(defvar my/cmake-compile-command ; cmake command for compiling with 1
|
|
|
|
(concat "cmake --build . -- -j" ; core less than available.
|
|
|
|
(substring (shell-command-to-string "nproc --ignore=1") 0 -1)))
|
2019-04-10 05:18:54 +02:00
|
|
|
:custom
|
|
|
|
(projectile-project-compilation-dir "build")
|
|
|
|
(projectile-switch-project-action 'neotree-projectile-action)
|
2019-04-19 03:10:30 +02:00
|
|
|
(projectile-project-configure-cmd
|
|
|
|
"cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
|
|
|
|
-GUnix\\ Makefiles ..")
|
2019-03-22 23:23:51 +01:00
|
|
|
:config
|
2019-04-14 03:40:17 +02:00
|
|
|
(setq projectile-project-compilation-cmd (concat my/cmake-compile-command
|
2019-04-15 23:54:22 +02:00
|
|
|
" && ctest -Q"))
|
2019-03-22 23:23:51 +01:00
|
|
|
(projectile-mode +1)
|
2019-04-14 03:40:17 +02:00
|
|
|
(put 'projectile-project-compilation-cmd 'safe-local-variable #'stringp)
|
2019-04-19 03:10:30 +02:00
|
|
|
;; Mark variable as safe. This prevents prompts when using .dir-locals.el.
|
|
|
|
(put 'projectile-project-configure-cmd 'safe-local-variable #'stringp)
|
2019-03-22 23:23:51 +01:00
|
|
|
:bind
|
|
|
|
("C-c p" . 'projectile-command-map)
|
|
|
|
(:map projectile-command-map
|
|
|
|
("k" . 'my/projectile-kill-buffers-and-change-tabbar-grouping))))
|
2019-03-19 00:12:11 +01:00
|
|
|
|
2019-03-20 08:27:47 +01:00
|
|
|
;; Highlight TODO, FIXME, NOTE and so on.
|
2019-03-19 01:34:36 +01:00
|
|
|
(use-package hl-todo
|
2019-03-29 19:10:05 +01:00
|
|
|
:bind
|
|
|
|
(:map hl-todo-mode-map
|
2019-03-30 12:29:09 +01:00
|
|
|
("C-c t" . hl-todo-occur))
|
2019-03-22 04:08:47 +01:00
|
|
|
:hook
|
|
|
|
(prog-mode . hl-todo-mode))
|
2019-03-19 01:34:36 +01:00
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Better commenting.
|
2019-03-19 01:34:36 +01:00
|
|
|
(use-package smart-comment
|
|
|
|
:bind
|
2019-03-20 09:54:12 +01:00
|
|
|
("C-x c" . smart-comment))
|
2019-03-19 01:34:36 +01:00
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Toggle betweeen beginning/end of line and beginning/end of code.
|
2019-03-19 20:49:29 +01:00
|
|
|
(use-package mwim
|
|
|
|
:bind
|
|
|
|
("<home>" . mwim-beginning-of-line-or-code)
|
|
|
|
("<end>" . mwim-end-of-line-or-code))
|
2019-03-19 01:34:36 +01:00
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Auto-type closing brackets.
|
2019-03-19 01:43:28 +01:00
|
|
|
(electric-pair-mode t)
|
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Fold code.
|
2019-03-19 20:49:29 +01:00
|
|
|
(use-package fold-dwim
|
|
|
|
:bind
|
|
|
|
("<f7>" . fold-dwim-toggle)
|
2019-03-21 11:29:28 +01:00
|
|
|
("C-x t" . fold-dwim-toggle)
|
|
|
|
:hook
|
|
|
|
(prog-mode . hs-minor-mode))
|
2019-03-19 20:49:29 +01:00
|
|
|
|
2019-03-28 21:25:55 +01:00
|
|
|
;; ;; Highlight indentation levels.
|
|
|
|
;; (use-package highlight-indent-guides
|
|
|
|
;; :custom
|
|
|
|
;; (highlight-indent-guides-method 'character)
|
|
|
|
;; (highlight-indent-guides-responsive 'top)
|
|
|
|
;; :hook
|
|
|
|
;; (prog-mode . highlight-indent-guides-mode))
|
2019-03-19 20:49:29 +01:00
|
|
|
|
2019-03-31 19:26:14 +02:00
|
|
|
;; Tries to find points of interest and jumps to them.
|
2019-03-21 12:48:26 +01:00
|
|
|
(use-package imenu-anywhere
|
|
|
|
:after ido-completing-read+
|
|
|
|
:bind
|
|
|
|
("M-i" . imenu-anywhere))
|
|
|
|
|
2019-03-28 21:25:55 +01:00
|
|
|
(use-package highlight-doxygen
|
|
|
|
:custom-face
|
2019-04-12 03:03:37 +02:00
|
|
|
(highlight-doxygen-comment ((t (:inherit font-lock-comment-face
|
|
|
|
:foreground "#667788"))))
|
|
|
|
(highlight-doxygen-code-block ((t (:inherit highlight-doxygen-comment-face))))
|
2019-03-28 21:25:55 +01:00
|
|
|
:hook
|
|
|
|
(prog-mode . highlight-doxygen-mode))
|
|
|
|
|
2019-04-11 19:22:37 +02:00
|
|
|
(use-package dumb-jump
|
|
|
|
:bind
|
|
|
|
("M-." . dumb-jump-go)
|
|
|
|
("M-," . dumb-jump-back))
|
|
|
|
|
2019-03-31 19:26:14 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;; Programming / C++ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Set coding style.
|
|
|
|
(use-package cc-mode
|
|
|
|
:ensure nil ; Included in Emacs.
|
2019-04-01 01:07:09 +02:00
|
|
|
:config
|
2019-03-31 19:26:14 +02:00
|
|
|
(c-add-style "tastytea"
|
|
|
|
'("bsd"
|
|
|
|
(c-basic-offset . 4)))
|
|
|
|
:custom
|
|
|
|
(c-default-style "tastytea"))
|
|
|
|
|
|
|
|
(unless slow-computer
|
2019-04-13 20:40:34 +02:00
|
|
|
;; irony communicates with a clang-server. It needs compile_commands.json.
|
2019-04-11 18:25:06 +02:00
|
|
|
(use-package irony
|
|
|
|
:after yasnippet
|
|
|
|
:hook
|
|
|
|
(c++-mode . irony-mode)
|
|
|
|
(c-mode . irony-mode)
|
|
|
|
(irony-mode . irony-cdb-autosetup-compile-options)
|
2019-03-31 19:26:14 +02:00
|
|
|
:config
|
2019-04-13 20:40:34 +02:00
|
|
|
;; If irony server is not installed, install it.
|
2019-04-11 18:25:06 +02:00
|
|
|
(unless (irony--find-server-executable)
|
|
|
|
(call-interactively #'irony-install-server)))
|
|
|
|
|
|
|
|
;; Eldoc shows argument list of the function you are currently writing.
|
|
|
|
(use-package irony-eldoc
|
|
|
|
:after (eldoc irony)
|
2019-03-31 19:26:14 +02:00
|
|
|
:hook
|
2019-04-11 18:25:06 +02:00
|
|
|
(irony-mode . irony-eldoc))
|
2019-03-31 19:26:14 +02:00
|
|
|
|
2019-04-13 20:40:34 +02:00
|
|
|
;; Syntax checker.
|
2019-04-11 18:25:06 +02:00
|
|
|
(use-package flycheck-irony
|
|
|
|
:after (flycheck irony)
|
|
|
|
:hook
|
|
|
|
(flycheck-mode-hook . flycheck-irony-setup))
|
2019-03-31 19:26:14 +02:00
|
|
|
|
2019-04-11 18:25:06 +02:00
|
|
|
;; Auto-complete integration.
|
|
|
|
(use-package company-irony
|
|
|
|
:after (company irony)
|
|
|
|
:config
|
|
|
|
(add-to-list 'company-backends 'company-irony))
|
2019-03-31 19:26:14 +02:00
|
|
|
|
2019-04-11 18:25:06 +02:00
|
|
|
;; Auto-complete headers
|
|
|
|
(use-package company-irony-c-headers
|
|
|
|
:after (company-irony)
|
|
|
|
:config
|
|
|
|
(add-to-list 'company-backends 'company-irony-c-headers))
|
|
|
|
|
|
|
|
;; cmake integration.
|
2019-03-31 19:26:14 +02:00
|
|
|
(use-package cmake-ide
|
2019-04-11 18:25:06 +02:00
|
|
|
:after irony
|
2019-03-31 19:26:14 +02:00
|
|
|
:custom
|
|
|
|
(cmake-ide-build-dir "build")
|
2019-04-19 03:10:30 +02:00
|
|
|
;; (cmake-ide-cmake-args '("-DCMAKE_BUILD_TYPE=Debug"
|
|
|
|
;; "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
|
|
|
|
;; "-GUnix Makefiles"))
|
|
|
|
(cmake-ide-cmake-opts "") ; Use the already configured options.
|
2019-03-31 19:26:14 +02:00
|
|
|
:config
|
2019-04-11 18:25:06 +02:00
|
|
|
(cmake-ide-setup))
|
2019-04-11 19:22:37 +02:00
|
|
|
) ; unless slow-computer
|
2019-03-31 19:26:14 +02:00
|
|
|
|
|
|
|
;; GUI for gdb and other debuggers.
|
|
|
|
(use-package realgud
|
|
|
|
:after cc-mode
|
|
|
|
:config
|
|
|
|
(defun my/load-realgud ()
|
|
|
|
(load-library "realgud"))
|
|
|
|
:bind
|
|
|
|
(:map c-mode-base-map
|
|
|
|
("C-c g" . my/load-realgud)))
|
|
|
|
|
2019-03-19 07:08:27 +01:00
|
|
|
;;;;;;;;;;;;;;;;;;;; Appearance ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2019-04-02 14:45:01 +02:00
|
|
|
;; Hide toolbar.
|
|
|
|
(tool-bar-mode -1)
|
|
|
|
|
|
|
|
;; Put scrollbar to the right side.
|
|
|
|
(if (display-graphic-p)
|
|
|
|
(set-scroll-bar-mode 'right))
|
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Icons (required by doom).
|
2019-03-19 07:08:27 +01:00
|
|
|
(use-package all-the-icons
|
|
|
|
:config
|
2019-04-25 18:38:34 +02:00
|
|
|
(unless (member "all-the-icons" (font-family-list))
|
2019-03-19 07:08:27 +01:00
|
|
|
(all-the-icons-install-fonts t)))
|
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Themes for doom-modeline.
|
2019-03-22 23:23:51 +01:00
|
|
|
(unless slow-computer
|
|
|
|
(use-package doom-themes
|
|
|
|
:after (all-the-icons neotree)
|
|
|
|
:custom
|
|
|
|
(doom-neotree-file-icons 'icons)
|
2019-03-28 21:25:55 +01:00
|
|
|
:custom-face
|
2019-04-12 03:03:37 +02:00
|
|
|
(font-lock-comment-face ((t (:inherit font-lock-comment-face
|
|
|
|
:foreground "#667755"))))
|
2019-03-22 23:23:51 +01:00
|
|
|
:config
|
|
|
|
(load-theme 'doom-molokai t)
|
|
|
|
(doom-themes-neotree-config)))
|
2019-03-20 08:27:47 +01:00
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Neat modeline.
|
2019-03-19 07:08:27 +01:00
|
|
|
(use-package doom-modeline
|
|
|
|
:after all-the-icons
|
2019-03-22 01:57:44 +01:00
|
|
|
:init
|
2019-03-22 09:03:23 +01:00
|
|
|
(column-number-mode t) ; Show column numbers in modeline.
|
2019-04-09 02:39:22 +02:00
|
|
|
(size-indication-mode) ; Buffer size display in the modeline.
|
2019-03-19 07:08:27 +01:00
|
|
|
:config
|
2019-04-09 02:39:22 +02:00
|
|
|
(setq doom-modeline-minor-modes nil
|
2019-03-28 21:47:43 +01:00
|
|
|
;; doom-modeline-buffer-file-name-style 'relative-to-project
|
2019-04-09 02:39:22 +02:00
|
|
|
doom-modeline-buffer-file-name-style 'truncate-except-project)
|
2019-03-22 09:03:23 +01:00
|
|
|
:hook
|
|
|
|
(after-init . doom-modeline-mode))
|
2019-03-19 07:08:27 +01:00
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Miscellaneous visual improvements.
|
2019-04-12 19:28:16 +02:00
|
|
|
(add-to-list 'default-frame-alist ; Set default font.
|
|
|
|
'(font . "Source Code Pro-10"))
|
2019-03-22 09:03:23 +01:00
|
|
|
(global-hl-line-mode t) ; Highlight current line.
|
|
|
|
(show-paren-mode t) ; Visualize matching parens.
|
2019-03-25 17:04:41 +01:00
|
|
|
;; Show line numbers on the left side of the buffer.
|
2019-03-22 09:03:23 +01:00
|
|
|
(use-package display-line-numbers
|
|
|
|
:if (>= emacs-major-version 26)
|
|
|
|
:config
|
|
|
|
(global-display-line-numbers-mode))
|
2019-03-19 07:08:27 +01:00
|
|
|
|
2019-04-09 02:39:22 +02:00
|
|
|
;; Colored man pages.
|
2019-03-22 09:41:57 +01:00
|
|
|
(use-package man
|
|
|
|
:defer t
|
|
|
|
:custom-face
|
|
|
|
(Man-overstrike ((t (:inherit font-lock-type-face :bold t))))
|
2019-04-12 03:03:37 +02:00
|
|
|
(Man-underline ((t (:inherit font-lock-keyword-face :underline t)))))
|
2019-03-22 09:41:57 +01:00
|
|
|
|
2019-03-19 00:12:11 +01:00
|
|
|
;;;;;;;;;;;;;;;;;;;; Misc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Show directory tree in a window.
|
2019-03-19 00:12:11 +01:00
|
|
|
(use-package neotree
|
|
|
|
:demand t
|
2019-03-20 07:16:58 +01:00
|
|
|
:after all-the-icons
|
|
|
|
:custom
|
|
|
|
(neo-smart-open t)
|
|
|
|
(neo-show-updir-line t) ; Disabled by doom-themes?
|
2019-04-15 01:37:44 +02:00
|
|
|
(neo-window-width 40)
|
2019-04-04 12:52:19 +02:00
|
|
|
(neo-show-hidden-files t)
|
2019-03-19 00:12:11 +01:00
|
|
|
:bind
|
|
|
|
("<f8>" . neotree-toggle))
|
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Git integration.
|
2019-04-12 03:03:37 +02:00
|
|
|
(use-package git-commit)
|
2019-03-22 23:23:51 +01:00
|
|
|
(unless slow-computer
|
|
|
|
(use-package magit
|
|
|
|
:config
|
|
|
|
(defun my/magit-kill-buffers (arg)
|
|
|
|
"Restore window configuration and kill all Magit buffers."
|
|
|
|
(interactive)
|
|
|
|
(let ((buffers (magit-mode-get-buffers)))
|
|
|
|
(magit-restore-window-configuration)
|
|
|
|
(mapc #'kill-buffer buffers)))
|
|
|
|
:bind
|
|
|
|
("C-x g" . magit-status)
|
|
|
|
("C-x M-g" . magit-dispatch)
|
|
|
|
:custom
|
|
|
|
(magit-bury-buffer-function 'my/magit-kill-buffers)))
|
2019-03-19 00:12:11 +01:00
|
|
|
|
2019-04-24 22:03:52 +02:00
|
|
|
;; ;; Draw line in column 80
|
|
|
|
;; (use-package fill-column-indicator
|
|
|
|
;; :after company
|
|
|
|
;; :config
|
|
|
|
;; ;; Fix bug with fci + popup menus.
|
|
|
|
;; (defun my/fci-mode-enabled-p ()
|
|
|
|
;; (symbol-value 'fci-mode))
|
|
|
|
;; (defvar-local my/fci-enabled nil)
|
|
|
|
;; ;; company:
|
|
|
|
;; (defun my/on-off-fci-before-company(command)
|
|
|
|
;; "Turn fci-mode off while displaying popups in company."
|
|
|
|
;; (when (string= "show" command)
|
|
|
|
;; (setq-local my/fci-enabled (my/fci-mode-enabled-p))
|
|
|
|
;; (if my/fci-enabled
|
|
|
|
;; (turn-off-fci-mode)))
|
|
|
|
;; (when (string= "hide" command)
|
|
|
|
;; (if my/fci-enabled
|
|
|
|
;; (turn-on-fci-mode))))
|
|
|
|
;; (advice-add 'company-call-frontends :before #'my/on-off-fci-before-company)
|
|
|
|
;; ;; popup:
|
|
|
|
;; (defadvice popup-create (before my/popup-suppress-fci-mode activate)
|
|
|
|
;; "Suspend fci-mode while popups are visible."
|
|
|
|
;; (setq-local my/fci-enabled (my/fci-mode-enabled-p))
|
|
|
|
;; (if my/fci-enabled
|
|
|
|
;; (turn-off-fci-mode)))
|
|
|
|
;; (defadvice popup-delete (after my/popup-restore-fci-mode activate)
|
|
|
|
;; "Restore fci-mode when all popups have closed."
|
|
|
|
;; (if my/fci-enabled
|
|
|
|
;; (turn-on-fci-mode)))
|
|
|
|
;; :hook
|
|
|
|
;; (prog-mode . fci-mode)
|
|
|
|
;; (conf-mode . fci-mode))
|
2019-03-19 00:12:11 +01:00
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Interactive substring matching.
|
2019-03-19 08:24:13 +01:00
|
|
|
(use-package ido
|
2019-03-23 20:16:51 +01:00
|
|
|
:defer 5
|
2019-03-19 08:24:13 +01:00
|
|
|
:config
|
|
|
|
(ido-mode t)
|
|
|
|
(ido-everywhere t))
|
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Flexible matching for ido.
|
2019-03-19 00:12:11 +01:00
|
|
|
(use-package flx-ido
|
|
|
|
:after ido
|
2019-03-22 09:03:23 +01:00
|
|
|
:custom
|
2019-03-22 09:41:57 +01:00
|
|
|
(ido-enable-flex-matching t)
|
2019-03-23 04:48:22 +01:00
|
|
|
(ido-ignore-extensions t) ; Ignore extension like ~ and .o.
|
|
|
|
(ido-use-virtual-buffers t) ; Use history of recently opened buffers.
|
2019-03-31 18:52:08 +02:00
|
|
|
(recentf-max-saved-items 40) ; Keep this number of buffers in history.
|
2019-03-19 00:12:11 +01:00
|
|
|
:config
|
2019-03-22 09:41:57 +01:00
|
|
|
(flx-ido-mode t))
|
2019-03-19 23:24:39 +01:00
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Replaces stock emacs completion with ido completion wherever it is possible.
|
2019-03-22 23:23:51 +01:00
|
|
|
(unless slow-computer
|
|
|
|
(use-package ido-completing-read+
|
|
|
|
:after ido
|
|
|
|
:config
|
|
|
|
(ido-ubiquitous-mode t)))
|
2019-03-21 12:48:26 +01:00
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Advanced tab bar.
|
2019-03-22 23:23:51 +01:00
|
|
|
(unless slow-computer
|
2019-04-07 01:30:47 +02:00
|
|
|
(use-package mode-icons)
|
2019-03-22 23:23:51 +01:00
|
|
|
(use-package tabbar-ruler
|
2019-03-25 17:19:15 +01:00
|
|
|
:pin melpa ; Faces are not correctly applied,
|
2019-04-07 01:30:47 +02:00
|
|
|
:after (projectile mode-icons) ; version from >=2016-08-02 is needed.
|
2019-04-25 15:11:08 +02:00
|
|
|
:custom
|
|
|
|
(tabbar-ruler-global-tabbar t)
|
|
|
|
(tabbar-ruler-global-ruler t)
|
2019-03-22 23:23:51 +01:00
|
|
|
:config
|
|
|
|
;; (tabbar-ruler-group-by-projectile-project) ; Group by projectile.
|
|
|
|
;; (tabbar-ruler-group-buffer-groups) ; Group by file type.
|
|
|
|
(tabbar-ruler-group-user-buffers) ; Group by frame.
|
2019-04-07 01:30:47 +02:00
|
|
|
(mode-icons-mode 0) ; Disable modeline symbols.
|
2019-03-22 23:23:51 +01:00
|
|
|
|
|
|
|
(add-hook 'projectile-after-switch-project-hook ; Does not work under :hook.
|
|
|
|
'tabbar-ruler-group-by-projectile-project)
|
2019-04-25 15:11:08 +02:00
|
|
|
|
|
|
|
;; Show tabbar after 5 seconds idle.
|
|
|
|
(run-with-idle-timer 5 t (lambda ()
|
2019-04-25 15:22:25 +02:00
|
|
|
(when tabbar-ruler-tabbar-off
|
|
|
|
(tabbar-mode 1)
|
|
|
|
(setq tabbar-ruler-tabbar-off nil)
|
|
|
|
(ruler-mode -1)
|
|
|
|
(setq tabbar-ruler-ruler-off t))))
|
2019-03-22 23:23:51 +01:00
|
|
|
:bind
|
|
|
|
("C-<prior>" . 'tabbar-ruler-tabbar-backward-tab)
|
|
|
|
("C-<next>" . 'tabbar-ruler-tabbar-forward-tab)
|
|
|
|
:custom-face
|
2019-04-24 23:42:58 +02:00
|
|
|
(tabbar-selected ((t
|
|
|
|
(:background "gray11"
|
|
|
|
:foreground "light gray"
|
2019-03-22 23:23:51 +01:00
|
|
|
:family "Sans Serif"
|
2019-04-24 23:42:58 +02:00
|
|
|
:bold t))))
|
|
|
|
(tabbar-unselected ((t
|
|
|
|
(:background "gray18"
|
|
|
|
:foreground "dark gray"
|
|
|
|
:family "Sans Serif"
|
|
|
|
:italic t))))
|
|
|
|
(tabbar-modified ((t
|
|
|
|
(:foreground "brown2"
|
|
|
|
:italic t
|
|
|
|
:bold nil))))
|
|
|
|
(ruler-mode-default ((t
|
|
|
|
(:inherit default
|
|
|
|
:background "gray18"
|
|
|
|
:foreground "dim gray"
|
|
|
|
:box nil))))
|
|
|
|
(ruler-mode-column-number ((t
|
|
|
|
(:inherit ruler-mode-default
|
|
|
|
:foreground "dark gray"))))
|
2019-04-24 23:22:05 +02:00
|
|
|
))
|
2019-03-19 00:12:11 +01:00
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Visualize whitespace.
|
2019-03-19 00:12:11 +01:00
|
|
|
(use-package whitespace
|
2019-04-12 02:01:34 +02:00
|
|
|
:after company
|
2019-03-19 00:12:11 +01:00
|
|
|
:config
|
2019-03-22 09:03:23 +01:00
|
|
|
(delete 'newline-mark whitespace-style) ; Don't paint $ at eol.
|
2019-03-21 08:12:44 +01:00
|
|
|
(delete 'lines whitespace-style) ; Don't paint lines red if too long.
|
2019-04-12 03:03:37 +02:00
|
|
|
;; Workaround to not show dots in popup menus.
|
2019-04-12 02:01:34 +02:00
|
|
|
(defun my/whitespace-mode-enabled-p ()
|
|
|
|
(symbol-value 'whitespace-mode))
|
|
|
|
(defvar-local my/ws-enabled nil)
|
|
|
|
;; company:
|
2019-03-22 09:03:23 +01:00
|
|
|
(defun my/on-off-whitespace-before-company(command)
|
2019-03-21 07:42:33 +01:00
|
|
|
(when (string= "show" command)
|
2019-04-12 02:01:34 +02:00
|
|
|
(setq-local my/ws-enabled (my/whitespace-mode-enabled-p))
|
|
|
|
(if my/ws-enabled
|
|
|
|
(whitespace-mode -1)))
|
2019-03-21 07:42:33 +01:00
|
|
|
(when (string= "hide" command)
|
2019-04-12 02:01:34 +02:00
|
|
|
(if my/ws-enabled
|
|
|
|
(whitespace-mode t))))
|
2019-03-21 07:42:33 +01:00
|
|
|
(advice-add 'company-call-frontends
|
2019-03-22 09:03:23 +01:00
|
|
|
:before #'my/on-off-whitespace-before-company)
|
2019-04-12 02:01:34 +02:00
|
|
|
;; popup:
|
|
|
|
(defadvice popup-create (before my/popup-suppress-whitespace-mode activate)
|
|
|
|
"Suspend whitespace-mode while popups are visible."
|
|
|
|
(setq-local my/ws-enabled (my/whitespace-mode-enabled-p))
|
|
|
|
(if my/ws-enabled
|
|
|
|
(whitespace-mode -1)))
|
|
|
|
(defadvice popup-delete (after my/popup-restore-whitespace-mode activate)
|
|
|
|
"Restore whitespace-mode when all popups have closed."
|
|
|
|
(if my/ws-enabled
|
|
|
|
(whitespace-mode t)))
|
2019-03-19 00:12:11 +01:00
|
|
|
:bind
|
2019-03-21 07:42:33 +01:00
|
|
|
("C-x w" . 'whitespace-mode)
|
2019-03-21 08:12:44 +01:00
|
|
|
:hook
|
|
|
|
(prog-mode . whitespace-mode)
|
2019-03-24 11:57:28 +01:00
|
|
|
(conf-mode . whitespace-mode)
|
2019-03-21 07:42:33 +01:00
|
|
|
:custom-face
|
|
|
|
(whitespace-space ((nil :foreground "gray18"))))
|
2019-03-19 00:12:11 +01:00
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Spell checking.
|
2019-03-23 06:18:13 +01:00
|
|
|
(if (or (executable-find "aspell")
|
|
|
|
(executable-find "hunspell")
|
|
|
|
(executable-find "ispell"))
|
2019-03-23 06:06:42 +01:00
|
|
|
(unless slow-computer
|
|
|
|
(use-package flyspell
|
|
|
|
:custom
|
|
|
|
(ispell-dictionary "english")
|
|
|
|
:config
|
|
|
|
(defun my/toggle-flyspell ()
|
|
|
|
"Toggle flyspell-mode and run flyspell-buffer after activating."
|
|
|
|
(interactive)
|
|
|
|
(if (bound-and-true-p flyspell-mode)
|
|
|
|
(flyspell-mode 0)
|
|
|
|
(flyspell-mode)
|
|
|
|
(flyspell-buffer)))
|
2019-03-29 19:10:05 +01:00
|
|
|
(defun my/flyspell-german ()
|
|
|
|
"Set dictionary to german."
|
|
|
|
(ispell-change-dictionary "german"))
|
2019-03-23 06:06:42 +01:00
|
|
|
:bind
|
|
|
|
("<f6>" . my/toggle-flyspell)
|
2019-03-30 17:50:50 +01:00
|
|
|
(:map flyspell-mode-map
|
|
|
|
("C-;" . nil)) ; iedit needs C-;.
|
2019-03-23 06:06:42 +01:00
|
|
|
:hook
|
|
|
|
;; Spellcheck comments.
|
2019-03-23 08:46:20 +01:00
|
|
|
(prog-mode . flyspell-prog-mode)
|
2019-03-29 19:10:05 +01:00
|
|
|
;; Spellcheck LaTeX
|
|
|
|
(LaTeX-mode . my/flyspell-german)
|
|
|
|
(LaTeX-mode . flyspell-mode))))
|
2019-03-19 00:12:11 +01:00
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Multiple cursors.
|
2019-03-19 00:12:11 +01:00
|
|
|
(use-package multiple-cursors
|
|
|
|
:init
|
|
|
|
(global-unset-key (kbd "M-<down-mouse-1>"))
|
|
|
|
:bind
|
2019-03-20 09:54:12 +01:00
|
|
|
("C-x M-m" . mc/edit-lines)
|
2019-03-19 00:12:11 +01:00
|
|
|
("M-<mouse-1>" . mc/add-cursor-on-click))
|
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; If 2 files have the same name, append directory name after the filename.
|
2019-03-21 12:48:26 +01:00
|
|
|
(use-package uniquify
|
2019-03-31 19:26:14 +02:00
|
|
|
:ensure nil ; Included in Emacs.
|
2019-03-21 12:48:26 +01:00
|
|
|
:custom
|
|
|
|
(uniquify-after-kill-buffer-p t)
|
|
|
|
(uniquify-buffer-name-style 'post-forward)
|
|
|
|
(uniquify-strip-common-suffix t))
|
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Delete old buffers.
|
2019-03-22 01:57:44 +01:00
|
|
|
;; https://www.emacswiki.org/emacs/CleanBufferList
|
|
|
|
(use-package midnight
|
2019-04-13 20:40:34 +02:00
|
|
|
:defer 10
|
2019-03-22 01:57:44 +01:00
|
|
|
:init
|
2019-03-30 12:29:09 +01:00
|
|
|
(setq midnight-delay 30 ; 30 seconds after "midnight"
|
2019-03-31 18:52:08 +02:00
|
|
|
midnight-period (* 2 60 60)) ; Clean every 2 hours.
|
2019-03-22 09:03:23 +01:00
|
|
|
:custom
|
|
|
|
(clean-buffer-list-delay-general 1) ; Clean normal bufs after 1d.
|
|
|
|
(clean-buffer-list-delay-special (* 30 60)) ; Clean special bufs after 30m.
|
2019-03-22 01:57:44 +01:00
|
|
|
:config
|
2019-03-22 09:03:23 +01:00
|
|
|
(setq clean-buffer-list-kill-regexps ; Add these to special buffers.
|
2019-04-13 20:40:34 +02:00
|
|
|
(nconc clean-buffer-list-kill-regexps
|
2019-03-22 01:57:44 +01:00
|
|
|
'("\\`magit-?.*:"
|
2019-03-31 18:52:08 +02:00
|
|
|
"\\.log\\'"
|
|
|
|
"\\`'\\*rdm\\*\\'")))
|
2019-03-22 01:57:44 +01:00
|
|
|
(midnight-mode t))
|
|
|
|
|
|
|
|
;; The string Time-stamp: <> in the first 8 lines of the file will be updated
|
|
|
|
;; with the current timestamp.
|
|
|
|
(use-package time-stamp
|
2019-03-22 09:03:23 +01:00
|
|
|
:custom
|
2019-04-08 23:52:19 +02:00
|
|
|
(time-stamp-format "%:y-%02m-%02dT%02H:%02M:%02S+00:00")
|
|
|
|
(time-stamp-time-zone t) ; Set to UTC until ISO 8601 is supported.
|
2019-03-22 01:57:44 +01:00
|
|
|
:hook
|
|
|
|
(before-save . time-stamp))
|
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Edit multiple regions in the same way simultaneously.
|
2019-03-22 06:28:59 +01:00
|
|
|
(use-package iedit
|
|
|
|
:bind
|
|
|
|
("C-;" . iedit-mode))
|
|
|
|
|
2019-03-22 23:44:26 +01:00
|
|
|
;; Mode for writing blog posts with hugo.
|
|
|
|
(if (string= (system-name) "ventiloplattform")
|
|
|
|
(use-package easy-hugo
|
|
|
|
:custom
|
|
|
|
(easy-hugo-basedir "~/Projekte/www/blog.tastytea.de/")
|
|
|
|
(easy-hugo-url "https://blog.tastytea.de")
|
|
|
|
(easy-hugo-previewtime "300")
|
|
|
|
(easy-hugo-postdir "content/posts")
|
|
|
|
(easy-hugo-default-ext ".adoc")
|
|
|
|
:bind
|
2019-03-29 19:10:05 +01:00
|
|
|
("C-x M-h" . easy-hugo)
|
2019-03-22 23:44:26 +01:00
|
|
|
:mode
|
|
|
|
;; The mode is not turned on?
|
|
|
|
("\\`'\\*Easy-hugo\\*\\'" . easy-hugo-mode)))
|
2019-03-22 06:28:59 +01:00
|
|
|
|
2019-04-11 18:25:06 +02:00
|
|
|
;; A template system.
|
|
|
|
(use-package yasnippet)
|
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Automatically insert text in new files.
|
2019-03-22 06:28:59 +01:00
|
|
|
(use-package autoinsert
|
2019-04-11 18:25:06 +02:00
|
|
|
:after yasnippet
|
2019-03-22 06:28:59 +01:00
|
|
|
:init
|
|
|
|
(defun my/autoinsert-yas-expand()
|
|
|
|
"Replace text in yasnippet template."
|
|
|
|
(yas-minor-mode t)
|
|
|
|
(yas-expand-snippet (buffer-string) (point-min) (point-max)))
|
|
|
|
:config
|
|
|
|
(add-to-list 'auto-insert-alist
|
|
|
|
'(("\\.\\(cpp\\|cc\\|cxx\\|c\\+\\+\\)\\'" . "C++ program") .
|
|
|
|
["cpp" my/autoinsert-yas-expand]))
|
|
|
|
(add-to-list 'auto-insert-alist
|
|
|
|
'(("\\.\\(hpp\\|hh\\|hxx\\|h\\+\\+\\)\\'" . "C++ header") .
|
2019-03-23 10:44:15 +01:00
|
|
|
["hpp" my/autoinsert-yas-expand]))
|
|
|
|
(add-to-list 'auto-insert-alist
|
|
|
|
'(("\\.[1-9]\\.adoc\\'" . "AsciiDoc manpage") .
|
2019-03-23 20:16:51 +01:00
|
|
|
["manpage.adoc" my/autoinsert-yas-expand]))
|
2019-03-22 06:28:59 +01:00
|
|
|
:custom
|
|
|
|
(auto-insert-directory (concat user-emacs-directory "auto-insert"))
|
2019-03-22 09:03:23 +01:00
|
|
|
(auto-insert-query nil) ; Don't ask before inserting.
|
2019-03-22 06:28:59 +01:00
|
|
|
:hook
|
|
|
|
(find-file . auto-insert))
|
|
|
|
|
2019-03-29 19:10:05 +01:00
|
|
|
;;;;;;;;;;;;;;;;;;;; LaTeX ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2019-04-23 13:55:49 +02:00
|
|
|
(if (executable-find "xetex")
|
2019-04-03 14:21:56 +02:00
|
|
|
(use-package tex-site
|
|
|
|
:ensure auctex
|
|
|
|
:custom
|
|
|
|
(TeX-parse-self t) ; Enable parse on load.
|
|
|
|
(TeX-auto-save t) ; Enable parse on save
|
|
|
|
(TeX-PDF-mode t) ; PDF mode (rather than DVI-mode)
|
2019-04-23 13:55:49 +02:00
|
|
|
(TeX-engine 'xetex)
|
2019-04-03 14:21:56 +02:00
|
|
|
;; To use pdf-tools with auctex.
|
|
|
|
;; https://emacs.stackexchange.com/a/21764/21935
|
|
|
|
(TeX-view-program-selection '((output-pdf "PDF Tools")))
|
|
|
|
(TeX-view-program-list '(("PDF Tools" TeX-pdf-tools-sync-view)))
|
|
|
|
:mode
|
|
|
|
("\\.tex\\'" . LaTeX-mode)
|
|
|
|
:config
|
|
|
|
;; To have the buffer refresh after compilation.
|
|
|
|
(add-hook 'TeX-after-compilation-finished-functions
|
|
|
|
#'TeX-revert-document-buffer)))
|
2019-03-29 19:10:05 +01:00
|
|
|
|
|
|
|
;; Auto complete for LaTeX.
|
|
|
|
(use-package company-auctex
|
2019-03-30 18:15:31 +01:00
|
|
|
:after auctex
|
2019-03-29 19:10:05 +01:00
|
|
|
:hook
|
|
|
|
(LaTeX-mode . company-auctex-init))
|
|
|
|
|
2019-04-11 18:25:06 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;; (X)HTML / CSS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2019-04-12 03:03:37 +02:00
|
|
|
;; Use company auto-completion for (X)HTML.
|
2019-04-11 18:25:06 +02:00
|
|
|
(use-package company-web
|
|
|
|
:after company
|
|
|
|
:config
|
|
|
|
(add-to-list 'company-backends 'company-web-html))
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;; Other file formats ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2019-03-19 00:12:11 +01:00
|
|
|
(use-package adoc-mode
|
2019-03-22 07:42:19 +01:00
|
|
|
:mode
|
2019-04-13 04:49:41 +02:00
|
|
|
("\\.adoc\\'" . adoc-mode)
|
2019-04-10 14:30:43 +02:00
|
|
|
:custom-face
|
|
|
|
;; Style headers.
|
|
|
|
(markup-title-0-face ((t (:inherit markup-gen-face :height 1.4))))
|
|
|
|
(markup-title-1-face ((t (:inherit markup-gen-face :height 1.3))))
|
|
|
|
(markup-title-2-face ((t (:inherit markup-gen-face :height 1.2))))
|
2019-04-12 03:03:37 +02:00
|
|
|
(markup-title-3-face ((t (:inherit markup-gen-face :height 1.1
|
|
|
|
:weight bold))))
|
|
|
|
(markup-title-4-face ((t (:inherit markup-gen-face :height 1.0
|
|
|
|
:underline t))))
|
2019-04-13 04:49:41 +02:00
|
|
|
(markup-title-5-face ((t (:inherit markup-gen-face :height 1.0))))
|
2019-04-12 19:28:16 +02:00
|
|
|
;; Enlarge meta-data a bit.
|
|
|
|
(markup-secondary-text-face ((t (:inherit markup-gen-face :height 0.9
|
|
|
|
:foreground "firebrick"))))
|
2019-03-22 07:42:19 +01:00
|
|
|
:hook
|
2019-04-13 04:49:41 +02:00
|
|
|
(adoc-mode . auto-fill-mode) ; Wrap at fill-column.
|
|
|
|
(adoc-mode . my/set-fill-column-80))
|
2019-03-19 00:12:11 +01:00
|
|
|
|
|
|
|
(use-package markdown-mode
|
2019-03-22 09:03:23 +01:00
|
|
|
:custom
|
2019-03-25 17:04:41 +01:00
|
|
|
(markdown-command "cmark")
|
2019-04-10 14:30:43 +02:00
|
|
|
:custom-face
|
|
|
|
;; Style headers.
|
2019-04-12 03:03:37 +02:00
|
|
|
(markdown-header-face-1 ((t (:inherit markdown-header-face :height 1.4
|
|
|
|
:weight normal))))
|
|
|
|
(markdown-header-face-2 ((t (:inherit markdown-header-face :height 1.3
|
|
|
|
:weight normal))))
|
|
|
|
(markdown-header-face-3 ((t (:inherit markdown-header-face :height 1.2
|
|
|
|
:weight normal))))
|
|
|
|
(markdown-header-face-4 ((t (:inherit markdown-header-face :height 1.1
|
|
|
|
:weight bold))))
|
|
|
|
(markdown-header-face-5 ((t (:inherit markdown-header-face :height 1.0
|
|
|
|
:weight normal :underline t))))
|
|
|
|
(markdown-header-face-6 ((t (:inherit markdown-header-face :height 1.0
|
|
|
|
:weight normal))))
|
|
|
|
(markdown-header-face-7 ((t (:inherit markdown-header-face :height 1.0
|
|
|
|
:weight normal))))
|
2019-03-20 04:46:31 +01:00
|
|
|
:mode
|
|
|
|
(("README\\.md\\'" . gfm-mode)
|
|
|
|
("\\.md\\'" . markdown-mode)
|
|
|
|
("\\.markdown\\'" . markdown-mode))
|
2019-03-22 07:42:19 +01:00
|
|
|
:hook
|
2019-04-23 13:55:49 +02:00
|
|
|
(markdown-mode . my/set-fill-column-80)
|
2019-04-13 04:49:41 +02:00
|
|
|
(markdown-mode . auto-fill-mode)) ; Wrap at fill-column.
|
2019-03-19 00:12:11 +01:00
|
|
|
|
|
|
|
(use-package crontab-mode
|
2019-03-20 04:46:31 +01:00
|
|
|
:mode
|
2019-03-30 18:45:24 +01:00
|
|
|
("/cron\\.d/" . crontab-mode)
|
2019-03-20 22:40:41 +01:00
|
|
|
("\\`'/etc/crontab\\'" . crontab-mode))
|
2019-03-19 00:12:11 +01:00
|
|
|
|
2019-03-19 00:28:35 +01:00
|
|
|
(use-package nginx-mode
|
|
|
|
:defer t)
|
|
|
|
|
|
|
|
(use-package company-nginx
|
|
|
|
:after nginx-mode
|
|
|
|
:hook
|
2019-03-21 07:42:33 +01:00
|
|
|
(nginx-mode . company-nginx-keywords))
|
2019-03-19 00:28:35 +01:00
|
|
|
|
2019-03-30 18:45:24 +01:00
|
|
|
;; View PDF files.
|
|
|
|
(use-package pdf-tools
|
2019-04-23 13:55:49 +02:00
|
|
|
:custom
|
|
|
|
(pdf-misc-print-programm "/usr/bin/lpr")
|
2019-03-30 18:45:24 +01:00
|
|
|
:mode
|
|
|
|
("\\.pdf\\'" . pdf-tools-install))
|
|
|
|
|
2019-04-14 03:40:17 +02:00
|
|
|
(use-package yaml-mode
|
|
|
|
:mode
|
|
|
|
("\\.yml\\'" . yaml-mode)
|
|
|
|
:hook
|
|
|
|
(yaml-mode . my/set-fill-column-80))
|
|
|
|
|
2019-03-19 00:12:11 +01:00
|
|
|
;;;;;;;;;;;;;;;;;;;; Server / Remote editing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Edit remote files.
|
2019-03-22 23:23:51 +01:00
|
|
|
(unless slow-computer
|
|
|
|
(use-package tramp
|
|
|
|
:config
|
|
|
|
;; ssh is faster than scp and supports ports.
|
|
|
|
(setq tramp-default-method "ssh")
|
|
|
|
;; Add verification code support.
|
|
|
|
(customize-set-variable
|
|
|
|
'tramp-password-prompt-regexp
|
|
|
|
(concat
|
|
|
|
"^.*"
|
|
|
|
(regexp-opt
|
|
|
|
'("passphrase" "Passphrase"
|
|
|
|
"password" "Password"
|
|
|
|
"Verification code")
|
|
|
|
t)
|
|
|
|
".*:\0? *"))
|
|
|
|
;; Respect remote PATH.
|
|
|
|
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)))
|
2019-03-19 00:12:11 +01:00
|
|
|
|
|
|
|
;; Run server if:
|
2019-03-22 09:03:23 +01:00
|
|
|
;; - Our EUID is not 0,
|
|
|
|
;; - We are not logged in via SSH,
|
|
|
|
;; - It is not already running.
|
2019-03-19 00:12:11 +01:00
|
|
|
(unless (equal (user-real-uid) 0)
|
|
|
|
(unless (getenv "SSH_CONNECTION")
|
|
|
|
(use-package server
|
2019-03-23 20:16:51 +01:00
|
|
|
:defer 5
|
2019-03-19 00:12:11 +01:00
|
|
|
:init
|
2019-03-20 04:46:31 +01:00
|
|
|
(setq server-use-tcp t
|
|
|
|
server-port 51313
|
2019-03-22 09:03:23 +01:00
|
|
|
server-auth-key ; 64 chars, saved in ~/.emacs.d/server/server.
|
2019-03-19 00:12:11 +01:00
|
|
|
"phahw2ohVoh0oopheish7IVie9desh8aequeenei3uo8wahShe%thuadaeNa4ieh")
|
|
|
|
:config
|
|
|
|
(unless (server-running-p)
|
|
|
|
(server-start))
|
|
|
|
)))
|
|
|
|
|
2019-03-22 09:03:23 +01:00
|
|
|
;; Set garbage collection threshold to original value.
|
2019-03-22 04:08:47 +01:00
|
|
|
(setq gc-cons-threshold (car (get 'gc-cons-threshold 'standard-value)))
|
|
|
|
|
2019-03-19 00:55:01 +01:00
|
|
|
(provide 'init)
|
2019-03-22 09:53:31 +01:00
|
|
|
;;; init.el ends here
|