summary refs log blame commit diff stats
path: root/init.el
blob: 6688c738e4a5fa154787b7ac4b7bdc4310857962 (plain) (tree)
1
2
3
4
5
6
7
8
9




                               

                                          
                                         
                                                  











                                                                        



                                                         

                                                                                        







                                                   
                                                










                                                                                             


                                                  





                                
                    



































                                                                                                       
                                                                                                                    
 





                                                 
                                             





























                                                            

                                                       





































                                                                                           
                             

                                                     





























                                                                                    
                                                      


                           











                                                                                                                                              








                                                                              

























                                                          
                      




































                                                                                                                                  
                                                                   


                                                        

                                                                              



                                      

                                     

                                                          



                                             


                                    


                                          
 

                                  




                                  






                                



                                                       




                                   

                                      


                                  
                                                      


                                             


                                   


                                





                                                  

                                                             
 











                                                                           

 








                                                         


               
 
                     
;;; init.el --- an emacs config
;;; Commentary:
;; config file for eli_oat
;;; Code:
;; load filepath
(add-to-list 'load-path "~/.emacs.d/lisp")

(defun ooo/create-if-not-exist (filename)
  "Create a FILENAME if it doesn't already exist."
  (interactive)
  (if (not(file-exists-p filename))
      (with-temp-file filename
        (insert ""))))

;; Prevent emacs from adding stuff to init.el
;; Instead, add that stuff to custom.el
(ooo/create-if-not-exist "~/.emacs.d/lisp/custom.el")
(setq custom-file
    (expand-file-name "~/.emacs.d/lisp/custom.el" user-emacs-directory))
(load custom-file)

;; Who am I -- probably modify this bit if you aren't me.
(setq user-full-name "Eli Mellen"
      user-mail-address "hi@eli.li")

;; I find automated backups to be wicked useful. I allow emacs to make many of them,
;; and to make them often. This said, I don't like them muddying my project directories,
;; so I have them dumped into a common folder.
(setq backup-directory-alist `(("." . "~/.saves")))
(setq backup-by-copying t) ;; SLOW but very safe
(setq delete-old-versions t
    kept-new-versions 6
    kept-old-versions 2
    version-control t)

;; Likewise, history can be a valuable resource.
;; See, https://www.wisdomandwonder.com/wp-content/uploads/2014/03/C3F.html for more on this.
(setq savehist-file "~/.emacs.d/savehist")
(savehist-mode 1)
(setq history-length t)
(setq history-delete-duplicates t)
(setq savehist-save-minibuffer-history 1)
(setq savehist-additional-variables
      '(kill-ring
        search-ring
        regexp-search-ring))

;; Make the default scratch buffer an org-mode one
(setq initial-major-mode 'org-mode)

;; UI stuffs
(setq frame-title-format '("%b")
      ring-bell-function 'ignore
      default-directory "~/")

(tool-bar-mode   -1)
(menu-bar-mode   +1)
(scroll-bar-mode -1)
(window-divider-mode 1) ; allows you to resize windows by grabbing the divider
(global-visual-line-mode 1) ; line wrapping, because I spend a lot of time working on very tiny screens
(global-prettify-symbols-mode 1)
(column-number-mode +1)
(global-hl-line-mode 1) ; highlight the currently active line

;; Display line numbers, but only on Emacs26 or higher
(when (version<= "26.0.50" emacs-version )
  (global-display-line-numbers-mode))

;; Play nice(er) with the X11 clipboard
(setq select-enable-clipboard t)

;; No thank you to a welcome screen
(setq inhibit-startup-message t initial-scratch-message nil)

;; Automatically save and load changes
(global-auto-revert-mode +1)
(auto-save-visited-mode  +1)

;; Automatically insert buddies
(electric-pair-mode +1)

;; Highlight buddies (and do it right away)
(setq show-paren-delay 0)
(show-paren-mode 1)

;; Increase line space for better readability
(setq-default line-spacing 3)

(setq-default indent-tabs-mode nil
              tab-width 2)

;; ===== SIMPLE THEME =====

; (set-face-font 'default "Go Mono 14") ;; enable this, and disable the lower block if you don't want so much margin

(set-frame-parameter (selected-frame)
                     'internal-border-width 24)
(setq default-frame-alist
      (append (list '(width  . 72) '(height . 40)
                    '(vertical-scroll-bars . nil)
                    '(internal-border-width . 24)
                    '(font . "Go Mono 16"))))


;; Underline line at descent position, not baseline position
(setq x-underline-at-descent-line t)

;; No ugly button for checkboxes
(setq widget-image-enable nil)

;; Line cursor and no blink
(set-default 'cursor-type  '(bar . 1))
(blink-cursor-mode 1)

;; No sound
(setq visible-bell t)
(setq ring-bell-function 'ignore)

;; Fringe or bangs?
(fringe-mode '(0 . 0))
(defface fallback '((t :family "Go Mono"
                       :inherit 'face-faded)) "Fallback")
(set-display-table-slot standard-display-table 'truncation
                        (make-glyph-code ?… 'fallback))
(set-display-table-slot standard-display-table 'wrap
                        (make-glyph-code ?↩ 'fallback))

;; Vertical window divider
(setq window-divider-default-right-width 3)
(setq window-divider-default-places 'right-only)
(window-divider-mode)

(setq-default left-fringe-width 1 right-fringe-width 8
              left-margin-width 1 right-margin-width 0)

;; ===== PACKAGES =====

;; bootstrap straight.el
(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 6))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

;; go go gadget straight.el
(setq package-enable-at-startup nil)

;; make it pretend to be use-package
(straight-use-package 'use-package)

;; theme
(straight-use-package 'acme-theme)
(load-theme 'acme t)
;; this makes it so that emacs doesn't load a theme when launched in a terminal
(add-to-list 'default-frame-alist '(tty-color-mode  . -1))

;; whimsy
(straight-use-package 'rainbow-delimiters)
(add-hook 'prog-mode-hook #'rainbow-delimiters-mode)
(straight-use-package 'nyan-mode)
(add-hook 'prog-mode-hook #'nyan-mode)
(straight-use-package 'emojify)
(add-hook 'after-init-hook #'global-emojify-mode)

;; git
(straight-use-package 'magit)
; (straight-use-package 'git-gutter)
; (add-hook 'prog-mode-hook #'global-git-gutter-mode)

;; keep splits good sizes
(straight-use-package 'golden-ratio)
(golden-ratio-mode 1)

;; ergonomic stuff for easy cheating and nicer mode-line
(straight-use-package 'helm)
(setq helm-M-x-fuzzy-match t
    helm-mode-fuzzy-match t
    helm-buffers-fuzzy-matching t
    helm-recentf-fuzzy-match t
    helm-locate-fuzzy-match t
    helm-semantic-fuzzy-match t
    helm-imenu-fuzzy-match t
    helm-completion-in-region-fuzzy-match t
    helm-candidate-number-list 150
    helm-split-window-in-side-p t
    helm-move-to-line-cycle-in-source t
    helm-echo-input-in-header-line t
    helm-autoresize-max-height 0
    helm-autoresize-min-height 20)
:config (helm-mode 1)
(global-set-key (kbd "M-x") 'helm-M-x) ; like spacemacs, but with M-x instead of SPC
(global-set-key (kbd "M-f") 'helm-find-files)

(straight-use-package 'which-key)
(setq which-key-separator " ")
(setq which-key-prefix-prefix "+")

(straight-use-package 'company)
(setq company-dabbrev-downcase 0 company-idle-delay 0)
(progn (company-mode +1)
  (global-company-mode +1))

;; ===== org-mode =====

(straight-use-package 'org)
(setq org-todo-keywords
      '((sequence "TODO(t)" "|" "DONE(d)") ;; basic boolean todo lists
        (sequence "BACKLOG" "NEXT" "DOING" "FOLLOW-UP" "BLOCKED" "|" "DONE" "DELEGATED"))) ;; fancy-pants kanban style, multi-state todo lists
      (setq org-tag-alist '(("@work" . ?w) ("@home" . ?h) ("hobby" . ?h) ("client" . ?c))) ;; not in use, but one day...
      (setq org-fontify-done-headline t)
      (custom-set-faces
      '(org-done ((t (:foreground "#5DA7AA" :weight normal :strike-through t))))
      '(org-headline-done
            ((((class color) (min-colors 16) (background light))
              (:foreground "#5E81AC" :strike-through t)))))

(setq org-capture-templates
      '(("t" "todo" entry (file+headline "~/Dropbox/Eli/org/todo.org" "Tasks")
         "* TODO %?\n  %i\n  %a")
        ("s" "scratch" entry (file+datetree "~/Dropbox/Eli/org/scratch.org")
         "* %?\nEntered on %U\n  %i\n  %a")
        ("i" "inbox" entry (file+datetree "~/Dropbox/Eli/org/inbox.org")
         "* %?\nEntered on %U\n %i\n %a")))

(straight-use-package 'org-bullets)
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))

;; Export org files in various formats
(straight-use-package 'htmlize)
(straight-use-package 'ox-pandoc)

(straight-use-package 'restclient)

(straight-use-package 'ob-restclient)
(org-babel-do-load-languages
 'org-babel-load-languages
 '((restclient . t)))

;; ORG BABEL
(org-babel-do-load-languages
 'org-babel-load-languages
 '((shell . t)
   (emacs-lisp . t)
   (forth . t)
   (C . t)
   (sqlite . t)
   (restclient . t)))

(defun org-babel-tangle-block()
  "Tangle 'dem block."
  (interactive)
  (let ((current-prefix-arg '(4)))
     (call-interactively 'org-babel-tangle)))

(eval-after-load "org"
  '(progn
     (define-key org-mode-map (kbd "C-c b") 'org-babel-tangle-block)))

(eval-after-load 'org
      (lambda()
        (require 'ob-emacs-lisp)
        (require 'ob-sql)
        (require 'ob-shell)
        (require 'ob-sqlite)
        (require 'ob-org)
        (require 'ob-css)
        (require 'ob-C)
        (require 'ob-forth)
        (require 'ob-lisp)
        (setq org-export-babel-evaluate nil)
        (setq org-startup-indented t)
        ;; increase imenu depth to include third level headings
        (setq org-imenu-depth 3)
        ;; Update images from babel code blocks automatically
        (add-hook 'org-babel-after-execute-hook 'org-display-inline-images)
        (setq org-src-fontify-natively t)
        (setq org-src-tab-acts-natively t)
        (setq org-confirm-babel-evaluate nil)))

;; ===== LANGUAGES =====

;; Common Lisp support
(straight-use-package 'sly)
(setq inferior-lisp-program "/opt/homebrew/bin/sbcl --noinform") ;; this is the bit that changes from machine to machine, usually.

;; Scheme support for chicken, chibi and racket (brev too!)...and guile
(straight-use-package 'geiser)
(setq geiser-racket-binary "/Applications/Racket\ v8.9/bin/racket")
(setq geiser-chicken-binary "/opt/homebrew/bin/csi")
(setq geiser-chibi-binary "/usr/local/bin/chibi-scheme")
(setq geiser-guile-binary "/opt/homebrew/bin/guile")
(setq geiser-active-implementations '(chibi chicken racket guile kawa gauche))
(setq geiser-repl-history-filename "~/.saves/geiser")
(straight-use-package 'geiser-chibi)
(straight-use-package 'geiser-chicken)
(straight-use-package 'geiser-racket)
(straight-use-package 'geiser-guile)
(straight-use-package 'geiser-kawa)
(straight-use-package 'geiser-gauche)
(add-to-list 'auto-mode-alist '("\\.brev$" . scheme-mode))

;; ELISP
;; use eldoc with elisp
(add-hook 'emacs-lisp-mode-hook #'eldoc-mode)

;; CLOJURE
(straight-use-package 'clojure-mode)
(straight-use-package 'cider)
(add-hook 'clojure-mode-hook #'cider-mode)
;; NOTE:
;; bb --nrepl-server

;; JANET
(straight-use-package 'janet-mode)
(straight-use-package
 '(ijanet
   :type git
   :host github
   :repo "serialdev/ijanet-mode"))

;; GO
(straight-use-package 'go-mode)

;; LUA
(straight-use-package 'lua-mode)

;; JAVASCRIPT
(straight-use-package 'js2-mode)
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))

;; FENNEL
(straight-use-package 'fennel-mode)

;; RACKET
(straight-use-package 'racket-mode)
(straight-use-package 'pollen-mode)
(straight-use-package 'company-pollen)

;; FORTH
(autoload 'forth-mode "gforth.el")
(setq auto-mode-alist (cons '("\\.fs\\'" . forth-mode)
			    auto-mode-alist))
(autoload 'forth-block-mode "gforth.el")

;; UXNTAL
(straight-use-package 'uxntal-mode)

;; BQN
(straight-use-package 'bqn-mode)

;; FLYCHECK
(straight-use-package 'flycheck)
(global-flycheck-mode)
(straight-use-package 'exec-path-from-shell)
(exec-path-from-shell-initialize)
(add-hook 'after-init-hook #'global-flycheck-mode)
(setq-default flycheck-indication-mode 'left-margin)
(add-hook 'flycheck-mode-hook #'flycheck-set-indication-mode)

;; FLYSPELL
(dolist (hook '(text-mode-hook))
  (add-hook hook (lambda () (flyspell-mode 1))))

(dolist (hook '(change-log-mode-hook log-edit-mode-hook))
  (add-hook hook (lambda () (flyspell-mode -1))))

(eval-after-load "flyspell"
  '(progn
     (define-key flyspell-mouse-map [down-mouse-3] #'flyspell-correct-word)
     (define-key flyspell-mouse-map [mouse-3] #'undefined)))



;; Instruct emacs to check for personal-pizza.el
;; This file is used for one-off overrides and any
;; tweaks that need to be made to init.el rather than
;; editing the config directly. Should be loaded last,
;; or at least after straight has been bootstrapped and
;; loaded some other stuff.
(when (file-exists-p "~/.emacs.d/lisp/personal-pizza.el")
  (load "~/.emacs.d/lisp/personal-pizza.el"))



(provide 'init)

;;; init.el ends here