2017-05-15 01:35:31 +02:00
(package-initialize)
(require 'package)
2017-05-18 00:49:00 +02:00
;; Quote
2017-05-18 00:56:47 +02:00
(setq initial-scratch-message ";; Simplicity and elegance are unpopular because\n;; they require hard work and discipline to achieve\n;; and education to be appreciated.\n;;\n;; - Dijkstra\n\n")
2017-05-18 00:49:00 +02:00
2017-05-20 01:42:12 +02:00
;; Set frame title
(setq frame-title-format "[%m] %f")
2017-05-18 01:48:46 +02:00
;; Default frame size
(setq initial-frame-alist
'(
(width . 110)
(height . 40)
))
2017-05-15 01:35:31 +02:00
(push '("melpa" . "http://melpa.milkbox.net/packages/") package-archives)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(ansi-color-faces-vector
[default default default italic underline success warning error])
2017-05-16 19:24:48 +02:00
'(ansi-color-names-vector
["#242424" "#e5786d" "#95e454" "#cae682" "#8ac6f2" "#333366" "#ccaa8f" "#f6f3e8"])
2017-05-15 01:35:31 +02:00
'(blink-cursor-mode nil)
2017-05-16 19:24:48 +02:00
'(custom-enabled-themes (quote (heroku)))
'(custom-safe-themes
(quote
2017-05-18 00:49:00 +02:00
("4f2ede02b3324c2f788f4e0bad77f7ebc1874eff7971d2a2c9b9724a50fb3f65" default)))
2017-05-15 01:35:31 +02:00
'(global-evil-surround-mode t)
'(inhibit-startup-screen t)
'(menu-bar-mode nil)
'(package-selected-packages
(quote
2017-05-21 21:17:42 +02:00
(swiper neotree centered-cursor-mode ivy avy heroku-theme auto-complete use-package yasnippet evil-surround org evil-magit magit makefile-runner evil)))
2017-05-15 01:35:31 +02:00
'(scroll-bar-mode nil)
'(tool-bar-mode nil))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
2017-05-20 18:03:06 +02:00
'(neo-dir-link-face ((t (:foreground "#fce94f"))))
'(neo-expand-btn-face ((t (:foreground "#ffe070"))))
'(neo-root-dir-face ((t (:foreground "#fff3c6" :weight bold)))))
2017-05-15 01:35:31 +02:00
2017-05-15 14:25:35 +02:00
;; ensure repo cache is up1date
(or (file-exists-p package-user-dir)
(package-refresh-contents))
2017-05-17 20:43:49 +02:00
;; Install use-package
(defun ensure-package-installed (package)
"Ensure packages are installed"
(if (package-installed-p package)
nil
(progn
(package-refresh-contents)
(package-install package))))
(ensure-package-installed 'use-package)
2017-05-19 20:42:54 +02:00
;; *.tex files are Latex-Files
2017-05-20 02:07:33 +02:00
(add-to-list 'auto-mode-alist '("\\.tex\\'" . latex-mode))
2017-05-19 20:42:54 +02:00
2017-05-20 20:39:29 +02:00
;; Extra Latex keybindings
(defun my/latex-keybindings ()
(define-key latex-mode-map (kbd "<f9>") 'recompile))
(add-hook 'latex-mode-hook 'my/latex-keybindings)
2017-05-19 23:55:58 +02:00
;; show parens
(show-paren-mode t)
2017-05-20 02:07:33 +02:00
;; highlight line
(global-hl-line-mode)
2017-05-18 00:49:00 +02:00
;; theme
(use-package heroku-theme
:ensure t)
2017-05-17 20:43:49 +02:00
;; Org-mode
(use-package org
:ensure t)
;; Evil-mode
(use-package evil
:ensure t
:demand t
2017-05-18 20:07:04 +02:00
:config
(evil-mode 1)
2017-05-21 20:51:52 +02:00
(setq evil-ex-substitute-global t)
(define-key evil-normal-state-map "/" 'swiper))
2017-05-17 20:43:49 +02:00
;; Auto-Complete
(use-package auto-complete
:ensure t
:demand t
:config (progn
(require 'auto-complete-config)
(ac-config-default)))
2017-05-16 19:24:48 +02:00
2017-05-19 00:16:17 +02:00
;; ivy
2017-05-18 00:49:00 +02:00
(use-package ivy
:ensure t
:demand t
:config (progn
(ivy-mode 1)
(setq ivy-use-virtual-buffers t)
2017-05-18 01:48:46 +02:00
(setq ivy-count-format "(%d/%d) ")
(define-key ivy-minibuffer-map (kbd "<C-return>") 'ivy-immediate-done)))
2017-05-18 00:49:00 +02:00
2017-05-20 18:03:06 +02:00
;; swiper
(use-package swiper
:ensure t
:bind ("C-s" . swiper))
2017-05-19 20:42:54 +02:00
;; Neotree
(use-package neotree
:ensure t
:bind ("C-x n" . neotree-show)
:config
2017-05-20 01:42:12 +02:00
(setq neo-theme 'ascii)
(evil-define-key 'normal neotree-mode-map (kbd "+") 'neotree-create-node)
2017-05-20 13:55:46 +02:00
(evil-define-key 'normal neotree-mode-map (kbd "g") 'neotree-refresh)
2017-05-20 01:42:12 +02:00
(evil-define-key 'normal neotree-mode-map (kbd "d") 'neotree-delete-node)
(evil-define-key 'normal neotree-mode-map (kbd "c") 'neotree-rename-node)
2017-05-19 20:42:54 +02:00
(evil-define-key 'normal neotree-mode-map (kbd "TAB") 'neotree-enter)
(evil-define-key 'normal neotree-mode-map (kbd "RET") 'neotree-enter)
2017-05-20 01:42:12 +02:00
(evil-define-key 'normal neotree-mode-map (kbd "q") 'neotree-hide))
2017-05-19 20:42:54 +02:00
2017-05-19 00:16:17 +02:00
;; Cursor centered
(use-package centered-cursor-mode
:ensure t
:demand t
2017-05-19 20:42:54 +02:00
:disabled
2017-05-19 00:16:17 +02:00
:config (global-centered-cursor-mode))
2017-05-17 20:43:49 +02:00
;; Yasnippet
(use-package yasnippet
2017-05-18 01:48:46 +02:00
:ensure t
2017-05-17 20:43:49 +02:00
:demand t
:config (yas-global-mode 1))
2017-05-15 14:25:35 +02:00
2017-05-18 00:49:00 +02:00
;; avy
(use-package avy
:ensure t
:demand t
2017-05-20 01:42:12 +02:00
:disabled
2017-05-18 00:49:00 +02:00
:bind ("C-s" . avy-goto-word-0)
:config (progn
(setq avy-keys '(?a ?s ?d ?f ?g ?q ?w ?e ?r ?t ?y ?x ?c ?v ?z ?u ?i ?o ?p ?h ?j ?k ?l ?b ?n ?m))))
2017-05-17 20:43:49 +02:00
;; Magit
(use-package magit
2017-05-18 00:49:00 +02:00
:ensure t
2017-05-17 20:43:49 +02:00
:bind ("C-x g" . magit-status))
2017-05-15 14:25:35 +02:00
2017-05-17 20:43:49 +02:00
;; Easy terminal
(setq my/default-shell (or (executable-find "zsh") (executable-find "bash")))
2017-05-15 18:22:09 +02:00
2017-05-17 20:43:49 +02:00
(defun term-split ()
"creates terminal window below"
(interactive)
(let ((window (split-window-below -7)))
(select-window window)
2017-05-20 18:03:06 +02:00
(term my/default-shell)
(set-window-dedicated-p window t)))
2017-05-17 20:43:49 +02:00
(use-package term
:bind ("C-x t" . term-split))
2017-05-20 18:03:06 +02:00
(defun term-handle-exit--close-buffer (&rest args)
(let ((term-window (get-buffer-window "*terminal*")))
(when (and term-window (window-dedicated-p term-window))
(delete-window term-window))))
(advice-add 'term-handle-exit :after #'term-handle-exit--close-buffer)
2017-05-20 01:42:12 +02:00
2017-05-17 20:43:49 +02:00
;; tabbing (doesn't really work yet)
(setq-default indent-tabs-mode t)
(setq-default tab-width 4)
(setq-default LateX-indent-level 4)
2017-05-16 08:12:04 +02:00
2017-05-18 20:07:04 +02:00
;; Activate line numbers
(global-linum-mode t)
;; compilation buffer
; Set buffer scrolling
(setq compilation-scroll-output 'first-error)
; kill window if successfull
;(defun bury-compile-buffer-if-successful (buffer string)
; "Bury a compilation buffer if succeeded without warnings "
; (when (and
; (buffer-live-p buffer)
; (string-match "compilation" (buffer-name buffer))
; (string-match "finished" string)
; (not
; (with-current-buffer buffer
; (goto-char (point-min))
; (search-forward "warning" nil t))))
; (run-with-timer 1 nil
; (lambda (buf)
; (bury-buffer buf)
; (switch-to-prev-buffer (get-buffer-window buf) 'kill))
; buffer)))
;(add-hook 'compilation-finish-functions 'bury-compile-buffer-if-successful)
; set window height
(setq compilation-window-height 10)
(defun my-compilation-hook ()
(when (not (get-buffer-window "*compilation*"))
(save-selected-window
(save-excursion
(let* ((w (split-window-vertically))
(h (window-height w)))
(select-window w)
(switch-to-buffer "*compilation*")
(shrink-window (- h compilation-window-height)))))))
(add-hook 'compilation-mode-hook 'my-compilation-hook)
2017-05-15 14:25:35 +02:00
;; Window movement
2017-05-20 01:42:12 +02:00
; Old keys
2017-05-20 18:03:06 +02:00
(global-set-key (kbd "C-x <up>") 'windmove-up)
(global-set-key (kbd "C-x <down>") 'windmove-down)
(global-set-key (kbd "C-x <left>") 'windmove-left)
(global-set-key (kbd "C-x <right>") 'windmove-right)
2017-05-20 01:42:12 +02:00
; New keys
(global-set-key (kbd "<M-up>") 'windmove-up)
(global-set-key (kbd "<M-down>") 'windmove-down)
(global-set-key (kbd "<M-left>") 'windmove-left)
(global-set-key (kbd "<M-right>") 'windmove-right)
2017-05-15 14:25:35 +02:00
(defun cycle-window ()
"cycles windows"
(interactive)
(select-window (next-window)))
(global-set-key (kbd "<C-tab>") 'cycle-window)
2017-05-17 20:43:49 +02:00
;; Latex german
(quail-define-package "latex-german" "UTF-8" "LaGe" t
"Transforms umlauts to the better latex notation.
ä -> \"a
ö -> \"o
ü -> \"u
Ä -> \"A
Ö -> \"O
Ü -> \"U
ß -> \"s"
nil t nil nil nil nil nil nil nil nil t)
(quail-define-rules
("ä" ["\"a"])
("ö" ["\"o"])
("ü" ["\"u"])
("Ä" ["\"A"])
("Ö" ["\"O"])
("Ü" ["\"U"])
("ß" ["\"s"])
)
(add-hook 'latex-mode-hook (lambda ()
(set-input-method "latex-german")
(local-set-key "\"" 'self-insert-command)))
2017-05-15 18:22:09 +02:00
;; Split windows horizontally preferred
(setq split-height-threshold 6)
(setq split-width-threshold 20)
2017-05-17 20:43:49 +02:00
;; Overlay windows (What does it do?)
2017-05-15 14:25:35 +02:00
(add-to-list 'display-buffer-alist
'("*Apropos*" display-buffer-same-window))
(add-to-list 'display-buffer-alist
'("*Help*" display-buffer-same-window))
2017-05-17 20:43:49 +02:00
;; Change all prompts to y or n
(fset 'yes-or-no-p 'y-or-n-p)
2017-05-19 23:55:58 +02:00
2017-05-20 01:42:12 +02:00
;; Insert time, german format
(defun datetime-german ()
(interactive)
(insert (format-time-string "%d.%m.%Y %H:%M")))
(global-set-key (kbd "C-c C-d") 'datetime-german)
2017-05-19 23:55:58 +02:00
;; Comment fun
;(defun extend-comment ()
; (interactive)
; (if (looking-back "//" (line-beginning-position))
; (progn
; (newline-and-indent)
; (insert "Hallo Welt"))
; (newline-and-indent)))
;; Show in binary and decimal
;(defun hex-popup ()
; (interactive)
; (let (hexStr p1 p2)
; (save-excursion
; (search-backward-regexp "[^0-9A-Fa-f]" nil t)
; (forward-char)
; (setq p1 (point))
; (search-forward-regexp "[^0-9A-Fa-f]" nil t)
; (backward-char)
; (setq p2 (point)))
; (setq hexStr (buffer-substring-no-properties p1 p2))
; (message "The hex number is: '%s' '%d' '%d'" hexStr p1 p2)))