Moved .emacs to .emacs.d/init.el.
This commit is contained in:
parent
02995a4d60
commit
ca474c5958
427
init.el
Normal file
427
init.el
Normal file
|
@ -0,0 +1,427 @@
|
|||
;;; .emacs --- tastytea's .emacs file.
|
||||
;;; Commentary:
|
||||
;;; Code:
|
||||
(require 'package)
|
||||
;; (add-to-list 'package-archives
|
||||
;; '("melpa-stable" . "https://stable.melpa.org/packages/") t)
|
||||
(add-to-list 'package-archives
|
||||
'("melpa" . "https://melpa.org/packages/") t)
|
||||
(package-initialize)
|
||||
|
||||
;; Add path for custom packages
|
||||
(add-to-list 'load-path "~/.emacs.d/custom-packages/")
|
||||
|
||||
;; Install use-package if necessary
|
||||
(unless (package-installed-p 'use-package)
|
||||
(package-refresh-contents)
|
||||
(package-install 'use-package))
|
||||
|
||||
(eval-when-compile
|
||||
(require 'use-package))
|
||||
|
||||
;; Always install packages if they are not present
|
||||
(require 'use-package-ensure)
|
||||
(setq use-package-always-ensure t)
|
||||
|
||||
;; ;; Benchmark initialization
|
||||
;; (use-package benchmark-init
|
||||
;; :config
|
||||
;; ;; To disable collection of benchmark data after init is done.
|
||||
;; (add-hook 'after-init-hook 'benchmark-init/deactivate))
|
||||
|
||||
;; Update packages if at least auto-package-update-interval (7) days have passed
|
||||
(use-package auto-package-update
|
||||
:config
|
||||
(setq auto-package-update-delete-old-versions t)
|
||||
;; (setq auto-package-update-hide-results t)
|
||||
(auto-package-update-maybe))
|
||||
|
||||
;; Determine if we run on a slow computer
|
||||
(defvar slow-computer nil)
|
||||
(if (member (system-name) '("steuerbeamter" "azimuth" "localhost"))
|
||||
(setq slow-computer t)) ; localhost is schnibble
|
||||
|
||||
;; Just type y/n instead of yes/no when prompted
|
||||
(defalias 'yes-or-no-p 'y-or-n-p)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;; Configure some minor modes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Hide toolbar
|
||||
(tool-bar-mode -1)
|
||||
|
||||
;; Save cursor position
|
||||
(save-place-mode 1)
|
||||
|
||||
;; Delete selection when you start to write
|
||||
(delete-selection-mode t)
|
||||
|
||||
;; Save minibuffer history
|
||||
(savehist-mode t)
|
||||
|
||||
;; Show column numbers in modeline
|
||||
(column-number-mode t)
|
||||
|
||||
;; Auto-type closing brackets
|
||||
(electric-pair-mode t)
|
||||
|
||||
;; Accelerate startup by not printing so much
|
||||
(setf inhibit-startup-screen t
|
||||
inhibit-startup-echo-area-message t
|
||||
inhibit-startup-message t)
|
||||
|
||||
;; Save backups in ~/.emacs.d/ and keep more versions
|
||||
(setq backup-directory-alist
|
||||
`(("." . ,(concat user-emacs-directory "backups"))))
|
||||
(setq delete-old-versions t
|
||||
kept-new-versions 6
|
||||
kept-old-versions 2
|
||||
version-control t)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;; Keybindings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Next/Previous buffer
|
||||
(global-set-key (kbd "C-c <left>") 'previous-buffer)
|
||||
(global-set-key (kbd "C-c <right>") 'next-buffer)
|
||||
;; Scroll in other window
|
||||
(global-set-key (kbd "S-<prior>") 'scroll-other-window-down)
|
||||
(global-set-key (kbd "S-<next>") 'scroll-other-window)
|
||||
;; Switch window
|
||||
(global-set-key (kbd "C-<tab>") 'other-window)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;; Programming / irony ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; (unless slow-computer
|
||||
;; (use-package irony
|
||||
;; :hook
|
||||
;; (c++-mode . irony-mode)
|
||||
;; (c-mode . irony-mode)
|
||||
;; (irony-mode . irony-cdb-autosetup-compile-options)
|
||||
;; :config
|
||||
;; ;; If irony server was never installed, install it.
|
||||
;; (unless (irony--find-server-executable)
|
||||
;; (call-interactively #'irony-install-server))
|
||||
;; ;; Use compilation database first, clang_complete as fallback.
|
||||
;; (setq-default irony-cdb-compilation-databases '(irony-cdb-libclang
|
||||
;; irony-cdb-clang-complete))))
|
||||
|
||||
;; ;; Eldoc shows argument list of the function you are currently writing.
|
||||
;; (unless slow-computer
|
||||
;; (use-package eldoc))
|
||||
;; (use-package irony-eldoc
|
||||
;; :after (eldoc irony)
|
||||
;; :init
|
||||
;; :hook
|
||||
;; (irony-mode . #'irony-eldoc))
|
||||
|
||||
;; ;; Syntax checker
|
||||
;; (unless slow-computer
|
||||
;; (use-package flycheck))
|
||||
;; (use-package flycheck-irony
|
||||
;; :after (flycheck irony)
|
||||
;; :config
|
||||
;; (global-flycheck-mode)
|
||||
;; (eval-after-load 'flycheck
|
||||
;; '(add-hook 'flycheck-mode-hook #'flycheck-irony-setup)))
|
||||
|
||||
;; ;; Autocomplete
|
||||
;; (unless slow-computer
|
||||
;; (use-package company
|
||||
;; :hook
|
||||
;; (after-init . global-company-mode)))
|
||||
;; (use-package company-irony
|
||||
;; :after (company irony)
|
||||
;; :config
|
||||
;; (add-to-list 'company-backends 'company-irony))
|
||||
|
||||
;; ;; Autocomplete headers
|
||||
;; (use-package company-irony-c-headers
|
||||
;; :after (company-irony)
|
||||
;; :config
|
||||
;; (add-to-list 'company-backends 'company-irony-c-headers))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;; Programming / RTags ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
(unless slow-computer
|
||||
(use-package rtags
|
||||
:if (executable-find "llvm-config")
|
||||
:if (executable-find "clang++")
|
||||
:config
|
||||
(unless (and (rtags-executable-find "rc") (rtags-executable-find "rdm"))
|
||||
(progn
|
||||
(message "RTags is not installed!")
|
||||
(rtags-install)))
|
||||
|
||||
(define-key c-mode-base-map (kbd "M-.") 'rtags-find-symbol-at-point)
|
||||
(define-key c-mode-base-map (kbd "M-,") 'rtags-find-references-at-point)
|
||||
(define-key c-mode-base-map (kbd "M-?") 'rtags-display-summary)
|
||||
(rtags-enable-standard-keybindings)
|
||||
:hook
|
||||
(c++-mode . (rtags-start-process-unless-running))
|
||||
(c-mode . (rtags-start-process-unless-running))
|
||||
(kill-emacs . rtags-quit-rdm)))
|
||||
|
||||
(unless slow-computer
|
||||
(use-package flycheck))
|
||||
(use-package flycheck-rtags
|
||||
:after (flycheck rtags)
|
||||
:defer nil
|
||||
:config
|
||||
;; ensure that we use only rtags checking
|
||||
;; https://github.com/Andersbakken/rtags#optional-1
|
||||
(defun setup-flycheck-rtags ()
|
||||
(flycheck-select-checker 'rtags)
|
||||
(setq-local flycheck-highlighting-mode nil)) ; Can't disable RTags overlay
|
||||
(global-flycheck-mode)
|
||||
:hook
|
||||
(c-mode-hook . #'setup-flycheck-rtags)
|
||||
(c++-mode-hook . #'setup-flycheck-rtags))
|
||||
|
||||
(unless slow-computer
|
||||
(use-package company
|
||||
:hook
|
||||
(after-init . global-company-mode)))
|
||||
(use-package company-rtags
|
||||
:after (company rtags)
|
||||
:config
|
||||
;; (setq rtags-autostart-diagnostics t)
|
||||
;; (rtags-diagnostics)
|
||||
(setq rtags-completions-enabled t)
|
||||
(push 'company-rtags company-backends))
|
||||
|
||||
;; Fuzzy autocompletion
|
||||
(use-package company-flx
|
||||
:after company
|
||||
:config
|
||||
(company-flx-mode +1))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;; Programming / other ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; cmake integration
|
||||
(unless slow-computer
|
||||
(use-package cmake-ide
|
||||
:config
|
||||
(setq cmake-ide-build-dir "build")
|
||||
(cmake-ide-setup)))
|
||||
|
||||
;; Project management
|
||||
(unless slow-computer
|
||||
(use-package projectile
|
||||
:after neotree
|
||||
:config
|
||||
(projectile-mode +1)
|
||||
(setq projectile-switch-project-action 'neotree-projectile-action)
|
||||
(setq projectile-project-compilation-dir "build")
|
||||
(setq projectile-project-configure-cmd
|
||||
"cmake -DCMAKE_BUILD_TYPE=Debug
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -G 'Unix Makefiles'
|
||||
..")
|
||||
(setq projectile-project-compilation-cmd "cmake --build .")
|
||||
:bind
|
||||
("C-c p" . 'projectile-command-map)))
|
||||
|
||||
;; Debugger
|
||||
(use-package realgud
|
||||
:config
|
||||
(defun load-realgud ()
|
||||
(load-library "realgud"))
|
||||
:hook
|
||||
(c++-mode . load-realgud)
|
||||
(c-mode . load-realgud))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;; Misc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Directory tree
|
||||
(use-package neotree
|
||||
:demand t
|
||||
:config
|
||||
(setq neo-smart-open t)
|
||||
:bind
|
||||
("<f8>" . neotree-toggle))
|
||||
|
||||
;; Indentation
|
||||
(setq-default indent-tabs-mode nil
|
||||
tab-width 4)
|
||||
;(setq tab-width 4)
|
||||
(setq c-default-style "linux"
|
||||
c-basic-offset 4)
|
||||
|
||||
(use-package git-commit)
|
||||
(use-package magit
|
||||
:bind
|
||||
("C-x g" . magit-status)
|
||||
("C-x M-g" . magit-dispatch))
|
||||
|
||||
;; Appearance
|
||||
(unless slow-computer
|
||||
(use-package monokai-theme
|
||||
:init
|
||||
(setq monokai-highlight-line "#34342F")
|
||||
:config
|
||||
(load-theme 'monokai t)))
|
||||
(set-face-font 'default "Source Code Pro")
|
||||
(global-hl-line-mode t)
|
||||
(global-display-line-numbers-mode)
|
||||
(setq show-trailing-whitespace t)
|
||||
(show-paren-mode t)
|
||||
|
||||
;; Draw line in column 80
|
||||
(use-package fill-column-indicator
|
||||
:after company
|
||||
:init
|
||||
(setq fci-rule-column 80)
|
||||
;; Fix bug with fci + company
|
||||
(defun on-off-fci-before-company(command)
|
||||
(when (string= "show" command)
|
||||
(turn-off-fci-mode))
|
||||
(when (string= "hide" command)
|
||||
(turn-on-fci-mode)))
|
||||
;; Add global fci-mode
|
||||
(define-globalized-minor-mode global-fci-mode fci-mode
|
||||
(lambda () (fci-mode t)))
|
||||
:config
|
||||
(global-fci-mode t)
|
||||
(advice-add 'company-call-frontends :before #'on-off-fci-before-company))
|
||||
|
||||
;; Highlight TODO, FIXME, NOTE
|
||||
(use-package hl-todo
|
||||
:config
|
||||
(global-hl-todo-mode t))
|
||||
|
||||
;; Better commenting
|
||||
(use-package smart-comment
|
||||
:bind
|
||||
("C-c c" . smart-comment))
|
||||
|
||||
;; IDO
|
||||
(use-package ido)
|
||||
(use-package flx-ido
|
||||
:after ido
|
||||
:config
|
||||
(ido-mode t)
|
||||
(ido-everywhere t)
|
||||
(flx-ido-mode t)
|
||||
(setq ido-enable-flex-matching t)
|
||||
(setq ido-ignore-extensions t))
|
||||
|
||||
;; Toggle betweeen beginning of line and beginning of code
|
||||
(defun beginning-of-line-or-indentation ()
|
||||
"Move to beginning of line, or indentation."
|
||||
(interactive)
|
||||
(if (bolp)
|
||||
(back-to-indentation)
|
||||
(beginning-of-line)))
|
||||
(global-set-key (kbd "<home>") 'beginning-of-line-or-indentation)
|
||||
|
||||
;; Tab bar
|
||||
(unless slow-computer
|
||||
(use-package tabbar-ruler
|
||||
:after projectile
|
||||
:init
|
||||
(setq tabbar-ruler-global-tabbar t)
|
||||
: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
|
||||
;; (mode-icons-mode 0) ; Disable modeline symbols
|
||||
(setq tabbar-ruler-swap-faces t) ; Swap tab colors
|
||||
:bind
|
||||
("C-<prior>" . 'tabbar-ruler-tabbar-backward-tab)
|
||||
("C-<next>" . 'tabbar-ruler-tabbar-forward-tab)))
|
||||
|
||||
;; Keybinding for whitespace, don't visualise newlines
|
||||
(use-package whitespace
|
||||
:config
|
||||
(delete 'newline-mark whitespace-style)
|
||||
:bind
|
||||
("C-C w" . 'whitespace-mode))
|
||||
|
||||
;; Spell checking
|
||||
(use-package flyspell
|
||||
:config
|
||||
(defun 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)))
|
||||
(setq ispell-dictionary "english")
|
||||
:bind
|
||||
("<f6>" . toggle-flyspell)
|
||||
:hook
|
||||
(c++-mode . flyspell-prog-mode)
|
||||
(c-mode . flyspell-prog-mode))
|
||||
|
||||
;; Multiple cursors
|
||||
(use-package multiple-cursors
|
||||
:init
|
||||
(global-unset-key (kbd "M-<down-mouse-1>"))
|
||||
:bind
|
||||
("C-c m c" . mc/edit-lines)
|
||||
("M-<mouse-1>" . mc/add-cursor-on-click))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;; File formats ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; AsciiDoc
|
||||
(use-package adoc-mode
|
||||
:mode (("\\.adoc" . adoc-mode)))
|
||||
|
||||
;; Markdown
|
||||
(use-package markdown-mode
|
||||
:mode (("README\\.md\\'" . gfm-mode)
|
||||
("\\.md\\'" . markdown-mode)
|
||||
("\\.markdown\\'" . markdown-mode))
|
||||
:init (setq markdown-command "markdown2"))
|
||||
|
||||
;; Crontabs
|
||||
(use-package crontab-mode
|
||||
:defer t)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;; Server / Remote editing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Edit remote files
|
||||
(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)))
|
||||
|
||||
;; Run server if:
|
||||
;; - Our EUID is not 0
|
||||
;; - We are not logged in via SSH
|
||||
;; - It is not already running
|
||||
(unless (equal (user-real-uid) 0)
|
||||
(unless (getenv "SSH_CONNECTION")
|
||||
(use-package server
|
||||
:init
|
||||
(setq server-use-tcp t)
|
||||
(setq server-port 51313)
|
||||
(setq server-auth-key
|
||||
"phahw2ohVoh0oopheish7IVie9desh8aequeenei3uo8wahShe%thuadaeNa4ieh")
|
||||
:config
|
||||
(unless (server-running-p)
|
||||
(server-start))
|
||||
)))
|
||||
|
||||
(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.
|
||||
'(package-selected-packages
|
||||
(quote
|
||||
(use-package-ensure zenburn-theme use-package tabbar-ruler spaceline smart-comment realgud projectile popup neotree multiple-cursors monokai-theme markdown-mode magit irony-eldoc hl-todo flycheck-rtags flycheck-irony flx-ido fill-column-indicator crontab-mode counsel company-rtags company-irony-c-headers company-irony company-flx cmake-ide benchmark-init base16-theme autothemer auto-package-update adoc-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.
|
||||
;; Your init file should contain only one such instance.
|
||||
;; If there is more than one, they won't work right.
|
||||
)
|
||||
|
||||
(provide '.emacs)
|
||||
;;; .emacs ends here
|
Loading…
Reference in New Issue
Block a user