mirror of
https://codeberg.org/scip/dot-emacs.git
synced 2026-08-23 21:24:18 +02:00
add gitswitch and git repo list to consult-buffer, do: g SPC
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -24,3 +24,8 @@ emms
|
|||||||
macros.el
|
macros.el
|
||||||
forge-database.sqlite
|
forge-database.sqlite
|
||||||
forge-database*
|
forge-database*
|
||||||
|
.cache
|
||||||
|
cache
|
||||||
|
*history*
|
||||||
|
tree-sitter
|
||||||
|
warnings
|
||||||
|
|||||||
@@ -138,9 +138,9 @@
|
|||||||
|
|
||||||
:custom-face
|
:custom-face
|
||||||
(blamer-face ((t :foreground "#7a88cf"
|
(blamer-face ((t :foreground "#7a88cf"
|
||||||
:background nil
|
:background nil
|
||||||
:height 140
|
:height 140
|
||||||
:italic t)))
|
:italic t)))
|
||||||
|
|
||||||
:config
|
:config
|
||||||
(defalias 'blame 'blamer-mode)
|
(defalias 'blame 'blamer-mode)
|
||||||
@@ -148,10 +148,10 @@
|
|||||||
;; in addition to blaming I also like to follow the lead, so make
|
;; in addition to blaming I also like to follow the lead, so make
|
||||||
;; the hash lead to the commit by clicking on it.
|
;; the hash lead to the commit by clicking on it.
|
||||||
(defun blamer-callback-show-commit-diff (commit-info)
|
(defun blamer-callback-show-commit-diff (commit-info)
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((commit-hash (plist-get commit-info :commit-hash)))
|
(let ((commit-hash (plist-get commit-info :commit-hash)))
|
||||||
(when commit-hash
|
(when commit-hash
|
||||||
(magit-show-commit commit-hash))))
|
(magit-show-commit commit-hash))))
|
||||||
|
|
||||||
(setq blamer-bindings '(("<mouse-1>" . blamer-callback-show-commit-diff))))
|
(setq blamer-bindings '(("<mouse-1>" . blamer-callback-show-commit-diff))))
|
||||||
|
|
||||||
@@ -161,5 +161,34 @@
|
|||||||
(use-package sqlite3
|
(use-package sqlite3
|
||||||
:defer nil)
|
:defer nil)
|
||||||
|
|
||||||
|
;; git helpers
|
||||||
|
(defun tvd-list-git-repos()
|
||||||
|
"Returns a list of all available git repositories in dev and fits/git"
|
||||||
|
(interactive)
|
||||||
|
(setq repos (list))
|
||||||
|
(let ((bases (list "~/dev" "~/fits/git")))
|
||||||
|
(dolist (base bases)
|
||||||
|
(dolist (dir (directory-files base nil "^[^\\.]"))
|
||||||
|
(if (and (file-accessible-directory-p (concat base "/" dir "/.git"))
|
||||||
|
(not (s-suffix? "bak" dir) ))
|
||||||
|
(push dir repos)))))
|
||||||
|
repos)
|
||||||
|
|
||||||
|
(defun tvd-switch-to-repo(repo)
|
||||||
|
"calls magit-status with <repo>, switches to and changes dir to it"
|
||||||
|
(interactive)
|
||||||
|
(let* ((devdir (concat "~/dev/" repo))
|
||||||
|
(fitsdir (concat "~/fits/git/" repo)))
|
||||||
|
(cond
|
||||||
|
((file-accessible-directory-p (concat devdir "/.git"))
|
||||||
|
(magit-status devdir))
|
||||||
|
((file-accessible-directory-p (concat fitsdir "/.git"))
|
||||||
|
(magit-status fitsdir)))))
|
||||||
|
|
||||||
|
(defun gitswitch()
|
||||||
|
"select a git repo from a list and switch to it"
|
||||||
|
(interactive)
|
||||||
|
(tvd-switch-to-repo (completing-read "select git repo> " (tvd-list-git-repos))))
|
||||||
|
|
||||||
(provide 'init-magit)
|
(provide 'init-magit)
|
||||||
;;; init-magit.el ends here
|
;;; init-magit.el ends here
|
||||||
|
|||||||
@@ -212,7 +212,6 @@ targets."
|
|||||||
(consult-widen-key ">")
|
(consult-widen-key ">")
|
||||||
|
|
||||||
:config
|
:config
|
||||||
|
|
||||||
(when (fboundp 'persp-new)
|
(when (fboundp 'persp-new)
|
||||||
(consult-customize consult--source-buffer :hidden t :default nil)
|
(consult-customize consult--source-buffer :hidden t :default nil)
|
||||||
|
|
||||||
@@ -224,7 +223,21 @@ targets."
|
|||||||
:default t
|
:default t
|
||||||
:items #'persp-get-buffer-names))
|
:items #'persp-get-buffer-names))
|
||||||
|
|
||||||
(push consult--source-perspective consult-buffer-sources)))
|
(push consult--source-perspective consult-buffer-sources))
|
||||||
|
|
||||||
|
|
||||||
|
(defvar git-source
|
||||||
|
(list :name "Git Repo"
|
||||||
|
:category 'consult-location
|
||||||
|
:narrow ?g
|
||||||
|
:face 'consult-buffer
|
||||||
|
:history 'buffer-name-history
|
||||||
|
:state #'consult--buffer-state
|
||||||
|
:sort t
|
||||||
|
:action #'tvd-switch-to-repo
|
||||||
|
:items #'tvd-list-git-repos))
|
||||||
|
|
||||||
|
(add-to-list 'consult-buffer-sources 'git-source 'append))
|
||||||
|
|
||||||
;; needs to be defined outside
|
;; needs to be defined outside
|
||||||
(defalias 'rg 'consult-ripgrep)
|
(defalias 'rg 'consult-ripgrep)
|
||||||
@@ -273,7 +286,7 @@ targets."
|
|||||||
([backtab] . corfu-previous)))
|
([backtab] . corfu-previous)))
|
||||||
|
|
||||||
|
|
||||||
;; much better experience to seach current buffer consult-line would
|
;; much better experience to seach current buffer, consult-line would
|
||||||
;; do the job as well and looks similar, but I'm used to swiper, so
|
;; do the job as well and looks similar, but I'm used to swiper, so
|
||||||
;; stick with it.
|
;; stick with it.
|
||||||
(use-package swiper
|
(use-package swiper
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ _k_: kill (C-k) _s_: split _{_: wrap with { }
|
|||||||
|
|
||||||
(define-key smartparens-mode-map (kbd "C-x (") 'hydra-smartparens/body))
|
(define-key smartparens-mode-map (kbd "C-x (") 'hydra-smartparens/body))
|
||||||
|
|
||||||
:bind (:map smartparens-mode-map
|
:bind (;:map smartparens-mode-map
|
||||||
;; auto wrapping w/o region
|
;; auto wrapping w/o region
|
||||||
( "C-c (" . 'wrap-with-parens)
|
( "C-c (" . 'wrap-with-parens)
|
||||||
( "C-c [" . 'wrap-with-brackets)
|
( "C-c [" . 'wrap-with-brackets)
|
||||||
|
|||||||
Reference in New Issue
Block a user