Some work on vterm stuff

This commit is contained in:
Alexander Rosenberg 2023-10-12 16:56:14 -07:00
parent 0e3491c9a8
commit 8f354329dd
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730

20
init.el
View File

@ -457,16 +457,17 @@ visual states."
;; project.el
(use-package project
:bind (:map project-prefix-map
:bind (("C-x C-a" . my/project-vterm-or-default)
:map project-prefix-map
("s" . my/project-vterm)
("u" . my/project-run))
:init
(defvar my/project-vterm-hash-table (make-hash-table :test 'equal)
"Hash table that maps project root dirs to vterm buffers.")
(defun my/project-vterm ()
(defun my/project-vterm (prompt)
"Switch to or create a vterm buffer in the current projects root."
(interactive)
(if-let ((proj (project-current t))
(interactive (list t))
(if-let ((proj (project-current prompt))
(default-directory (project-root proj)))
(if-let ((vterm-buff (gethash default-directory
my/project-vterm-hash-table))
@ -475,6 +476,14 @@ visual states."
(puthash default-directory
(vterm (concat "*vterm for project " default-directory "*"))
my/project-vterm-hash-table))))
(defun my/project-vterm-or-default ()
"Open a vterm for the current project, otherwise, open a normal vterm."
(interactive)
(unless (my/project-vterm nil)
(if-let ((vterm-buff (gethash nil my/project-vterm-hash-table))
((buffer-live-p vterm-buff)))
(switch-to-buffer vterm-buff)
(puthash nil (vterm vterm-buffer-name) my/project-vterm-hash-table))))
(defvar my/project-run-command nil
"Command to run with `my/project-run'.")
(put 'my/project-run-command 'safe-local-variable (lambda (val)
@ -551,8 +560,7 @@ COMMAND and COMINT are like `compile'."
;; vterm
(use-package vterm
:hook (vterm-mode . with-editor-export-editor)
:bind ("C-x C-a" . vterm))
:hook (vterm-mode . with-editor-export-editor))
;; proced
(use-package proced