;; init.el --- Summary: Emacs ;;; Commentary: ;;; First Emacs install date: 04/30/2019 ;;; To install config ;;; list-package RET package-install use-package RET ;;; To update packages: ;;; M-x list-packages U-x ;;; Code: (require 'package) (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/")) (setq package-enable-at-startup nil) (package-initialize) ;; (set-face-attribute 'default nil :height 130) ;; sets global font size ;; Setup use-package ;; https://github.com/jwiegley/use-package (eval-when-compile (require 'use-package)) ;; Always download packages that are not found (setq use-package-always-ensure t) ;; Sync emacs path and shell path (use-package exec-path-from-shell :config (when (memq window-system '(mac ns x)) (exec-path-from-shell-initialize))) ;; Setup helm (use-package helm :config (require 'helm-config) (helm-mode 1) (helm-autoresize-mode t) (setq helm-buffer-max-length nil)) ;; Setup magit (use-package magit) ;; Setup evil leader (use-package evil-leader :init (setq evil-want-keybinding nil) :config (global-evil-leader-mode) (evil-leader/set-leader "SPC") (evil-leader/set-key "RET" 'eshell "x" 'helm-M-x "b" 'helm-mini ;; In helm mini, use C-SPC to select buffers, M-D to kill all marked "d" (lambda() (interactive) (load-theme 'spacemacs-dark)) "l" (lambda() (interactive) (load-theme 'spacemacs-light)) "f" 'helm-find-files "s" 'rg-project "n" 'linum-mode "hk" 'describe-key "hf" 'describe-function "j" 'other-window "vn" 'narrow-to-region "vw" 'widen "o" 'delete-other-windows "g" 'magit-status ";" 'comment-line "k" (lambda() (interactive) (kill-buffer nil)) "r" (lambda() (interactive) (load-file "~/.emacs.d/init.el")) "e" (lambda() (interactive) (find-file "~/.emacs.d/init.el")) ;; C-i is tab "C-i" (lambda() (interactive) (switch-to-buffer nil)))) ;; Setup evil (use-package evil :ensure t :config (evil-mode 1)) (use-package evil-collection :after evil :ensure t :config (evil-collection-init)) ;; Setup theme and powerline (use-package spacemacs-theme :defer t :init (load-theme 'spacemacs-light t)) (use-package spaceline :config (require `spaceline-config) (spaceline-emacs-theme)) (use-package lsp-mode :init ;; (setq lsp-keymap-prefix "C-c l") (setq lsp-lens-enable nil) (setq lsp-enable-snippet nil) :hook (;; replace XXX-mode with concrete major-mode(e. g. python-mode) (go-mode . lsp)) :commands lsp) (use-package dockerfile-mode) ;; Setup elixir support (use-package elixir-mode) (use-package alchemist) (add-hook 'elixir-mode-hook (lambda () (local-set-key (kbd "C-c C-c") 'elixir-format))) ;; (use-package lsp-mode ;; :commands lsp ;; :ensure t ;; :diminish lsp-mode ;; :hook ;; (elixir-mode . lsp) ;; :init ;; (add-to-list 'exec-path "/Users/nicolasknoebber/package/elixir-ls/release")) ;; Setup golang support (use-package go-mode) (add-hook 'go-mode-hook (lambda () (local-set-key (kbd "C-c C-c") 'gofmt))) ;; Setup webmode (use-package web-mode :mode "\\.[tj]sx?\\'" "\\.html\\'" "\\.php\\'" "\\.tmpl\\'" "\\.erb\\'" "\\.h?eex\\'" :init (defun my-web-mode-hook () ;; Hooks for Web mode (setq-default indent-tabs-mode nil) (setq web-mode-markup-indent-offset 2) (setq web-mode-code-indent-offset 2) (setq web-mode-enable-auto-quoting nil)) (add-hook 'web-mode-hook 'my-web-mode-hook)) (setq web-mode-engines-alist '(("elixir" . "\\.heex\\'"))) (setq web-mode-engines-alist '(("elixir" . "\\.ex\\'"))) (use-package polymode :ensure t :mode ("\\.ex\\'" . poly-elixir-web-mode) :init (setq web-mode-engines-alist '(("elixir" . "\\.ex\\'"))) :config (define-hostmode poly-elixir-hostmode :mode 'elixir-mode) (define-innermode poly-surface-expr-elixir-innermode :mode 'web-mode :head-matcher (rx line-start (* space) "~H" (= 3 (char "\"'")) line-end) :tail-matcher (rx line-start (* space) (= 3 (char "\"'")) line-end) :head-mode 'host :tail-mode 'host :allow-nested nil :keep-in-mode 'host :fallback-mode 'host) (define-polymode poly-elixir-web-mode :hostmode 'poly-elixir-hostmode :innermodes '(poly-surface-expr-elixir-innermode))) ;; Setup linting with flycheck ;; Use 'C-c ! v' to check flycheck status in buffer. (use-package flycheck :init (add-hook 'prog-mode-hook 'global-flycheck-mode) :config (flycheck-add-mode 'javascript-eslint 'web-mode)) ;; Setup auto completion (use-package company :init (global-company-mode) :config (setq company-idle-delay 0) (setq company-minimum-prefix-length 1)) (use-package rg) (use-package htmlize) (add-hook 'org-mode-hook 'my-org-mode-hook) (defun my-org-mode-hook() (flyspell-mode 1) (auto-fill-mode 1)) ;;; General config (show-paren-mode 1) (menu-bar-mode -1) (tool-bar-mode -1) (toggle-scroll-bar -1) (setq ediff-split-window-function 'split-window-horizontally) ;; Flash the modeline instead of ringing. (setq visible-bell nil ring-bell-function 'flash-mode-line) (setq user-full-name "Nicolas Knoebber") (defun flash-mode-line () (invert-face 'mode-line) (run-with-timer 0.1 nil #'invert-face 'mode-line)) ;;; Enable banned commands (put 'narrow-to-defun 'disabled nil) (put 'narrow-to-page 'disabled nil) (put 'narrow-to-region 'disabled nil) ;;; Don't save backup~ files in the same directory. (setq backup-directory-alist `(("." . "~/.emacs.d/backups"))) ;;; Custom functions (defun export-nicolasknoebber () "Build nicolasknoebber.com." (interactive) (load-file "~/projects/nicolasknoebber.com/src/site.el") (org-publish-all)) ;; (setq-default org-display-custom-times nil) ;; (setq org-time-stamp-custom-formats ;; '("<%m/%d/%Y>" . "<%m/%d/%Y>")) (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. '(custom-safe-themes '("bffa9739ce0752a37d9b1eee78fc00ba159748f50dc328af4be661484848e476" "fa2b58bb98b62c3b8cf3b6f02f058ef7827a8e497125de0254f56e373abee088" default)) '(helm-minibuffer-history-key "M-p") '(line-number-mode nil) '(package-selected-packages '(rg go-mode company elixir-mode helm-lsp lsp-mode evil-collection org-plus-contrib ox-rss orgit htmlize php-mode dockerfile-mode exec-path-from-shell spaceline spacemacs-theme use-package helm evil-visual-mark-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. )