Skip to content

Instantly share code, notes, and snippets.

Last active April 20, 2024 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hacknightly/ba0d0fea0ebbfb07c42ea991ba62f200 to your computer and use it in GitHub Desktop.
Save hacknightly/ba0d0fea0ebbfb07c42ea991ba62f200 to your computer and use it in GitHub Desktop.
;; emacs housekeeping
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(global-auto-revert-mode 1)
(setq warning-minimum-level :emergency)
;; pixel scroll
(setq pixel-scroll-precision-mode 1)
;; don't create lock files
(setq create-lockfiles nil)
; delete excess backup versions silently
(setq delete-old-versions -1)
; use version control
(setq version-control t)
; make backups file even when in version controlled dir
(setq vc-make-backup-files t)
; which directory to put backups file
(setq backup-directory-alist `(("." . "~/.emacs.d/backups")))
; don't ask for confirmation when opening symlinked file
(setq vc-follow-symlinks t)
; transform backups file name
(setq auto-save-file-name-transforms '((".*" "~/.emacs.d/auto-save-list/" t)))
; inhibit useless and old-school startup screen
(setq inhibit-startup-screen t)
; silent bell when you make a mistake
(setq ring-bell-function 'ignore)
; use utf-8 by default
(setq coding-system-for-read 'utf-8)
(setq coding-system-for-write 'utf-8)
; sentence SHOULD end with only a point.
(setq sentence-end-double-space nil)
; toggle wrapping text at the 80th character
(setq default-fill-column 80)
; Open to inbox file
(defun goto-inbox-file ()
"Open the inbox file."
(find-file "~/Dropbox/"))
;; package management
(require 'package)
(setq package-enable-at-startup nil)
(setq package-archives '(("org" . "")
("gnu" . "")
("melpa" . "")))
;; path management
(use-package exec-path-from-shell
:ensure t)
(when (memq window-system '(mac ns x))
;; dashboard
;; use-package with package.el:
(use-package dashboard
:ensure t
;; shell / vterm
(use-package vterm :ensure t
(setq vterm-shell "zsh"))
(use-package multi-vterm :ensure t)
(defun goto-init-file ()
"Open the init file."
(find-file user-init-file))
;; magit
(use-package magit :ensure t)
;; org-mode
(use-package org-remark
:ensure t
(setq org-pomodoro-length 40
org-pomodoro-short-break-length 8
org-pomodoro-long-break-length 30)
:hook (after-init . org-remark-global-tracking-mode))
(use-package org-pomodoro
:ensure t
:commands (org-pomodoro))
(use-package org-roam
:ensure t
(setq org-roam-directory "~/Dropbox/")
(setq org-link-file-path-type 'absolute)
(use-package org-roam-ui
:ensure t
(setq org-roam-ui-sync-theme t
org-roam-ui-follow t
org-roam-ui-update-on-save t
org-roam-ui-open-on-start t))
(define-skeleton babel-skeleton
"Header info for a emacs-org file."
"#+TITLE:" str " \n"
"#+AUTHOR: Darrell Banks\n"
"#+INFOJS_OPT: \n"
"#+BABEL: :session *js* :session *python* :cache yes :results output graphics :exports both :tangle yes \n"
'((shell . t)
(js . t)
(python . t)))
(use-package org
;; Basic Settings
org-startup-indented t
org-return-follows-link t
org-confirm-babel-evaluate nil
org-agenda-files '("~/Dropbox/")
org-outline-path-complete-in-steps nil
org-refile-use-outline-path nil
org-todo-keyword-faces '(("NOTE" . "#ffb951") ("ACHIEVEMENT" . "#32a852"))
org-todo-keywords '((sequence "TODO(t)" "PROGRESS(p)" "|" "DONE(d)" "NOTE(n)"))
org-refile-targets `((,(directory-files-recursively "~/Dropbox/" "^[a-z0-9]*.org$") :maxlevel . 1))
org-refile-use-outline-path 'file
;; Edit settings
org-auto-align-tags nil
org-tags-column 0
org-catch-invisible-edits 'show-and-error
org-special-ctrl-a/e t
org-insert-heading-respect-content t
;; Org styling, hide markup etc.
org-hide-emphasis-markers t
org-pretty-entities t
org-ellipsis "…"
;; Pomodoro Settings
org-pomodoro-start-sound "~/Dropbox/chime.wav"
org-pomodoro-finished-sound "~/Dropbox/chime.wav"
org-pomodoro-short-break-sound "~/Dropbox/chime.wav"
org-pomodoro-long-break-sound "~/Dropbox/chime.wav"
;; Templates
'(("t" "Todo" entry (file+datetree "~/Dropbox/")
"* TODO %^{Description} %^g
Added: %U")
("n" "Note" entry (file+datetree "~/Dropbox/")
"* NOTE %^{Description} %^g %?
Added: %U")
("a" "Achievement" entry (file+datetree "~/Dropbox/")
"* ACHIEVEMENT %^{Description} %^g %?
Added: %U")
;; Agenda styling
org-agenda-tags-column 0
org-agenda-block-separator ?─
'((daily today require-timed)
(800 1000 1200 1400 1600 1800 2000)
" ┄┄┄┄┄ " "┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄")
"◀── now ─────────────────────────────────────────────────"))
;; Hugo
(use-package ox-hugo
:ensure t)
(setq org-hugo-base-dir "~/Dropbox/"
time-stamp-active t
time-stamp-start "#\\+lastmod:[ \t]*"
time-stamp-end "$"
time-stamp-format "%04Y-%02m-%02d")
(add-hook 'before-save-hook 'time-stamp nil)
;; Visual settings
;; - org mode
(use-package org-modern :ensure t)
(with-eval-after-load 'org (global-org-modern-mode))
(with-eval-after-load 'org (auto-fill-mode))
;; - font
(set-face-attribute 'default nil :font "RobotoMono Nerd Font" :height 180)
;; - icons
(use-package all-the-icons :ensure t)
;; - company
(use-package company
:ensure t
(add-hook 'after-init-hook 'global-company-mode))
;; - modeline
(use-package lambda-line
:ensure nil
:load-path "~/ThirdParty/lambda-line"
(lambda-line-icon-time t) ;; requires ClockFace font (see below)
(lambda-line-clockface-update-fontset "ClockFaceRect") ;; set clock icon
(lambda-line-position 'bottom) ;; Set position of status-line
(lambda-line-abbrev t) ;; abbreviate major modes
(lambda-line-hspace " ") ;; add some cushion
(lambda-line-prefix t) ;; use a prefix symbol
(lambda-line-prefix-padding nil) ;; no extra space for prefix
(lambda-line-status-invert nil) ;; no invert colors
(lambda-line-gui-ro-symbol " ⨂") ;; symbols
(lambda-line-gui-mod-symbol " ⬤")
(lambda-line-gui-rw-symbol " ◯")
(lambda-line-space-top +.50) ;; padding on top and bottom of line
(lambda-line-space-bottom -.50)
(lambda-line-symbol-position 0.1) ;; adjust the vertical placement of symbol
;; activate lambda-line
;; set divider line in footer
(when (eq lambda-line-position 'top)
(setq-default mode-line-format (list "%_"))
(setq mode-line-format (list "%_"))))
;; - indents
(setq-default indent-tabs-mode nil)
(setq-default tab-width 2)
(setq indent-line-function 'insert-space)
;; - themes
(setq custom-safe-themes t)
(use-package ef-themes
:ensure t
(load-theme 'ef-cherie))
;; use-package
(unless (package-installed-p 'use-package) ; unless it is already installed
(package-refresh-contents) ; update packages archive
(package-install 'use-package)) ; and install the most recent version of use-package
;; projectile
(use-package projectile :ensure t
(setq projectile-globally-ignored-directories '("dist"))
(setq projectile-indexing-method 'hybrid))
;; Editing
;; - brackets
(electric-pair-mode 1)
;; copilot
(use-package s :ensure t)
(use-package dash :ensure t)
(use-package editorconfig :ensure t)
(add-to-list 'load-path (expand-file-name "~/ThirdParty/copilot.el"))
(require 'copilot)
(add-hook 'tsx-ts-mode-hook 'copilot-mode)
(add-hook 'typescript-ts-mode-hook 'copilot-mode)
(add-hook 'web-mode-hook 'copilot-mode)
(define-key copilot-completion-map (kbd "<backtab>") 'copilot-accept-completion)
(exec-path-from-shell-copy-env "OPENAI_API_KEY")
(use-package gptel :ensure t
(setq gptel-api-key (getenv "OPENAI_API_KEY"))
(gptel-make-ollama "Ollama"
:host "localhost:11434"
:stream t
:models '("llama2:latest")))
;; Languages
;; tree sitter
(setq treesit-extra-load-path '("~/ThirdParty/tree-sitter-module/dist"))
(add-to-list 'auto-mode-alist '("\\.css\\'" . css-ts-mode))
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-ts-mode))
(add-to-list 'auto-mode-alist '("\\.ts\\'" . typescript-ts-mode))
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . tsx-ts-mode))
(add-to-list 'auto-mode-alist '("\\.yml\\'" . yml-ts-mode))
;; PlantUML
(use-package plantuml-mode :ensure t
:mode (("\\.plantuml$" . plantuml-mode)))
(setq plantuml-executable-path "/opt/homebrew/bin/plantuml")
(setq plantuml-default-exec-mode 'executable)
;; Markdown
(use-package markdown-mode :ensure t)
;; - Eglot
(use-package eglot
(add-to-list 'eglot-server-programs
'(web-mode . ("svelteserver" "--stdio")))
(typescript-ts-mode . eglot-ensure)
(tsx-ts-mode . eglot-ensure)
(python-ts-mode . eglot-ensure)
(json-ts-mode . eglot-ensure)
(js-ts-mode . eglot-ensure)
(web-mode . eglot-ensure)
(erlang-mode . eglot-ensure)
(rust-mode . eglot-ensure))
;; - web
(use-package web-mode :ensure t
:mode (("\\.html$" . web-mode)
("\\.svelte$" . web-mode)))
(use-package emmet-mode :ensure t
(add-hook 'web-mode-hook 'emmet-mode))
;; rust
(use-package rust-mode :ensure t
:mode (("\\.rs$" . rust-mode)
;; - prettier
(use-package prettier-js :ensure t
(add-hook 'typescript-ts-mode-hook 'prettier-js-mode)
(add-hook 'tsx-ts-mode-hook 'prettier-js-mode)
(add-hook 'js-mode-hook 'prettier-js-mode)
(add-hook 'svelte-mode-hook 'prettier-js-mode)
(add-hook 'web-mode-hook 'prettier-js-mode))
;; flycheck
(use-package flycheck :ensure t)
;; treemacs
(use-package treemacs :ensure t)
(use-package treemacs-evil :ensure t)
(use-package treemacs-projectile :ensure t)
(use-package treemacs-all-the-icons :ensure t)
;; evil-mc
(use-package evil-mc
:ensure t
(global-evil-mc-mode 1))
;; ivy
(use-package ivy
:ensure t
(ivy-use-selectable-prompt t)
(ivy-count-format "(%d/%d) ")
(ivy-use-virtual-buffers t)
(use-package ivy-rich
:ensure t
:after ivy
(ivy-virtual-abbreviate 'full
ivy-rich-switch-buffer-align-virtual-buffer t
ivy-rich-path-style 'abbrev))
(use-package all-the-icons-ivy
:ensure t
:init (add-hook 'after-init-hook 'all-the-icons-ivy-setup))
(use-package counsel
:after ivy
:ensure t
(use-package counsel-projectile :ensure t)
;; movement
(use-package avy :ensure t)
(use-package wgrep :ensure t)
(use-package swiper :ensure t)
(use-package imenu-list :ensure t
(setq imenu-list-auto-resize t)
(setq imenu-list-focus-after-activation t))
;; Evil Mode
(use-package evil
:ensure t
(evil-set-undo-system 'undo-redo)
;; Key Bindings
(use-package which-key :ensure t
:init (which-key-mode))
(use-package general :ensure t
(general-evil-setup t)
;; web keys
:states '(insert)
:keymaps 'web-mode-map
"TAB" 'emmet-expand-line)
;; xref keys
:states '(normal)
:keymaps 'xref--xref-buffer-mode-map
"TAB" 'xref-goto-xref)
;; llm keys
:states '(normal visual)
:prefix ","
:keymaps 'markdown-mode-map
"RET" 'gptel-send)
;; org keys
:states '(normal visual)
:keymaps 'org-mode-map
"t" 'org-todo
"." 'org-time-stamp
"-" 'org-ctrl-c-minus
"+" 'org-ctrl-c-ctrl-c
"*" 'org-ctrl-c-star
"^" 'org-sort
"{" 'org-edit-src-code
"|" 'org-table-create-or-convert-from-region
"RET" 'org-open-at-point
"TAB" 'org-cycle)
:states '(normal)
:prefix ","
:keymaps 'org-mode-map
"<backtab>" 'org-promote-subtree
"," "C-c C-c"
"/" 'org-sparse-tree
"b" '(:ignore t :which-key "Babel")
"bi" 'org-insert-structure-template
"bx" 'org-babel-execute-src-block
"bh" 'org-babel-insert-header-arg
"bn" 'org-babel-next-src-block
"bp" 'org-babel-previous-src-block
"bs" 'babel-skeleton
"c" '(:ignore t :which-key "Clocks")
"ci" 'org-clock-in
"co" 'org-clock-out
"cs" 'org-schedule
"cd" 'org-deadline
"cp" 'org-pomodoro
"t" 'org-set-tags-command
"o" 'org-occur
"r" 'org-refile
"A" 'org-archive-subtree
"il" 'org-insert-link
"RET" 'org-meta-return
"TAB" 'org-demote-subtree
;; general keys
:states '(normal visual insert emacs treemacs)
:prefix "SPC"
:non-normal-prefix "C-SPC"
;; M-x
"SPC" '(counsel-M-x :which-key "M-x")
;; Applications
"a" '(:ignore t :which-key "Applications")
"ae" '(:ignore t :which-key "Eldoc")
"aed" '(eldoc-doc-buffer :which-key "Doc Buffer")
"ai" '(:ignore t :which-key "AI")
"ai>" '(gptel-send :which-key "Send Line")
"aig" '(gptel :which-key "GPT Buffer")
"aim" '(gptel-menu :which-key "GPT Menu")
"ao" '(:ignore t :which-key "Org")
"aoa" '(org-agenda :which-key "Agenda")
"aoc" '(org-capture :which-key "Capture")
"ao>" '(org-goto-calendar :which-key "Go To Calendar")
"aot" '(org-tags-view :which-key "Tags View")
"aop" '(org-pomodoro :which-key "Pomodoro")
"at" '(:ignore t :which-key "Treemacs")
"atd" '(treemacs-select-directory :which-key "Select Directory")
"aor" '(:ignore t :which-key "Org Roam")
"aori" '(org-roam-node-insert :which-key "Insert Node")
"aorf" '(org-roam-node-find :which-key "Find Node")
"aoru" '(org-roam-ui-open :which-key "Open UI")
"aos" '(org-edit-src-exit :which-key "Exit Src Edit")
"ag" '(:ignore t :which-key "Magit")
"agb" '(magit-blame :which-key "Magit Blame")
"agc" '(magit-branch-checkout :which-key "Magit Branch Checkout")
"ag," '(magit-commit :which-key "Magit Commit")
"agn" '(magit-branch-create :which-key "Magit Branch Create")
"ag>" '(magit-push :which-key "Magit Push")
"ag<" '(magit-pull :which-key "Magit Pull")
"ags" '(magit-status :which-key "Magit Status")
"av" '(:ignore t :which-key "VTerm")
"avn" '(multi-vterm :which-key "New Terminal")
"av>" '(multi-vterm-next :which-key "Next Terminal")
"av<" '(multi-vterm-previous :which-key "Previous Terminal")
;; Buffers
"b" '(:ignore t :which-key "Buffers")
"bl" '(list-buffers :which-key "List Buffers")
"bb" '(switch-to-buffer :which-key "Switch Buffer")
"bd" '(kill-this-buffer :which-key "Kill Buffer")
"bp" '(previous-buffer :which-key "Previous Buffer")
"bn" '(next-buffer :which-key "Next Buffer")
"bs" '(scratch-buffer :which-key "Scratch Buffer")
"br" '(rename-buffer :which-key "Rename Buffer")
;; Toggles
"t" '(:ignore t :which-key "Toggles")
"tl" '(display-line-numbers-mode :which-key "Line Numbers")
"ti" '(imenu-list-smart-toggle :which-key "IMenu List")
;; Avy
"j" '(:ignore t :which-key "Jump To")
"jl" '(avy-goto-line :which-key "Jump To Line (avy)")
"jw" '(avy-goto-word-1 :which-key "Jump To Worg (avy)")
;; Counsel
"/" '(counsel-rg :which-key "Search in project")
"p" '(:ignore t :which-key "Projectile")
"pp" '(counsel-projectile-switch-project :which-key "Switch Project (projectile)")
"pf" '(counsel-projectile-find-file :which-key "Find Files In Project (projectile)")
;; Files
"f" '(:ignore t :which-key "Files")
"fed" '(goto-init-file :which-key "Go to init file")
"fei" '(goto-inbox-file :which-key "Go to inbox file")
"ft" '(treemacs :which-key "Treemacs Filetree")
;; Windows
"w" '(:ignore t :which-key "Windows")
"wd" '(delete-window :which-key "Delete Window")
"w/" '(split-window-right :which-key "Split Window Right")
"w-" '(split-window-below :which-key "Split Window Below")
"wh" '(windmove-left :which-key "Move to Window on Left")
"wl" '(windmove-right :which-key "Move to Window on Right")
"wj" '(windmove-down :which-key "Move to Window Below")
"wk" '(windmove-up :which-key "Move to Window Above")
;; Eglot
"gg" '(eglot-find-typeDefinition :which-key "Find Definition")
"gi" '(eglot-find-implementation :which-key "Find Implementation")
;; Emacs
"q" '(:ignore t :which-key "Quit")
"qr" '(restart-emacs :which-key "Restart Emacs")
;; Images
"i" '(:ignore t :which-key "Images")
"ii" '(image-increase-size :which-key "Increase Size")
;; 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.
'(org-agenda-files nil)
'(modus-themes jsonrpc all-the-icons-ivy company counsel-projectile dashboard editorconfig ef-themes evil-mc exec-path-from-shell flycheck general gptel imenu-list ivy-rich magit markdown-mode multi-vterm org-modern org-pomodoro org-remark org-roam-ui ox-hugo plantuml-mode prettier-js rust-mode treemacs-all-the-icons treemacs-evil treemacs-projectile web-mode wgrep which-key)))
;; 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.
'(default ((t (:background nil)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment