emacs.d: initial config version

- starting init.el
  just basics (package, use-package, path-handlin)
- include my-site-start.el
  that includes site-start.d directory and imports
  all *.el files in lexical order
- functionality is imported via use-package inside
  the *.el file
  (first run: internet connection is needed to MELPA)
This commit is contained in:
2020-06-03 22:24:55 +02:00
commit dfd4317d2d
27 changed files with 7147 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
;;; 00-my-setup.el --- basic personal definitions
;;; Commentary:
;; to debug the startup, run Emacs with folloging flag
;; emacs --debug-init
;;;
;;; Code:
;; regular used custom function
(defun reload-init-file ()
"Reload my init file."
(interactive)
(load-file user-init-file))
(bind-key "C-c M-l" 'reload-init-file)
;; surpress bloat messages
(setq inhibit-startup-message t
initial-scratch-message ""
inhibit-startup-echo-area-message t
inhibit-splash-screen t)
;; line wrapping
(setq new-line-add-newlines nil)
(setq-default truncate-lines t)
(setq truncate-partial-width-windows nil)
;; symbol and cursor handling
(global-prettify-symbols-mode +1)
(setq x-stretch-cursor t)
;; to window panes organized horizontally
;; (split-window-horizontally)
;; python mode adaptions
(add-hook 'python-mode-hook
(lambda ()
(setq indent-tabs-mode t)
(setq python-indent 8)
(setq tab-width 4)))
;; enable 'linux' as default c-mode minor mode
(add-hook 'c-mode-common-hook
'linux)
;; auto enable modes
(semantic-mode 1)
;; auto enable recent files
(recentf-mode 1)
;; where are my encrypted auth keys
(setq auth-sources
'((:source "~/.emacs.d/secrets/.authinfo.gpg")))
;; automactic handling of whitespace cleanup
(add-hook 'before-save-hook 'whitespace-cleanup)
;; font settings
(set-default-font "Source Code Pro" nil t)
(set-face-attribute 'default nil :height 110)
;; prettify symbols
(global-prettify-symbols-mode +1)
;; save Emacs backup files in one central directory, not cluttering the filesystem
(setq backup-directory-alist
`(("." . ,(expand-file-name
(concat user-emacs-directory "backups")))))
;; shorten yes or no dialog
(fset 'yes-or-no-p 'y-or-n-p)
(provide '00-my-setup)
;;; 00-my-setup.el ends here

View File

@@ -0,0 +1,11 @@
;;; 02-load-path.el --- customize loadpath
;;; Commentary:
;; load-path will enable to autoload your custom lisp code
;; that is not handled via packages (like use-package)
;;; Code:
(add-to-list 'load-path "~/.emacs.d/site-lisp")
(provide '02-load-path)
;;; 401-rust.el ends here

19
site-start.d/101-async.el Normal file
View File

@@ -0,0 +1,19 @@
;;; 101-async.el --- asynchronous code execution
;;; Commentary:
;; Async enables asynchronous processing in Emacs, as well as some basic implementations of asynchronous capabilities
;;; Code:
(use-package async
:init
(autoload 'dired-async-mode "dired-async.el" nil t)
(dired-async-mode 1)
(async-bytecomp-package-mode 1)
(autoload 'dired-async-mode "dired-async.el" nil t)
(async-bytecomp-package-mode 1)
(dired-async-mode 1)
(require 'smtpmail-async)
(setq send-mail-function 'async-smtpmail-send-it))
(provide '101-async)
;;; 101-async.el ends here

29
site-start.d/102-hydra.el Normal file
View File

@@ -0,0 +1,29 @@
;;; 102-hydra.el --- tie related commands into a family of short bindings
;;; Commentary:
;; Hydra enables you to tie related commands into a family of short bindings
;; with a common prefix - a Hydra.
;; reference: https://github.com/abo-abo/hydra
;;; Code:
(use-package hydra
:config
(setq hydra-lv nil))
;; Zooming
(defhydra hydra-zoom ()
"zoom"
("+" text-scale-increase "in")
("=" text-scale-increase "in")
("-" text-scale-decrease "out")
("_" text-scale-decrease "out")
("0" (text-scale-adjust 0) "reset")
("q" nil "quit" :color blue))
(bind-keys ("C-x C-0" . hydra-zoom/body)
("C-x C-=" . hydra-zoom/body)
("C-x C--" . hydra-zoom/body)
("C-x C-+" . hydra-zoom/body))
(provide '102-hydra)
;;; 102-hydra.el ends here

View File

@@ -0,0 +1,71 @@
;;; 102-ivy-councel.el --- Completion framework for Emacs
;;; Commentary:
;; Ivy - a generic completion frontend for Emacs,
;; Swiper - isearch with an overview
;; Councel - it consumes Ivy and provides useful commands
;; Reference: https://github.com/abo-abo/swiper
;; Presentation: https://writequit.org/denver-emacs/presentations/2017-04-11-ivy.html
;;; Code:
(use-package counsel
:bind (("C-x C-f" . counsel-find-file)
("C-x C-m" . counsel-M-x)
("C-x C-f" . counsel-find-file)
("C-h f" . counsel-describe-function)
("C-h v" . counsel-describe-variable)
("M-i" . counsel-imenu)
("M-I" . counsel-imenu)
("C-c i" . counsel-unicode-char)
:map read-expression-map
("C-r" . counsel-expression-history)))
(use-package swiper
:bind (("C-s" . swiper)
("C-r" . swiper)
("C-c C-r" . ivy-resume)
:map ivy-minibuffer-map
("C-SPC" . ivy-restrict-to-matches))
:init
(ivy-mode 1)
:config
(setq ivy-count-format "(%d/%d) "
ivy-display-style 'fancy
ivy-height 4
ivy-use-virtual-buffers t
ivy-initial-inputs-alist () ;; http://irreal.org/blog/?p=6512
enable-recursive-minibuffers t))
(use-package all-the-icons)
(use-package ivy-rich
:after ivy
:config
;; All the icon support to ivy-rich
(defun ivy-rich-switch-buffer-icon (candidate)
(with-current-buffer
(get-buffer candidate)
(all-the-icons-icon-for-mode major-mode)))
(setq ivy-rich--display-transformers-list
'(ivy-switch-buffer
(:columns
((ivy-rich-switch-buffer-icon (:width 2))
(ivy-rich-candidate (:width 30))
(ivy-rich-switch-buffer-size (:width 7))
(ivy-rich-switch-buffer-indicators (:width 4 :face error :align right))
(ivy-rich-switch-buffer-major-mode (:width 12 :face warning))
(ivy-rich-switch-buffer-project (:width 15 :face success))
(ivy-rich-switch-buffer-path (:width (lambda (x) (ivy-rich-switch-buffer-shorten-path x (ivy-rich-minibuffer-width 0.3))))))
:predicate
(lambda (cand) (get-buffer cand)))))
;; Add custom icons for various modes that can break ivy-rich
(add-to-list 'all-the-icons-mode-icon-alist '(dashboard-mode all-the-icons-fileicon "elisp" :height 1.0 :v-adjust -0.2 :face all-the-icons-dsilver))
(add-to-list 'all-the-icons-mode-icon-alist '(ess-mode all-the-icons-fileicon "R" :face all-the-icons-lblue))
(ivy-rich-mode 1))
(provide '102-ivy-councel)
;;; 102-ivy-councel.el ends here

35
site-start.d/104-avy.el Normal file
View File

@@ -0,0 +1,35 @@
;;; 104-avy-ace.el --- Quick jumping inside Emacs
;;; Commentary:
;; Avy - Jump to Characters and Words
;; Ace - Jump to Windows
;;; Code:
(use-package avy
:bind ("M-SPC" . avy-goto-char)
:config
(setq avy-background t
avy-keys '(?a ?o ?e ?u ?i ?d ?h ?t ?n ?s)))
(use-package ace-window
:bind (("C-x o" . ace-window)
("M-2" . ace-window))
:init
(setq aw-background nil
aw-keys '(?a ?o ?e ?u ?i ?d ?h ?t ?n ?s)))
(use-package ace-link
:init
(ace-link-setup-default))
(bind-keys :prefix-map avy-map
:prefix "C-c j"
("c" . avy-goto-char)
("l" . avy-goto-line)
("w" . avy-goto-word-or-subword-1)
("W" . ace-window)
("z" . avy-zap-to-char)
("Z" . avy-zap-up-to-char))
(provide '104-avy-ace)
;;; 104-avy-ace.el ends here

View File

@@ -0,0 +1,22 @@
;;; 105-flycheck.el --- on-the-fly syntax checking
;;; Commentary:
;; Flycheck is a modern on-the-fly syntax checking extension for GNU Emacs
;;; Code:
(use-package flycheck
:ensure t
:init
;; enables syntax checking for every supported language
(global-flycheck-mode))
;; Force flycheck to always use c++11 support. We use
;; the clang language backend so this is set to clang
;;(add-hook 'c++-mode-hook
;; (lambda () (setq flycheck-clang-language-standard "c++11")))
;; Use flycheck-pyflakes for python. Seems to work a little better.
;;(require 'flycheck-pyflakes)
(provide '105-flycheck)
;;; 105-flycheck.el ends here

View File

@@ -0,0 +1,71 @@
;;; 106-parentheses.el --- use smartparens
;;; Commentary:
;; Ease completion aof the right parenthese
;;; Code:
(use-package smartparens
:bind
(("C-M-f" . sp-forward-sexp)
("C-M-b" . sp-backward-sexp)
("C-M-d" . sp-down-sexp)
("C-M-a" . sp-backward-down-sexp)
("C-S-a" . sp-beginning-of-sexp)
("C-S-d" . sp-end-of-sexp)
("C-M-e" . sp-up-sexp)
("C-M-u" . sp-backward-up-sexp)
("C-M-t" . sp-transpose-sexp)
("C-M-n" . sp-next-sexp)
("C-M-p" . sp-previous-sexp)
("C-M-k" . sp-kill-sexp)
("C-M-w" . sp-copy-sexp)
("M-<delete>" . sp-unwrap-sexp)
("M-S-<backspace>" . sp-backward-unwrap-sexp)
("C-<right>" . sp-forward-slurp-sexp)
("C-<left>" . sp-forward-barf-sexp)
("C-M-<left>" . sp-backward-slurp-sexp)
("C-M-<right>" . sp-backward-barf-sexp)
("M-D" . sp-splice-sexp)
("C-M-<delete>" . sp-splice-sexp-killing-forward)
("C-M-<backspace>" . sp-splice-sexp-killing-backward)
("C-M-S-<backspace>" . sp-splice-sexp-killing-around)
("C-]" . sp-select-next-thing-exchange)
("C-<left_bracket>" . sp-select-previous-thing)
("C-M-]" . sp-select-next-thing)
("M-F" . sp-forward-symbol)
("M-B" . sp-backward-symbol)
("H-t" . sp-prefix-tag-object)
("H-p" . sp-prefix-pair-object)
("H-s c" . sp-convolute-sexp)
("H-s a" . sp-absorb-sexp)
("H-s e" . sp-emit-sexp)
("H-s p" . sp-add-to-previous-sexp)
("H-s n" . sp-add-to-next-sexp)
("H-s j" . sp-join-sexp)
("H-s s" . sp-split-sexp)
("M-9" . sp-backward-sexp)
("M-0" . sp-forward-sexp))
:init
(smartparens-global-mode t)
(show-smartparens-global-mode t)
(use-package smartparens-config
:ensure f)
(bind-key "s" 'smartparens-mode toggle-map)
(when (is-mac-p)
(bind-keys ("<s-right>" . sp-forward-slurp-sexp)
("<s-left>" . sp-forward-barf-sexp)))
(sp-with-modes '(markdown-mode gfm-mode)
(sp-local-pair "*" "*"))
(sp-with-modes '(org-mode)
(sp-local-pair "=" "=")
(sp-local-pair "*" "*")
(sp-local-pair "/" "/")
(sp-local-pair "_" "_")
(sp-local-pair "+" "+")
(sp-local-pair "<" ">")
(sp-local-pair "[" "]"))
(use-package rainbow-delimiters
:hook (prog-mode . rainbow-delimiters-mode)))
(provide '106-parantheses)
;;; 106-parentheses.el ends here

View File

@@ -0,0 +1,19 @@
;;; 20-counsel-gtags.el --- counsel-gtags adaptions
;;; Commentary:
;; Online Documentation can be found at
;; https://github.com/syohex/emacs-counsel-gtags
;;; Code:
(add-hook 'c-mode-hook 'counsel-gtags-mode)
(add-hook 'c++-mode-hook 'counsel-gtags-mode)
(with-eval-after-load 'counsel-gtags
(define-key counsel-gtags-mode-map (kbd "M-t") 'counsel-gtags-find-definition)
(define-key counsel-gtags-mode-map (kbd "M-r") 'counsel-gtags-find-reference)
(define-key counsel-gtags-mode-map (kbd "M-s") 'counsel-gtags-find-symbol)
(define-key counsel-gtags-mode-map (kbd "M-,") 'counsel-gtags-go-backward)
)
;;; 20-counsel-gtags.el ends here

View File

@@ -0,0 +1,32 @@
;;; 20-hs-minor-mode.el --- hide-show code folding
;;; Commentary:
;; Online Documentation can be found at
;; https://www.emacswiki.org/emacs/HideShow
;;; Code:
(load-library "hideshow")
(global-set-key (kbd "C-+") 'toggle-hiding)
(global-set-key (kbd "C-\\") 'toggle-selective-display)
;; activate on following major modes
(add-hook 'c-mode-common-hook 'hs-minor-mode)
(add-hook 'emacs-lisp-mode-hook 'hs-minor-mode)
(add-hook 'java-mode-hook 'hs-minor-mode)
(add-hook 'lisp-mode-hook 'hs-minor-mode)
(add-hook 'perl-mode-hook 'hs-minor-mode)
(add-hook 'sh-mode-hook 'hs-minor-mode)
(add-hook 'rust-mode-hook 'hs-minor-mode)
;; Hide the comments too when you do a 'hs-hide-all'
(setq hs-hide-comments nil)
;; Set whether isearch opens folded comments, code, or both
;; where x is code, comments, t (both), or nil (neither)
(setq hs-isearch-open 'code)
;; enable hs-minor-mode globaly
;; (hs-minor-mode 1)
;;; 20-hs-minor-mode.el ends here

74
site-start.d/401-rust.el Normal file
View File

@@ -0,0 +1,74 @@
;;; 401-rust.el --- handle rust code
;;; Commentary:
;; using rust-mode with rust-analyzer via lsp
;;; Code:
;; load rustic -> IDE like for rust
(use-package rustic
:ensure t
:init
(setq rustic-lsp-server 'rust-analyzer)
(setq rustic-format-on-save t))
;; use the lsp UI package
(use-package lsp-ui)
;; use rust-analyzer via lsp
;; (setq lsp-rust-analyzer-server-command '("~/.cargo/bin/rust-analyzer"))
;; (add-hook 'before-save-hook (lambda () (when (eq 'rust-mode major-mode)
;; (lsp-format-buffer))))
;; load the language-server-protocol (lsp)
;; (use-package lsp-mode
;; :init
;; (add-hook 'prog-mode-hook 'lsp-mode)
;; :after rustic)
;; ;; :config
;; ;; (use-package lsp-flycheck
;; ;; :ensure f ; comes with lsp-mode
;; ;; :after rustic))
;; (push 'rustic-clippy flycheck-checkers)
;; Turn off flycheck.
;; (remove-hook 'rustic-mode-hook 'flycheck-mode)
;; ;; load rust-mode
;; (use-package rust-mode
;; :mode "\\.rs\\'"
;; :init
;; (setq rust-format-on-save t))
;; ;; bind the lsp-rust mode
;; (use-package lsp-rust
;; :after lsp-mode)
;; option: bind commands to keys:
;; - lsp-rust-analyzer-join-lines
;; - lsp-extend-selection
;; - lsp-rust-analyzer-expand-macro
;; (autoload 'rust-mode "rust-mode"
;; "Major mode for the rust programming language" t)
;; (add-hook 'rust-mode-hook #'racer-mode)
;; (add-hook 'racer-mode-hook #'eldoc-mode)
;; (add-hook 'racer-mode-hook #'company-mode)
;; (add-hook 'rust-mode-hook 'cargo-minor-mode)
;; (add-hook 'flycheck-mode #'flycheck-rust)
;; (add-hook 'flycheck-mode-hook #'flycheck-rust-setup)
;; ;; reccommended: use spaces instead of tabs
;; (add-hook 'rust-mode-hook
;; (lambda () (setq indent-tabs-mode nil)))
;; ;; on save, run rustfmt if installed (C-c C-f)
;; (setq rust-format-on-save t)
(provide '401-rust)
;;; 401-rust.el ends here

View File

@@ -0,0 +1,10 @@
;;
;; support ansi colour shemes
;;
(require 'ansi-color)
(defun colorize-compilation-buffer ()
(toggle-read-only)
(ansi-color-apply-on-region compilation-filter-start (point))
(toggle-read-only))
(add-hook 'compilation-filter-hook 'colorize-compilation-buffer)

View File

@@ -0,0 +1,26 @@
;;; 400-boxquote.el --- showing an inline arguments hints
;;; Commentary:
;; provides a set of functions for using a text quoting style that partially boxes
;; in the left hand side of an area of text.
;; such a marking style might be used to show externally included text or example code
;;; Code:
(require 'boxquote)
(global-set-key (kbd "C-c b y") 'boxquote-yank)
(global-set-key (kbd "C-c b r") 'boxquote-region)
(global-set-key (kbd "C-c b u") 'boxquote-unbox-region)
(global-set-key (kbd "C-c b t") 'boxquote-title)
(global-set-key (kbd "C-c b i") 'boxquote-insert-file)
(global-set-key (kbd "C-c b k") 'boxquote-kill)
(global-set-key (kbd "C-c b s") 'boxquote-shell-command)
(global-set-key (kbd "C-c b b") 'boxquote-buffer)
(global-set-key (kbd "C-c b p") 'boxquote-paragraph)
(global-set-key (kbd "C-c b n") 'boxquote-narrow-to-boxquote)
(global-set-key (kbd "C-c b w") 'boxquote-where-is)
(global-set-key (kbd "C-c b d f") 'boxquote-describe-function)
(global-set-key (kbd "C-c b d k") 'boxquote-describe-key)
(global-set-key (kbd "C-c b d v") 'boxquote-describe-variable)

68
site-start.d/501-git.el Normal file
View File

@@ -0,0 +1,68 @@
;;; 501-git.el --- git user adaptions
;;; Commentary:
;;; Code:
;; loading standard git.el
;;(require 'git)
;; load magit for git handling
(use-package magit
:ensure t
:bind (("C-x g" . magit-status)
("C-c g" . magit-status)
:map magit-status-mode-map
("TAB" . magit-section-toggle)
("<C-tab>" . magit-section-cycle)
:map magit-branch-section-map
("RET" . magit-checkout))
:config
(add-hook 'after-save-hook 'magit-after-save-refresh-status)
(setq magit-use-overlays nil
magit-section-visibility-indicator nil
magit-completing-read-function 'ivy-completing-read
magit-push-always-verify nil
magit-repository-directories '("~/src/"))
(use-package git-timemachine
:bind (("C-x v t" . git-timemachine)))
(use-package git-link
:bind (("C-x v L" . git-link))
:init
(setq git-link-open-in-browser t))
(use-package pcmpl-git)
(defun visit-pull-request-url ()
"Visit the current branch's PR on Github."
(interactive)
(browse-url
(format "https://github.com/%s/pull/new/%s"
(replace-regexp-in-string
"\\`.+github\\.com:\\(.+\\)\\.git\\'" "\\1"
(magit-get "remote"
(magit-get-remote)
"url"))
(cdr (magit-get-remote-branch)))))
(bind-key "v" 'visit-pull-request-url magit-mode-map)
;; Do Not Show Recent Commits in status window
;; https://github.com/magit/magit/issues/3230#issuecomment-339900039
(magit-add-section-hook 'magit-status-sections-hook
'magit-insert-unpushed-to-upstream
'magit-insert-unpushed-to-upstream-or-recent
'replace))
;; load forge to handle github, gitlab, etc
;;(require 'forge)
(use-package forge
:after magit)
(defvar my/magit-default-options
`(
(pulling "--rebase")
))
;;(advice-add 'magit-key-mode :filter-args #'magit-key-mode--add-default-options)
(provide '501-git)
;;; 501-git.el ends here

View File

@@ -0,0 +1,13 @@
;;; 500-meson-mode.el --- meson build system
;;; Commentary:
; GNU Emacs major mode to support meson build system
;;; Code:
(autoload 'meson-mode "meson-mode"
"Major mode for the Meson build system files" t)
(add-hook 'meson-mode-hook 'company-mode)
;;; 500-meson-mode.el ends here