feat(projects): add projectile switch project keybind that creates new tab-bar tab if needed

This commit is contained in:
Jim Myhrberg
2024-12-02 15:05:36 +00:00
parent 97164f6d27
commit c3bc47ab47
2 changed files with 23 additions and 2 deletions

View File

@@ -6,9 +6,12 @@
;;; Code:
(require 'siren-tab-bar)
(use-package projectile
:commands
projectile-project-root
projectile-relevant-known-projects
:general
("C-c p p" 'projectile-switch-project)
@@ -22,6 +25,8 @@
("C-x j" 'projectile-dired)
("C-x ;" 'projectile-find-file)
("C-x C-;" 'projectile-find-file)
("C-z ;" 'siren-projectile-switch-project-and-tab)
("C-z C-;" 'siren-projectile-switch-project-and-tab)
(:keymaps 'projectile-mode-map
"C-c p" 'projectile-command-map)
@@ -74,6 +79,22 @@ behavior."
(apply orig-fun args)
(projectile-switch-project)))
(defun siren-projectile-switch-project-and-tab (&optional arg)
"Switch to a project we have visited before and create a new tab for it.
Behaves the same as `projectile-switch-project', but creates a new tab for the
project, based on the project name reported by projectile."
(interactive "P")
(let ((projects (projectile-relevant-known-projects)))
(if projects
(projectile-completing-read
"Switch to project: " projects
:action (lambda (project)
(siren-tab-bar-switch-to-or-create-tab
(projectile-project-name project))
(projectile-switch-project-by-name project arg)))
(user-error "There are no known projects"))))
:config
(push "Gemfile" projectile-project-root-files-bottom-up)
(advice-add 'projectile-find-file :around #'siren-projectile-find-file-advice)

View File

@@ -42,8 +42,8 @@
"C-e" 'tab-group
"u" 'tab-undo
"C-u" 'tab-undo
";" 'siren-tab-bar-echo-tab-list
"C-;" 'siren-tab-bar-echo-tab-list
"'" 'siren-tab-bar-echo-tab-list
"C-'" 'siren-tab-bar-echo-tab-list
"0" 'siren-tab-bar-switch-to-index
"1" 'siren-tab-bar-switch-to-index
"2" 'siren-tab-bar-switch-to-index