Compare commits

..

No commits in common. "ddc20b88e24082b5b7c42002aaf40445c6e3e86b" and "e2f027df579eb314e39e24adcd9766bf63a10a1f" have entirely different histories.

16 changed files with 91 additions and 169 deletions

View File

@ -5,7 +5,6 @@
(use-package gptel
:commands (gptel-request)
:autoload (gptel--strip-mode-suffix)
:init
;; Annoyingly, gptel fails to require gptel-context, so we have to do it manually
(autoload 'gptel-context-add "gptel-context")
@ -43,11 +42,7 @@
:stream t
:models '("llama3.1:latest"
"mistral-nemo:latest"
"gemma2:2b"
"tinyllama:latest")))
(defvar gptel-backend-anthropic (gptel-make-anthropic "Claude"
:stream t
:key (password-store-get "anthropic-api-key")))
"gemma2:2b")))
(setq gptel-backend gptel-backend-openai
gptel-model "gpt-4o")
(defun gptel-select-backend (backend)
@ -86,27 +81,6 @@
(when options-plist
(plist-put prompts-plist :options options-plist))
prompts-plist))
(defun gptel-format ()
"Format the current region or buffer with gptel."
(interactive)
(let* ((subject (if (derived-mode-p 'prog-mode)
(format "%s code" (gptel--strip-mode-suffix major-mode))
"prose"))
(output-format (if (derived-mode-p 'prog-mode)
"code"
"text"))
start
end)
(if (use-region-p)
(setq start (region-beginning)
end (region-end))
(setq start (point-min)
end (point-max)))
(goto-char start)
(push-mark end t t)
(setq mark-active t)
(setq gptel--rewrite-message (format "Format this %s according to industry standards. Generate only %s, no explanation, no code fences." subject output-format))
(gptel-rewrite-menu)))
(add-to-list 'gptel-directives '(shell-command . "You are a command line helper. Generate shell commands that do what is requested, without any additional description or explanation. Reply in plain text with no Markdown or other syntax. Reply with the command only."))
(add-to-list 'gptel-directives '(org-mode . "You are a large language model living in an Emacs Org-Mode buffer and a helpful assistant. You may evaluate Emacs Lisp, Python, and shell-script code when necessary by outputting an Org-Mode source block. You don't need to ask for confirmation before evaluating code. The user will execute the source block and display the results in the buffer. Respond concisely.
@ -283,10 +257,9 @@ Assistant: Write a short story about a dragon who discovers a hidden talent that
"s" #'gptel-send
"m" #'gptel-menu
"b" #'gptel-chat-with-buffer
"f" #'gptel-format
"B" #'gptel-select-backend
"a" #'gptel-context-add
"F" #'gptel-context-add-file
"f" #'gptel-context-add-file
"k" #'gptel-abort))
(use-package gptel-quick

View File

@ -1,6 +1,14 @@
;; -*- lexical-binding: t; -*-
(define-derived-mode astro-mode web-mode "astro")
(add-to-list 'auto-mode-alist '("\\.astro\\'" . astro-mode))
(use-package astro-ts-mode
:mode "\\.astro\\'"
:init
(with-eval-after-load 'treesit
(add-to-list 'treesit-language-source-alist
'(astro "https://github.com/virchau13/tree-sitter-astro"))
(add-to-list 'treesit-language-source-alist
'(css "https://github.com/tree-sitter/tree-sitter-css"))
(add-to-list 'treesit-language-source-alist
'(tsx "https://github.com/tree-sitter/tree-sitter-typescript" "master" "tsx/src"))))
(provide 'init-astro)

View File

@ -192,8 +192,7 @@ targets."
([remap imenu] #'consult-imenu)
([remap projectile-ripgrep] #'consult-ripgrep)
([remap projectile-grep] #'consult-grep)
("C-c p" #'consult-yank-from-kill-ring)
(minibuffer-local-map "M-r" #'consult-history))
("C-c p" #'consult-yank-from-kill-ring))
(use-package consult-projectile
:after (consult projectile)

View File

@ -1,6 +0,0 @@
;; -*- lexical-binding: t; -*-
(use-package csv-mode
:mode "\\.csv\\'")
(provide 'init-csv)

View File

@ -6,8 +6,6 @@
magit-file-dispatch
magit-dispatch
magit-name-local-branch)
:autoload (magit-git-lines
magit-toplevel)
:init
(leader-def-key "g" '(nil :which-key "git"))
:config
@ -58,7 +56,6 @@
(use-package forge
:after (magit sqlite3)
:demand t
:autoload (forge-get-repository)
:config
(setq forge-add-default-bindings nil)
(add-to-list 'forge-alist '("git.jeremydormitzer.com"
@ -88,11 +85,7 @@ Does not work on already-created pull requests."
(let ((target forge--buffer-base-branch)
(source forge--buffer-head-branch))
(magit-diff-range (format "%s..%s" target source))))
(defun forge--submit-create-pullreq-after-advice (&rest args)
(when-let ((buf (magit-get-mode-buffer 'magit-diff-mode)))
(quit-window nil (get-buffer-window buf))))
(add-hook 'forge-create-pullreq-hook #'forge-diff-for-pr)
(advice-add 'forge--submit-create-pullreq :after #'forge--submit-create-pullreq-after-advice)
:custom
(forge-owned-accounts '((jdormit . (remote-name "jdormit"))))
:general

View File

@ -92,9 +92,9 @@
;; Astro
(add-to-list 'eglot-server-programs
'(astro-mode . ("astro-ls" "--stdio"
:initializationOptions
(:typescript (:tsdk "./node_modules/typescript/lib")))))
'(astro-ts-mode . ("astro-ls" "--stdio"
:initializationOptions
(:typescript (:tsdk "./node_modules/typescript/lib")))))
;; Custom eglot java server for deeper customization
(defvar eglot-java-java-agent nil
@ -235,7 +235,7 @@
(ruby-ts-mode . eglot-ensure)
(sh-mode . eglot-ensure)
(bash-ts-mode . eglot-ensure)
(astro-mode . eglot-ensure)
(astro-ts-mode . eglot-ensure)
:custom
(eglot-confirm-server-initiated-edits nil)
(eglot-connect-timeout nil))
@ -291,44 +291,41 @@
(defun apheleia ()
"Format the region or current buffer using Apheleia."
(interactive)
(if (not (region-active-p))
(call-interactively #'apheleia-format-buffer)
(let* ((buf (current-buffer))
(name (buffer-file-name))
(temp-file (make-temp-file "apheleia" nil (format ".%s" (file-name-extension name))))
(temp-buffer (find-file-noselect temp-file))
(formatters (apheleia--get-formatters))
(line (line-number-at-pos))
(col (current-column))
(start (region-beginning))
(end (region-end)))
(with-current-buffer temp-buffer
(erase-buffer)
(insert-buffer-substring buf start end)
(write-file temp-file)
(apheleia-format-buffer formatters
(lambda ()
(with-current-buffer buf
(delete-region start end)
(insert (with-current-buffer temp-buffer
(buffer-substring-no-properties (point-min) (point-max))))
(goto-char (point-min))
(forward-line (1- line))
(move-to-column col)
(delete-file temp-file)
(when (get-buffer temp-buffer)
(with-current-buffer temp-buffer
(set-buffer-modified-p nil))
(kill-buffer temp-buffer))))
:callback (lambda (&rest args)
(when-let ((error (plist-get args :error)))
(delete-file temp-file)
(when (get-buffer temp-buffer)
(with-current-buffer temp-buffer
(set-buffer-modified-p nil))
(kill-buffer temp-buffer))
(error "Formatting failed: %s" error)))))))
)
(let* ((buf (current-buffer))
(name (buffer-file-name))
(temp-file (make-temp-file "apheleia" nil (format ".%s" (file-name-extension name))))
(temp-buffer (find-file-noselect temp-file))
(formatters (apheleia--get-formatters))
(line (line-number-at-pos))
(col (current-column))
start
end)
(if (region-active-p)
(setq start (region-beginning)
end (region-end))
(setq start (point-min)
end (point-max)))
(with-current-buffer temp-buffer
(erase-buffer)
(insert-buffer-substring buf start end)
(write-file temp-file)
(apheleia-format-buffer formatters
(lambda ()
(with-current-buffer buf
(delete-region start end)
(insert-buffer-substring temp-buffer)
(goto-char (point-min))
(forward-line (1- line))
(move-to-column col)
(delete-file temp-file)
(when (get-buffer temp-buffer)
(kill-buffer temp-buffer))))
:callback (lambda (&rest args)
(when-let ((error (plist-get args :error)))
(delete-file temp-file)
(when (get-buffer temp-buffer)
(kill-buffer temp-buffer))
(error "Formatting failed: %s" error)))))))
(keymap-set prog-mode-map "C-c f" #'apheleia)

View File

@ -2,11 +2,17 @@
;; node version manager
(use-package nvm
:straight (:host github :repo "rejeep/nvm.el")
:commands (nvm-use)
:autoload (nvm-use-for
:commands (nvm-use
nvm-use-for
nvm-use-for-buffer
nvm--installed-versions))
nvm--installed-versions)
:init
(defun nvm (version)
(interactive (list
(completing-read "Node version: "
(mapcar #'car
(nvm--installed-versions)))))
(nvm-use version)))
(use-package json-mode
:commands (json-mode)

View File

@ -2,8 +2,6 @@
(use-package markdown-mode
:mode (("\\.md\\'" . gfm-mode)
("\\.markdown\\'" . gfm-mode))
:custom
(markdown-fontify-code-blocks-natively t))
("\\.markdown\\'" . gfm-mode)))
(provide 'init-markdown)

View File

@ -12,60 +12,41 @@
("Guardfile\\'" . ruby-mode)
("Capfile\\'" . ruby-mode)
("Vagrantfile\\'" . ruby-mode))
:hook (ruby-mode . highlight-indent-guides-mode))
:hook (ruby-mode . highlight-indent-guides-mode)
:config
(defun toggle-spec-file ()
"Find the spec file for the current non-spec buffer or the file under test for the current spec buffer."
(interactive)
(let* ((dir (if-let ((proj (project-current)))
(project-root proj)
default-directory))
(ext (file-name-extension (buffer-file-name)))
(filename-base (file-name-base (buffer-file-name)))
(spec? (s-ends-with? "_spec" filename-base))
(rx (if spec?
(format "%s.%s$" (s-chop-suffix "_spec" filename-base) ext)
(format "%s_spec.%s$" filename-base ext)))
(candidates (directory-files-recursively dir rx)))
(cond ((= (length candidates) 0)
(message "No matching file found"))
((= (length candidates) 1)
(find-file (car candidates)))
(t
(let ((choice (consult--read candidates
:prompt "Find file: "
:category 'file)))
(find-file choice))))))
:general
(ruby-mode-map "C-c C-t" #'toggle-spec-file))
(use-package inf-ruby
:commands (inf-ruby inf-ruby-console-auto)
:general
([remap inf-ruby] #'inf-ruby-console-auto)
:hook (after-init . inf-ruby-switch-setup))
([remap inf-ruby] #'inf-ruby-console-auto))
(use-package rbenv
:hook (after-init . global-rbenv-mode)
:custom
(rbenv-show-active-ruby-in-modeline nil))
(use-package rspec-mode
:hook (dired-mode . rspec-dired-mode)
:config
(defun rspec-compile-command-filter-return (output)
(if current-prefix-arg
(read-string "Command: " output)
output))
(advice-add 'rspec-compile-command :filter-return #'rspec-compile-command-filter-return)
(defun rspec--run-verify-changed (&optional related)
(let* ((repo (forge-get-repository :tracked))
(branch (or (when repo
(oref repo default-branch))
"master"))
(remote (or (when repo
(oref repo remote))
"origin"))
(target-branch (format "%s/%s" remote branch))
(files (->> (magit-git-lines "diff" "--name-only" (format "%s..." target-branch))
(seq-filter (lambda (file)
(string-match-p "\\.rb\\'" file)))
(mapcar (lambda (file) (expand-file-name file (magit-toplevel))))))
(specs (->> (if related
(seq-mapcat #'rspec-all-related-spec-files files)
(mapcar #'rspec-spec-file-for files))
(mapcar (lambda (file) (expand-file-name file (magit-toplevel))))
(seq-filter #'file-exists-p))))
(rspec-run-multiple-files specs (rspec-core-options))))
(defun rspec-verify-changed ()
"Runs RSpec on the specs for the Ruby files changed between the current branch and TARGET-BRANCH."
(interactive)
(rspec--run-verify-changed))
(defun rspec-verify-changed-related ()
"Runs RSpec on all related specs for the Ruby files changed between the current branch and TARGET-BRANCH."
(interactive)
(rspec--run-verify-changed t))
:general
(rspec-mode-map "C-c , g" #'rspec-verify-changed
"C-c , G" #'rspec-verify-changed-related)
(rspec-verifiable-mode-map "C-c , g" #'rspec-verify-changed
"C-c , G" #'rspec-verify-changed-related)
:custom
(rspec-use-opts-file-when-available nil))
(provide 'init-ruby)

View File

@ -39,17 +39,9 @@
(advice-add 'run-command :around #'run-command-advice)
(advice-add 'run-command-core-run :around #'run-command-core-run-advice)
(defun run-command-runner-compile-comint (command-line _buffer-base-name output-buffer)
"Command runner that runs COMMAND-LINE in a comint buffer."
(with-current-buffer output-buffer
(compilation-mode)
(compilation-start command-line t)
(setq-local comint-process-echoes t)))
(defun run-command-with-runner (runner)
(interactive (list (completing-read "Runner: "
'(run-command-runner-compile
run-command-runner-compile-comint
run-command-runner-vterm
run-command-runner-term
run-command-runner-eat)

View File

@ -3,7 +3,4 @@
(use-package rust-mode
:mode (("\\.rs\\'" . rust-mode)))
(use-package cargo
:hook (rust-mode . cargo-minor-mode))
(provide 'init-rust)

View File

@ -30,10 +30,6 @@
(use-package hide-mode-line
:commands hide-mode-line-mode)
(use-package nerd-icons)
(use-package nerd-icons-dired
:hook (dired-mode . nerd-icons-dired-mode))
;; A function to set the frame font
(defun set-font (font)
"Set the frame font to `font'"

View File

@ -99,7 +99,6 @@
(require 'init-astro)
(require 'init-xml)
(require 'init-yaml)
(require 'init-csv)
(require 'init-groovy)
(require 'init-devdocs)
(require 'init-terraform)

View File

@ -59,7 +59,6 @@ brew "youtube-dl"
cask "alfred"
cask "bartender"
cask "calibre"
cask "charles"
cask "cleanshot"
cask "contexts"
cask "corretto11"
@ -81,4 +80,3 @@ cask "spotify"
cask "syncthing"
cask "the-unarchiver"
cask "vcv-rack"
cask "wireshark"

View File

@ -8,13 +8,9 @@
<array>
<string>sh</string>
<string>-c</string>
<string>/usr/bin/python3 -m http.server -d $HOME/witchcraft-scripts 5743</string>
<string>/usr/bin/python3 -m http.server -d ~/witchcraft-scripts 5743</string>
</array>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>/tmp/witchcraft.log</string>
<key>StandardErrorPath</key>
<string>/tmp/witchcraft.log</string>
</dict>
</plist>

View File

@ -94,7 +94,6 @@ fi
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git direnv pipenv npm nvm rbenv pass aws)
zstyle ':omz:plugins:nvm' autoload true
source $ZSH/oh-my-zsh.sh
@ -273,7 +272,3 @@ PROMPT=$PROMPT'%{$(vterm_prompt_end)%}'
type navi > /dev/null && eval "$(navi widget zsh)"
eval "$(rbenv init - zsh)"
export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion