diff --git a/dotfiles/desktop/.emacs.d/lisp/core/keybindings.el b/dotfiles/desktop/.emacs.d/lisp/core/keybindings.el index 6eab859..c8379d2 100644 --- a/dotfiles/desktop/.emacs.d/lisp/core/keybindings.el +++ b/dotfiles/desktop/.emacs.d/lisp/core/keybindings.el @@ -90,10 +90,10 @@ (define-key fscotto/leader-map (kbd "p") 'projectile-command-map) (with-eval-after-load 'projectile - (define-key projectile-command-map (kbd "v") #'fscotto/project-vterm) - (define-key projectile-command-map (kbd "V") #'fscotto/project-multi-vterm) + (define-key projectile-command-map (kbd "v") #'fscotto/project-multi-vterm) + (define-key projectile-command-map (kbd "V") nil) (define-key projectile-command-map (kbd "x") #'fscotto/project-external-terminal) - (define-key projectile-command-map (kbd "a") #'fscotto/project-opencode) + (define-key projectile-command-map (kbd "a") #'fscotto/project-opencode-dwim) (define-key projectile-command-map (kbd "A") #'fscotto/project-opencode-session) (define-key projectile-command-map (kbd "g") #'fscotto/project-magit-status)) diff --git a/dotfiles/desktop/.emacs.d/lisp/misc/custom-functions.el b/dotfiles/desktop/.emacs.d/lisp/misc/custom-functions.el index 5ba7705..ed4b51d 100644 --- a/dotfiles/desktop/.emacs.d/lisp/misc/custom-functions.el +++ b/dotfiles/desktop/.emacs.d/lisp/misc/custom-functions.el @@ -124,6 +124,21 @@ Each entry is a cons cell of display string and session id." "order by time_updated desc;") (replace-regexp-in-string "'" "''" session-directory)))))) +(defun fscotto/project-opencode-latest-session-id () + "Return the latest saved OpenCode session id for the current project." + (car (last (car (fscotto/opencode-session-candidates (fscotto/project-root)))))) + +(defun fscotto/project-opencode-dwim () + "Open the most useful OpenCode session for the current project. + +Resume the latest saved session when available, otherwise create a new one." + (interactive) + (let ((session-id (fscotto/project-opencode-latest-session-id))) + (if session-id + (fscotto/launch-external-terminal (list "opencode" "--session" session-id) + (fscotto/project-root)) + (fscotto/project-opencode)))) + (defun fscotto/project-opencode-session () "Resume a saved OpenCode session for the current project." (interactive) diff --git a/dotfiles/desktop/.emacs.d/lisp/misc/which-key.el b/dotfiles/desktop/.emacs.d/lisp/misc/which-key.el index 617ef7f..77d5af1 100644 --- a/dotfiles/desktop/.emacs.d/lisp/misc/which-key.el +++ b/dotfiles/desktop/.emacs.d/lisp/misc/which-key.el @@ -143,11 +143,10 @@ ;; Actions "C-c p c" "Compile" "C-c p t" "Test" - "C-c p v" "Open vterm in project" - "C-c p V" "Open multi-vterm in project" + "C-c p v" "Open multi-vterm in project" "C-c p x" "Open external term" - "C-c p a" "Open opencode" - "C-c p A" "Resume opencode session" + "C-c p a" "OpenCode (dwim)" + "C-c p A" "Choose OpenCode session" "C-c p e" "Edit project config" "C-c p g" "Project Git status" "C-c p 4" "Other Window"