; 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/lang/elixir/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 tramp-default-method "ssh") ;; (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. '(connection-local-criteria-alist '(((:application tramp :machine "localhost") tramp-connection-local-darwin-ps-profile) ((:application tramp :machine "Nicolass-Air") tramp-connection-local-darwin-ps-profile) ((:application tramp) tramp-connection-local-default-system-profile tramp-connection-local-default-shell-profile) ((:application eshell) eshell-connection-default-profile))) '(connection-local-profile-alist '((tramp-connection-local-darwin-ps-profile (tramp-process-attributes-ps-args "-acxww" "-o" "pid,uid,user,gid,comm=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" "-o" "state=abcde" "-o" "ppid,pgid,sess,tty,tpgid,minflt,majflt,time,pri,nice,vsz,rss,etime,pcpu,pmem,args") (tramp-process-attributes-ps-format (pid . number) (euid . number) (user . string) (egid . number) (comm . 52) (state . 5) (ppid . number) (pgrp . number) (sess . number) (ttname . string) (tpgid . number) (minflt . number) (majflt . number) (time . tramp-ps-time) (pri . number) (nice . number) (vsize . number) (rss . number) (etime . tramp-ps-time) (pcpu . number) (pmem . number) (args))) (tramp-connection-local-busybox-ps-profile (tramp-process-attributes-ps-args "-o" "pid,user,group,comm=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" "-o" "stat=abcde" "-o" "ppid,pgid,tty,time,nice,etime,args") (tramp-process-attributes-ps-format (pid . number) (user . string) (group . string) (comm . 52) (state . 5) (ppid . number) (pgrp . number) (ttname . string) (time . tramp-ps-time) (nice . number) (etime . tramp-ps-time) (args))) (tramp-connection-local-bsd-ps-profile (tramp-process-attributes-ps-args "-acxww" "-o" "pid,euid,user,egid,egroup,comm=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" "-o" "state,ppid,pgid,sid,tty,tpgid,minflt,majflt,time,pri,nice,vsz,rss,etimes,pcpu,pmem,args") (tramp-process-attributes-ps-format (pid . number) (euid . number) (user . string) (egid . number) (group . string) (comm . 52) (state . string) (ppid . number) (pgrp . number) (sess . number) (ttname . string) (tpgid . number) (minflt . number) (majflt . number) (time . tramp-ps-time) (pri . number) (nice . number) (vsize . number) (rss . number) (etime . number) (pcpu . number) (pmem . number) (args))) (tramp-connection-local-default-shell-profile (shell-file-name . "/bin/sh") (shell-command-switch . "-c")) (tramp-connection-local-default-system-profile (path-separator . ":") (null-device . "/dev/null")) (eshell-connection-default-profile (eshell-path-env-list)))) '(custom-safe-themes '("fa2b58bb98b62c3b8cf3b6f02f058ef7827a8e497125de0254f56e373abee088" "bffa9739ce0752a37d9b1eee78fc00ba159748f50dc328af4be661484848e476" default)) '(helm-minibuffer-history-key "M-p") '(package-selected-packages '(inf-elixir htmlize rg flycheck web-mode elixir-ts-mode dockerfile-mode spaceline spacemacs-theme evil-collection evil-leader magit helm exec-path-from-shell))) (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. )