doomemacs/core/core-vcs.el

104 lines
3.5 KiB
EmacsLisp
Raw Normal View History

2017-01-17 12:15:48 +08:00
;;; core-vcs.el
2015-06-15 15:05:52 +08:00
2017-01-17 12:15:48 +08:00
(package! gitconfig-mode
:mode "/\\.?git/?config$"
:mode "/\\.gitmodules$"
2016-03-28 06:18:43 +08:00
:init (add-hook 'gitconfig-mode-hook 'flyspell-mode))
2015-06-15 15:05:52 +08:00
2017-01-17 12:15:48 +08:00
(package! gitignore-mode
:mode "/\\.gitignore$"
:mode "/\\.git/info/exclude$"
:mode "/git/ignore$")
2015-06-15 15:05:52 +08:00
2017-01-17 12:15:48 +08:00
(package! git-gutter-fringe
:commands git-gutter-mode
:init (add-hook! (text-mode prog-mode conf-mode) 'git-gutter-mode)
2015-12-09 14:16:31 +08:00
:config
2017-01-17 12:15:48 +08:00
;; places the git gutter outside the margins.
(setq-default fringes-outside-margins t)
2015-12-09 14:16:31 +08:00
2017-01-17 12:15:48 +08:00
;; thin fringe bitmaps
2015-12-09 14:16:31 +08:00
(define-fringe-bitmap 'git-gutter-fr:added
[224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224]
2015-12-09 14:16:31 +08:00
nil nil 'center)
(define-fringe-bitmap 'git-gutter-fr:modified
[224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224 224]
2015-12-09 14:16:31 +08:00
nil nil 'center)
(define-fringe-bitmap 'git-gutter-fr:deleted
2016-05-21 04:56:55 +08:00
[0 0 0 0 0 0 0 0 0 0 0 0 0 128 192 224 240 248]
2015-12-09 14:16:31 +08:00
nil nil 'center)
2017-01-17 12:15:48 +08:00
;; Refreshing git-gutter on ESC and focus
2015-12-09 14:16:31 +08:00
(advice-add 'evil-force-normal-state :after 'git-gutter)
2017-01-17 12:15:48 +08:00
(add-hook 'focus-in-hook 'git-gutter:update-all-windows))
2015-12-09 14:16:31 +08:00
2017-01-17 12:15:48 +08:00
(package! magit
:commands magit-status
:config
;; Prevent magit + evil-snipe conflicts
2016-06-05 11:33:55 +08:00
(add-hook 'magit-mode-hook 'turn-off-evil-snipe-override-mode)
(map! :map magit-mode-map
;; Don't let Tab binding in my-bindings conflict with Tab in magit
:m "<tab>" 'magit-section-toggle
;; Don't interfere with window movement keys
:nv "C-j" nil
:nv "C-k" nil))
2017-01-17 12:15:48 +08:00
(package! evil-magit :after magit)
(package! browse-at-remote
:commands (browse-at-remote/browse browse-at-remote/get-url))
NARF v0.7.0 vcs: + +git-gutter to conf-modes; -git-gutter from evil-insert-state-exit + switch github-browse-file for browse-at-remote + fix <leader>ob; add <leader>d[./sr] vc bindings + vc-annotate bindings and initial state Workgroups2 integration: + don't mess with buffers (speeds up emacs a lot!) + unicode numbers in display + single display function + remember workgroup uid instead (and smarter :tabrename) + clean up after wg update Org-mode + give highlight precedence to links in org-mode + enable encryption + config clean up + use different font for org + exclude attachments in recentf + redo latex and inline-image config + add narf/org-open-notes + update file templates for org CRM Mode-line + polish mode-line + decouple from spaceline-segments.el + refactor narf|spaceline-env-update + add macro-recording and buffer-size indicators to mode-line + python: '2>&1' in env-command + flycheck fringe indicator: change to arrow Aesthetics + update narf-dark-theme + add narf-minibuffer-active face + change writing indicator in writing-mode Misc + fix whitespace in display-startup-echo-area-message + reset fonts for more unicode characters + custom imenu entries + helm-imenu fontification + enable yascroll-bar in REPLs + reorganize my-commands.el + force quit iedit on ESC in normal mode + update snippets submodule + remove ido init (helm handles it all) [EXPERIMENTAL] + back to Terminus(TTF) font + popwin: update config for git-gutter and vc-diff windows + highlight :g[lobal] and :al[ign] matches + decouple narf/get-buffers+narf/get-all-buffers from wg-mess-with-buffer-list + fix narf/helm-buffers-dwim (add interactive form)
2015-12-12 05:51:04 +08:00
(after! vc-annotate
2016-05-21 07:08:02 +08:00
(evil-set-initial-state 'vc-annotate-mode 'normal)
NARF v0.7.0 vcs: + +git-gutter to conf-modes; -git-gutter from evil-insert-state-exit + switch github-browse-file for browse-at-remote + fix <leader>ob; add <leader>d[./sr] vc bindings + vc-annotate bindings and initial state Workgroups2 integration: + don't mess with buffers (speeds up emacs a lot!) + unicode numbers in display + single display function + remember workgroup uid instead (and smarter :tabrename) + clean up after wg update Org-mode + give highlight precedence to links in org-mode + enable encryption + config clean up + use different font for org + exclude attachments in recentf + redo latex and inline-image config + add narf/org-open-notes + update file templates for org CRM Mode-line + polish mode-line + decouple from spaceline-segments.el + refactor narf|spaceline-env-update + add macro-recording and buffer-size indicators to mode-line + python: '2>&1' in env-command + flycheck fringe indicator: change to arrow Aesthetics + update narf-dark-theme + add narf-minibuffer-active face + change writing indicator in writing-mode Misc + fix whitespace in display-startup-echo-area-message + reset fonts for more unicode characters + custom imenu entries + helm-imenu fontification + enable yascroll-bar in REPLs + reorganize my-commands.el + force quit iedit on ESC in normal mode + update snippets submodule + remove ido init (helm handles it all) [EXPERIMENTAL] + back to Terminus(TTF) font + popwin: update config for git-gutter and vc-diff windows + highlight :g[lobal] and :al[ign] matches + decouple narf/get-buffers+narf/get-all-buffers from wg-mess-with-buffer-list + fix narf/helm-buffers-dwim (add interactive form)
2015-12-12 05:51:04 +08:00
(evil-set-initial-state '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))
2017-01-17 12:15:48 +08:00
;;
;; Defuns
;;
(defun doom-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))))
(defun doom/git-browse-issues ()
"Open the github issues page for current repo."
(interactive)
(if-let (root (doom-git-root))
(browse-url (concat root "/issues"))
(user-error "No git root found!")))
(evil-define-command doom:git-browse (&optional bang)
"Open the website for the current (or specified) version controlled FILE. If
BANG, then copy it to clipboard. 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
(if bang
(message "Url copied to clipboard: %s" (kill-new url))
(browse-url url)))))
2015-06-15 15:05:52 +08:00
(provide 'core-vcs)
;;; core-vcs.el ends here