; 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 (helm-mode 1) (helm-autoresize-mode t) (setq helm-buffer-max-length nil)) ;; Setup magit (use-package magit) ;; Setup leader keys (TODO: switch to general.el) (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 "j" 'other-window "o" 'delete-other-windows "g" 'magit-status "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" (lambda() (interactive) (switch-to-buffer nil))) ;; C-i is tab ) ;; 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 dockerfile-mode) (defun eglot-format-buffer-on-save () (add-hook 'before-save-hook #'eglot-format-buffer -10 t)) ;; https://github.com/casouri/tree-sitter-module (add-to-list 'treesit-extra-load-path (concat (getenv "HOME") "/package/tree-sitter-module/dist")) (use-package elixir-ts-mode :ensure t :config (add-hook 'elixir-ts-mode-hook #'eglot-format-buffer-on-save) ) (use-package inf-elixir) ;; :bind (("C-c i i" . 'inf-elixir) ;; ("C-c i p" . 'inf-elixir-project) ;; ("C-c i l" . 'inf-elixir-send-line) ;; ("C-c i r" . 'inf-elixir-send-region) ;; ("C-c i b" . 'inf-elixir-send-buffer) ;; ("C-c i R" . 'inf-elixir-reload-module))) (require 'eglot) (dolist (mode '(elixir-ts-mode heex-ts-mode)) (add-to-list 'eglot-server-programs `(,mode . ("/Users/nicolasknoebber/package/elixir-ls/language_server.sh")))) (add-hook 'elixir-ts-mode-hook 'eglot-ensure) (add-hook 'heex-ts-mode-hook 'eglot-ensure) (setq eldoc-echo-area-use-multiline-p 1) (setq js-indent-level 2) ;; Setup webmode ;; (use-package web-mode ;; :mode "\\.[tj]sx?\\'" "\\.html\\'" "\\.php\\'" "\\.tmpl\\'" "\\.erb\\'" ;; :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)) ;; Setup linting with flycheck ;; Use 'C-c ! v' to check flycheck status in buffer. (use-package flycheck) (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>"))