Add modules/feature/version-control
This commit is contained in:
parent
cdeab2c292
commit
76f09d83ff
3 changed files with 90 additions and 0 deletions
32
modules/feature/version-control/autoload.el
Normal file
32
modules/feature/version-control/autoload.el
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
;;; feature/version-control/autoload.el
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +vcs-git-root ()
|
||||||
|
"Get git url root."
|
||||||
|
(-when-let (url (car-safe (browse-at-remote--remote-ref buffer-file-name)))
|
||||||
|
(cdr (browse-at-remote--get-url-from-remote url))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +vcs/git-browse ()
|
||||||
|
"Open the website for the current (or specified) version controlled FILE.
|
||||||
|
Fallback to repository root."
|
||||||
|
(interactive)
|
||||||
|
(let (url)
|
||||||
|
(condition-case err
|
||||||
|
(setq url (browse-at-remote-get-url))
|
||||||
|
(error
|
||||||
|
(setq url (shell-command-to-string "hub browse -u --"))
|
||||||
|
(setq url (if url
|
||||||
|
(concat (s-trim url) "/" (f-relative (buffer-file-name) (doom-project-root))
|
||||||
|
(when (use-region-p) (format "#L%s-L%s"
|
||||||
|
(line-number-at-pos (region-beginning))
|
||||||
|
(line-number-at-pos (region-end)))))))))
|
||||||
|
(when url (browse-url url))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +vcs/git-browse-issues ()
|
||||||
|
"Open the github issues page for current repo."
|
||||||
|
(interactive)
|
||||||
|
(if-let (root (+vcs-git-root))
|
||||||
|
(browse-url (concat root "/issues"))
|
||||||
|
(user-error "No git root found!")))
|
50
modules/feature/version-control/config.el
Normal file
50
modules/feature/version-control/config.el
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
;;; core/version-control/config.el
|
||||||
|
|
||||||
|
(use-package! gitconfig-mode
|
||||||
|
:mode "/\\.?git/?config$"
|
||||||
|
:mode "/\\.gitmodules$"
|
||||||
|
:init (add-hook 'gitconfig-mode-hook 'flyspell-mode))
|
||||||
|
|
||||||
|
(use-package! gitignore-mode
|
||||||
|
:mode "/\\.?git/?config$"
|
||||||
|
:mode "/\\.gitmodules$")
|
||||||
|
|
||||||
|
|
||||||
|
(use-package! browse-at-remote
|
||||||
|
:commands (browse-at-remote/browse browse-at-remote/get-url))
|
||||||
|
|
||||||
|
|
||||||
|
(use-package! magit
|
||||||
|
:commands magit-status
|
||||||
|
:config
|
||||||
|
(def-popup! ("^\\*magit.+" :regexp t))
|
||||||
|
(after! evil-snipe
|
||||||
|
;; evil-snipe conflicts with magit
|
||||||
|
(add-hook 'magit-mode-hook 'turn-off-evil-snipe-override-mode)))
|
||||||
|
|
||||||
|
|
||||||
|
(use-package! evil-magit
|
||||||
|
:when (featurep 'evil)
|
||||||
|
:after magit)
|
||||||
|
|
||||||
|
|
||||||
|
(after! vc-annotate
|
||||||
|
(set! :popup
|
||||||
|
("*vc-diff*" :size 15 :noselect t)
|
||||||
|
("*vc-change-log*" :size 15 :select t)
|
||||||
|
(vc-annotate-mode :same t))
|
||||||
|
|
||||||
|
(set! :evil-state
|
||||||
|
(vc-annotate-mode normal)
|
||||||
|
(vc-git-log-view-mode normal))
|
||||||
|
|
||||||
|
(map! :map vc-annotate-mode-map
|
||||||
|
:n "q" 'kill-this-buffer
|
||||||
|
:n "d" 'vc-annotate-show-diff-revision-at-line
|
||||||
|
:n "D" 'vc-annotate-show-changeset-diff-revision-at-line
|
||||||
|
:n "SPC" 'vc-annotate-show-log-revision-at-line
|
||||||
|
:n "]]" 'vc-annotate-next-revision
|
||||||
|
:n "[[" 'vc-annotate-prev-revision
|
||||||
|
:n [tab] 'vc-annotate-toggle-annotation-visibility
|
||||||
|
:n "RET" 'vc-annotate-find-revision-at-line))
|
||||||
|
|
8
modules/feature/version-control/packages.el
Normal file
8
modules/feature/version-control/packages.el
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
;; -*- no-byte-compile: t; -*-
|
||||||
|
;;; core/version-control/packages.el
|
||||||
|
|
||||||
|
(package! browse-at-remote)
|
||||||
|
(package! evil-magit :needs evil)
|
||||||
|
(package! gitconfig-mode)
|
||||||
|
(package! gitignore-mode)
|
||||||
|
(package! magit)
|
Loading…
Add table
Add a link
Reference in a new issue