diff-hl -> git-gutter-fringe

This commit is contained in:
Henrik Lissner 2015-12-09 01:16:31 -05:00
parent 9a9bce7260
commit ae391a3356
3 changed files with 53 additions and 9 deletions

3
Cask
View file

@ -87,7 +87,8 @@
(depends-on "neotree") (depends-on "neotree")
;; VCS --- core/core-vcs.el ;; VCS --- core/core-vcs.el
(depends-on "diff-hl") ;; (depends-on "diff-hl")
(depends-on "git-gutter-fringe")
(depends-on "gitconfig-mode") (depends-on "gitconfig-mode")
(depends-on "gitignore-mode") (depends-on "gitignore-mode")
(depends-on "github-browse-file") (depends-on "github-browse-file")

View file

@ -9,16 +9,64 @@
"/\\.git/info/exclude$" "/\\.git/info/exclude$"
"/git/ignore$")) "/git/ignore$"))
(use-package github-browse-file
:commands (github-browse-file github-browse-file-blame)
:init
(evil-define-command narf:github-browse-file (&optional bang)
(interactive "<!>")
(if bang (github-browse-file-blame) (github-browse-file))))
(use-package git-gutter
:commands (git-gutter-mode narf/vcs-next-hunk narf/vcs-prev-hunk
narf/vcs-show-hunk narf/vcs-stage-hunk narf/vcs-revert-hunk)
:init
(add-hook! (text-mode prog-mode) 'git-gutter-mode)
:config
(require 'git-gutter-fringe)
(setq git-gutter:update-interval 2)
(defalias 'narf/vcs-next-hunk 'git-gutter:next-hunk)
(defalias 'narf/vcs-prev-hunk 'git-gutter:previous-hunk)
(defalias 'narf/vcs-show-hunk 'git-gutter:popup-hunk)
(defalias 'narf/vcs-stage-hunk 'git-gutter:stage-hunk)
(defalias 'narf/vcs-revert-hunk 'git-gutter:revert-hunk)
(define-fringe-bitmap 'git-gutter-fr:added
[240 240 240 240 240 240 240 240 240 240 240 240 240 240]
nil nil 'center)
(define-fringe-bitmap 'git-gutter-fr:modified
[240 240 240 240 240 240 240 240 240 240 240 240 240 240]
nil nil 'center)
(define-fringe-bitmap 'git-gutter-fr:deleted
[0 0 0 128 192 224 240 248]
nil nil 'center)
(advice-add 'evil-force-normal-state :after 'git-gutter)
(add-hook! focus-in 'git-gutter:update-all-windows)
(add-hook! evil-insert-state-exit 'git-gutter))
(use-package diff-hl (use-package diff-hl
:disabled t
:init :init
(setq diff-hl-draw-borders nil (setq diff-hl-draw-borders nil
diff-hl-fringe-bmp-function 'narf-diff-hl-fringe-bmp) diff-hl-fringe-bmp-function 'narf-diff-hl-fringe-bmp)
:config :config
(defalias narf/vcs-next-hunk 'diff-hl-next-hunk)
(defalias narf/vcs-prev-hunk 'diff-hl-previous-hunk)
;; (defalias narf/vcs-show-hunk
;; (defalias narf/vcs-stage-hunk ...)
(defalias narf/vcs-revert-hunk 'diff-hl-revert-hunk)
(defun narf-diff-hl-fringe-bmp (type _pos) (defun narf-diff-hl-fringe-bmp (type _pos)
(if (eq type 'delete) (if (eq type 'delete)
'narf--diff-hl-bitmap-del 'narf--diff-hl-bitmap-del
'narf--diff-hl-bitmap)) 'narf--diff-hl-bitmap))
(map! :map diff-mode-shared-map
:n "RET" 'diff-goto-source)
(define-fringe-bitmap 'narf--diff-hl-bitmap (define-fringe-bitmap 'narf--diff-hl-bitmap
[240 240 240 240 240 240 240 240 240 240 240 240 240 240] [240 240 240 240 240 240 240 240 240 240 240 240 240 240]
nil nil 'center) nil nil 'center)
@ -28,12 +76,5 @@
(global-diff-hl-mode 1)) (global-diff-hl-mode 1))
(use-package github-browse-file
:commands (narf:github-browse-file github-browse-file github-browse-file-blame)
:config
(evil-define-command narf:github-browse-file (&optional bang)
(interactive "<!>")
(if bang (github-browse-file-blame) (github-browse-file))))
(provide 'core-vcs) (provide 'core-vcs)
;;; core-vcs.el ends here ;;; core-vcs.el ends here

View file

@ -19,7 +19,6 @@
(exmap "en[ew]" 'narf:file-create) (exmap "en[ew]" 'narf:file-create)
(exmap "full[scr]" 'narf:toggle-fullscreen) (exmap "full[scr]" 'narf:toggle-fullscreen)
(exmap "fullw[rite]" 'narf:toggle-write-mode) (exmap "fullw[rite]" 'narf:toggle-write-mode)
(exmap "bl[ame]" 'narf:github-browse-file)
(exmap "http" 'httpd-start) (exmap "http" 'httpd-start)
(exmap "ini" 'narf:ido-find-file-in-emacsd) (exmap "ini" 'narf:ido-find-file-in-emacsd)
(exmap "k[ill]" 'kill-this-buffer) ; Kill current buffer (exmap "k[ill]" 'kill-this-buffer) ; Kill current buffer
@ -54,6 +53,9 @@
(exmap "proj[ect]" 'narf:org-crm-project) (exmap "proj[ect]" 'narf:org-crm-project)
(exmap "invo[ice]" 'narf:org-crm-invoice) (exmap "invo[ice]" 'narf:org-crm-invoice)
;; GIT
(exmap "bl[ame]" 'narf:github-browse-file)
(after! flycheck (after! flycheck
(exmap "er[rors]" (λ (flycheck-buffer) (flycheck-list-errors)))) (exmap "er[rors]" (λ (flycheck-buffer) (flycheck-list-errors))))