Compare commits
26 Commits
e2f027df57
...
ddc20b88e2
Author | SHA1 | Date | |
---|---|---|---|
ddc20b88e2 | |||
ebab6d32b9 | |||
f132f9fa7b | |||
6352fbb697 | |||
73227abcbe | |||
09bbe297aa | |||
b04ecc05d1 | |||
63f8fb86c9 | |||
3f43f47bac | |||
91a2df3e08 | |||
e8aec0ade3 | |||
0ccb10c8e2 | |||
ef5b7f03d6 | |||
fd961c9416 | |||
2f4d415cba | |||
5f11045ae0 | |||
e1be78e05f | |||
d3a2bcd6f5 | |||
ad1ba5f7fa | |||
1823e4bcf6 | |||
4af3063f30 | |||
47727d73f9 | |||
d5030f749f | |||
9a1f0aea68 | |||
59ab43f820 | |||
af5e7ab1e0 |
@ -5,6 +5,7 @@
|
||||
|
||||
(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")
|
||||
@ -42,7 +43,11 @@
|
||||
:stream t
|
||||
:models '("llama3.1:latest"
|
||||
"mistral-nemo:latest"
|
||||
"gemma2:2b")))
|
||||
"gemma2:2b"
|
||||
"tinyllama:latest")))
|
||||
(defvar gptel-backend-anthropic (gptel-make-anthropic "Claude"
|
||||
:stream t
|
||||
:key (password-store-get "anthropic-api-key")))
|
||||
(setq gptel-backend gptel-backend-openai
|
||||
gptel-model "gpt-4o")
|
||||
(defun gptel-select-backend (backend)
|
||||
@ -81,6 +86,27 @@
|
||||
(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.
|
||||
|
||||
@ -257,9 +283,10 @@ 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
|
||||
|
@ -1,14 +1,6 @@
|
||||
;; -*- lexical-binding: t; -*-
|
||||
|
||||
(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"))))
|
||||
(define-derived-mode astro-mode web-mode "astro")
|
||||
(add-to-list 'auto-mode-alist '("\\.astro\\'" . astro-mode))
|
||||
|
||||
(provide 'init-astro)
|
||||
|
@ -192,7 +192,8 @@ targets."
|
||||
([remap imenu] #'consult-imenu)
|
||||
([remap projectile-ripgrep] #'consult-ripgrep)
|
||||
([remap projectile-grep] #'consult-grep)
|
||||
("C-c p" #'consult-yank-from-kill-ring))
|
||||
("C-c p" #'consult-yank-from-kill-ring)
|
||||
(minibuffer-local-map "M-r" #'consult-history))
|
||||
|
||||
(use-package consult-projectile
|
||||
:after (consult projectile)
|
||||
|
6
emacs/.emacs.d/config/init-csv.el
Normal file
6
emacs/.emacs.d/config/init-csv.el
Normal file
@ -0,0 +1,6 @@
|
||||
;; -*- lexical-binding: t; -*-
|
||||
|
||||
(use-package csv-mode
|
||||
:mode "\\.csv\\'")
|
||||
|
||||
(provide 'init-csv)
|
@ -6,6 +6,8 @@
|
||||
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
|
||||
@ -56,6 +58,7 @@
|
||||
(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"
|
||||
@ -85,7 +88,11 @@ 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
|
||||
|
@ -92,9 +92,9 @@
|
||||
|
||||
;; Astro
|
||||
(add-to-list 'eglot-server-programs
|
||||
'(astro-ts-mode . ("astro-ls" "--stdio"
|
||||
:initializationOptions
|
||||
(:typescript (:tsdk "./node_modules/typescript/lib")))))
|
||||
'(astro-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-ts-mode . eglot-ensure)
|
||||
(astro-mode . eglot-ensure)
|
||||
:custom
|
||||
(eglot-confirm-server-initiated-edits nil)
|
||||
(eglot-connect-timeout nil))
|
||||
@ -291,41 +291,44 @@
|
||||
(defun apheleia ()
|
||||
"Format the region or current buffer using Apheleia."
|
||||
(interactive)
|
||||
(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)))))))
|
||||
(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)))))))
|
||||
)
|
||||
|
||||
(keymap-set prog-mode-map "C-c f" #'apheleia)
|
||||
|
||||
|
@ -2,17 +2,11 @@
|
||||
|
||||
;; node version manager
|
||||
(use-package nvm
|
||||
:commands (nvm-use
|
||||
nvm-use-for
|
||||
:straight (:host github :repo "rejeep/nvm.el")
|
||||
:commands (nvm-use)
|
||||
:autoload (nvm-use-for
|
||||
nvm-use-for-buffer
|
||||
nvm--installed-versions)
|
||||
:init
|
||||
(defun nvm (version)
|
||||
(interactive (list
|
||||
(completing-read "Node version: "
|
||||
(mapcar #'car
|
||||
(nvm--installed-versions)))))
|
||||
(nvm-use version)))
|
||||
nvm--installed-versions))
|
||||
|
||||
(use-package json-mode
|
||||
:commands (json-mode)
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
(use-package markdown-mode
|
||||
:mode (("\\.md\\'" . gfm-mode)
|
||||
("\\.markdown\\'" . gfm-mode)))
|
||||
("\\.markdown\\'" . gfm-mode))
|
||||
:custom
|
||||
(markdown-fontify-code-blocks-natively t))
|
||||
|
||||
(provide 'init-markdown)
|
||||
|
@ -12,41 +12,60 @@
|
||||
("Guardfile\\'" . ruby-mode)
|
||||
("Capfile\\'" . ruby-mode)
|
||||
("Vagrantfile\\'" . ruby-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))
|
||||
:hook (ruby-mode . highlight-indent-guides-mode))
|
||||
|
||||
(use-package inf-ruby
|
||||
:commands (inf-ruby inf-ruby-console-auto)
|
||||
:general
|
||||
([remap inf-ruby] #'inf-ruby-console-auto))
|
||||
([remap inf-ruby] #'inf-ruby-console-auto)
|
||||
:hook (after-init . inf-ruby-switch-setup))
|
||||
|
||||
(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)
|
||||
|
@ -39,9 +39,17 @@
|
||||
(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)
|
||||
|
@ -3,4 +3,7 @@
|
||||
(use-package rust-mode
|
||||
:mode (("\\.rs\\'" . rust-mode)))
|
||||
|
||||
(use-package cargo
|
||||
:hook (rust-mode . cargo-minor-mode))
|
||||
|
||||
(provide 'init-rust)
|
||||
|
@ -30,6 +30,10 @@
|
||||
(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'"
|
||||
|
@ -99,6 +99,7 @@
|
||||
(require 'init-astro)
|
||||
(require 'init-xml)
|
||||
(require 'init-yaml)
|
||||
(require 'init-csv)
|
||||
(require 'init-groovy)
|
||||
(require 'init-devdocs)
|
||||
(require 'init-terraform)
|
||||
|
@ -59,6 +59,7 @@ brew "youtube-dl"
|
||||
cask "alfred"
|
||||
cask "bartender"
|
||||
cask "calibre"
|
||||
cask "charles"
|
||||
cask "cleanshot"
|
||||
cask "contexts"
|
||||
cask "corretto11"
|
||||
@ -80,3 +81,4 @@ cask "spotify"
|
||||
cask "syncthing"
|
||||
cask "the-unarchiver"
|
||||
cask "vcv-rack"
|
||||
cask "wireshark"
|
||||
|
@ -8,9 +8,13 @@
|
||||
<array>
|
||||
<string>sh</string>
|
||||
<string>-c</string>
|
||||
<string>/usr/bin/python3 -m http.server -d ~/witchcraft-scripts 5743</string>
|
||||
<string>/usr/bin/python3 -m http.server -d $HOME/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>
|
||||
|
@ -94,6 +94,7 @@ 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
|
||||
|
||||
@ -272,3 +273,7 @@ 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
|
||||
|
Loading…
Reference in New Issue
Block a user