diff --git a/config.org b/config.org index a616832..2e011d7 100644 --- a/config.org +++ b/config.org @@ -143,7 +143,8 @@ Although org mode ships with Emacs, the latest version can be installed external To avoid problems executing source blocks out of the box. [[https://emacs.stackexchange.com/a/28604][Others have the same problem, too]]. The solution is to remove the .elc files form the package directory: -#+begin_src sh:var ORG_DIR=(let* ((org-v (cadr (split-string (org-version nil t) "@"))) (len (length org-v))) (substring org-v 1 (- len 2))) +#+begin_src sh: + var ORG_DIR=(let* ((org-v (cadr (split-string (org-version nil t) "@"))) (len (length org-v))) (substring org-v 1 (- len 2))) rm ${ORG_DIR}/*.elc #+end_src @@ -174,6 +175,7 @@ For a more detailed example [[https://github.com/sachac/.emacs.d/blob/83d21e4733 (setq org-default-notes-file "~/Archiv/Dokumente/Notizen/notes.org") #+end_src + ** Org Setup Speed commands are a nice and quick way to perform certain actions while at the beginning of a heading. It's not activated by default. @@ -185,6 +187,7 @@ See the doc for speed keys by checking out the documentation for speed keys in O (setq org-highlight-latex-and-related '(latex script entities)) #+end_src + ** Org tags The default value is -77, which is weird for smaller width windows. I'd rather have the tags align horizontally with the header. 45 is a good column number to do that. @@ -193,11 +196,12 @@ The default value is -77, which is weird for smaller width windows. I'd rather h (setq org-tags-column 45) #+end_src + ** Org babel languages #+begin_src emacs-lisp (org-babel-do-load-languages - 'org-babel-load-languages +'org-babel-load-languages '((python . t) (C . t) (calc . t) @@ -220,6 +224,7 @@ The default value is -77, which is weird for smaller width windows. I'd rather h (setq org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate) #+end_src + ** Org babel/source blocks I like to have source blocks properly syntax highlighted and with the editing popup window staying within the same window so all the windows don't jump around. Also, having the top and bottom trailing lines in the block is a waste of space, so we can remove them @@ -251,3 +256,190 @@ Info in Emacs: M-x customize-group which-key ) #+end_src + +* ivy / counsel / swiper + +Ivy displays a window with suggestions for hotkeys and M-x + +#+begin_src emacs-lisp + (use-package ivy + :ensure t + :diminish + (ivy-mode . "") ;; does not display ivy in the mode line + :init + (ivy-mode 1) + :bind + ("C-c C-r" . ivy-resume) + :config + (setq ivy-use-virtual-buffers t) ;; recent files and bookmarks in ivy-switch-buffer + (setq ivy-height 20) ;; height of ivy window + (setq ivy-count-format "%d/%d") ;; current and total number + ) +#+end_src + +Counsel replaces: +- M-x +- C-x C-f find-file +- C-c h f describe-function +- C-c h v describe-variable +- M-i imenu + +The find-file replacement is nicer to navigate + +#+begin_src emacs-lisp + (use-package counsel + :ensure t + :bind* ;; load counsel when pressed + (("M-x" . counsel-M-x) + ("C-x C-f" . counsel-find-file) + ("C-c h f" . counsel-describe-function) + ("C-c h v" . counsel-describe-variable) + ("M-i" . counsel-imenu) + ) + ) +#+end_src + +Swiper ivy-enhances isearch + +#+begin_src emacs-lisp + (use-package swiper + :ensure t + :bind + (("C-s" . swiper) + ("C-c C-r" . ivy-resume) + ) + ) +#+end_src + + +* Programming +** Common things +List of plugins and settings which are shared between the language plugins + +*** Company Mode +Complete Anything! + +Activate company and make it react nearly instantly + +#+begin_src emacs-lisp + (use-package company + :ensure t + :config + (add-to-list 'company-backends 'company-elisp) + (setq company-minimum-prefix-length 2 + company-tooltip-align-annotation t + company-tooltop-flip-when-above t + company-show-numbers t) + (setq company-idle-delay 0.1) + (add-hook 'after-init-hook 'global-company-mode) +;; (global-company-mode t) + ) +#+end_src + +Addon to sort suggestions by usage + +#+begin_src emacs-lisp + (use-package company-statistics + :ensure t + :config + (company-statistics-mode 1) + ) +#+end_src + +Get a popup with documentation of the completion candidate. +I have to test if it even works. + +#+begin_src emacs-lisp + (use-package company-quickhelp + :ensure t + :config + (company-quickhelp-mode 1) + ) +#+end_src + +Maybe add [[https://github.com/hlissner/emacs-company-dict][company-dict]]? It's a dictionary based on major modes, plus it has Yasnippet integration. + + +** Python + +Systemwide following packages need to be installed: +- virtualenv + +The virtual environments need to have following modules installed: +- jedi +- epc +- flake8 + +Automatically start python-mode when opening a .py-file. +Not sure if python.el is better than python-mode.el. +See [[https://github.com/jorgenschaefer/elpy/issues/887][here]] for info about ~python-shell-completion-native-enable~. +The custom function is to run inferiour processes (do I really need that?), see [[https://emacs.stackexchange.com/questions/16361/how-to-automatically-run-inferior-process-when-loading-major-mode][here]]. + +#+begin_src emacs-lisp + (use-package python + :mode ("\\.py\\'" . python-mode) + :interpreter ("python" . python-mode) + :config + (setq python-shell-completion-native-enable nil) +;; (defun my/run-python () +;; (save-selected-window +;; (switch-to-buffer-other-window (process-buffer (python-shell-get-or-create-process (python-shell-parse-command))))) +;; ) +;; (add-hook 'python-mode-hook 'my/run-python) + ) +#+end_src + +~TEST~ ELPY + +begin_src emacs-lisp + (use-package elpy + :ensure t +;; :pin elpy + :config + (elpy-enable) + (add-hook 'python-mode-hook 'elpy-mode) + (setq elpy-rpc-backend "jedi") + (pyvenv-mode 1) + ) +end_src + +Jedi is a backend for python autocompletion and needs to be installed on the server: +- pip install jedi +Code checks need to be installed, too: +- pip install flake8 + +#+begin_src emacs-lisp + (use-package company-jedi + :defer t + :ensure t + :config + (setq jedi:environment-virtualenv (list (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/"))) + (add-hook 'python-mode-hook 'jedi:setup) + (setq jedi:complete-on-dot t) + (setq jedi:use-shortcuts t) + (defun my/python-mode-hook() + (add-to-list 'company-backends 'company-jedi)) + (add-hook 'python-mode-hook 'my/python-mode-hook) + ) +#+end_src + +A wrapper to handle virtual environments. +I strongly recommend to install virtual environments on the terminal, not through this wrapper, but changing venvs is fine. + +#+begin_src emacs-lisp + (use-package virtualenvwrapper + :ensure t + :init + (venv-initialize-interactive-shells) + (venv-initialize-eshell) + (setq venv-location "~/Archiv/Programmierprojekte/Python/virtualenv") + (setq python-environment-directory venv-location) + (add-hook 'venv-postmkvirtualenv-hook + (lambda () (shell-command "pip install epc jedi"))) + (add-hook 'venv-postactivate-hook 'jedi:stop-server) + (add-hook 'venv-postdeactivate-hook 'jedi:stop-server) + ) +#+end_src + + + diff --git a/init.el b/init.el index 01212c0..0114386 100644 --- a/init.el +++ b/init.el @@ -1,49 +1,50 @@ -;;; init --- Summary -;;; Commentary: +;; Garbage collection threshold +;; higher means less interuptions +(setq gc-cons-threshold 400000000) -;;; Code: + +;; Begin initialization +;; Turn off mouse interface early in startup to avoid momentary display +(when window-system + (menu-bar-mode -1) + (tool-bar-mode -1) + (scroll-bar-mode -1) + (tooltip-mode -1) +) + +(setq inhibit-startup-message t) +(setq initial-scratch-message "") + +;; Setup package +(require 'package) +(add-to-list 'package-archives + '("melpa" . "http://melpa.org/packages/") t) +(add-to-list 'package-archives + '("org" . "http://orgmode.org/elpa/") t) +(when (boundp 'package-pinned-packages) + (setq package-pinned-packages + '((org-plus-contrib . "org")) + ) +) (package-initialize) -(setq shell-file-name "/bin/bash") ;;test für python und jedi -(setq debug-on-error t) ;; Debug-Meldung, wenn Fehler durch init.el auftritt - -(add-to-list 'load-path (concat user-emacs-directory "elisp/")) - -(require 'base) -(require 'base-theme) -(require 'base-backup) -(require 'base-functions) -(require 'base-global-keys) - -;(require 'plugin-evil) ; vi-mode für emacs -(require 'plugin-which-key) -(require 'plugin-counsel) -(require 'plugin-org) -(require 'plugin-company-mode) -(require 'plugin-flycheck) ; Syntaxcheck -(require 'plugin-smartparens) -(require 'plugin-yasnippet) -;(require 'plugin-neotree) -(require 'plugin-projectile) -(require 'plugin-treemacs) ;nach projectile, da treemacs auch treemacs-projectile lädt -(require 'plugin-spaceline) -(require 'plugin-markdown) -(require 'plugin-magit) -(require 'lang-python) -(require 'lang-latex) - -;;; init ends here -(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 - (pdf-tools yasnippet which-key use-package tablist smartparens projectile org-journal neotree material-theme magit flycheck counsel company-statistics company-quickhelp company-jedi company-dict auto-virtualenvwrapper)))) -(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. - ) + +;; Bootstrap use-package +;; Install use-package if it's not already installed +;; use-package is used to configure the rest of the packages +(unless (package-installed-p 'use-package) + (package-refresh-contents) + (package-install 'use-package) +) + +;; From use-package README +(eval-when-compile + (require 'use-package)) +(require 'diminish) +;;use-package needs this +(require 'bind-key) + +;; Load the config +(org-babel-load-file (concat user-emacs-directory "config.org")) + +(setq gc-cons-threshold 800000)