about summary refs log tree commit diff stats
path: root/.emacs.d/lisp/init-git.el
blob: 8ab69036b3c86b996f9810e10fc2cb4ec9d50aa6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
;;; init-git.el --- VCS/Git Configuration File -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:

(use-package ediff
  :custom
  (ediff-setup-windows-plain 'ediff-setup-windows-plain))

(use-package diff-hl
  :config
  (global-diff-hl-mode +1)
  :hook
  (dired-mode . diff-hl-dired-mode)
  (magit-post-refresh . diff-hl-magit-post-refresh))

(use-package gitconfig)
(use-package gitignore-mode)
(use-package gist)
(use-package git-timemachine)

(use-package magit
  :after key-chord
  :bind
  ("C-c g" . magit-file-dispatch)
  ("C-c C-g" . magit-dispatch)
  :config
  (defun my/magit-set-upstream ()
    (interactive)
    (magit-shell-command-topdir "git upstream"))
  ;; update stale git info on the modeline (based on code removed from doom modeline)
  (defun my/magit-refresh-state ()
    (interactive)
    (dolist (buf (buffer-list))
      (when (and (not (buffer-modified-p buf))
                 (buffer-file-name buf)
                 (file-exists-p (buffer-file-name buf))
                 (file-in-directory-p (buffer-file-name buf) (magit-toplevel)))
        (with-current-buffer buf
          (vc-refresh-state)))))
  (key-chord-define-global "UU" 'my/magit-set-upstream)
  (key-chord-define-global "RR" 'my/magit-refresh-state)
  :custom
  (magit-display-buffer-function #'magit-display-buffer-fullframe-status-topleft-v1)
  (magit-diff-refine-hunk 'all)
  (magit-diff-paint-whitespace-lines 'all)
  (magit-diff-refine-ignore-whitespace nil)
  (magit-diff-highlight-trailing t))

(use-package forge
  :after magit)

(use-package git-gutter
  :diminish
  :bind
  ("C-c j g" . git-gutter-mode)
  ("C-c j S-g" . git-gutter)
  ("C-c j n" . git-gutter:next-hunk)
  ("C-c j p" . git-gutter:previous-hunk)
  ("C-c j r" . git-gutter:revert-hunk)
  ("C-c j d" . git-gutter:popup-hunk))

(provide 'init-git)
;;; init-git.el ends here
ass="n">setColor(0,0,0) end function Text.search_next() -- search current line local pos = Lines[Cursor1.line].data:find(Search_term, Cursor1.pos) if pos then Cursor1.pos = pos end if pos == nil then for i=Cursor1.line+1,#Lines do pos = Lines[i].data:find(Search_term) if pos then Cursor1.line = i Cursor1.pos = pos break end end end if pos == nil then -- wrap around for i=1,Cursor1.line-1 do pos = Lines[i].data:find(Search_term) if pos then Cursor1.line = i Cursor1.pos = pos break end end end if pos == nil then Cursor1.line = Search_backup.cursor.line Cursor1.pos = Search_backup.cursor.pos Screen_top1.line = Search_backup.screen_top.line Screen_top1.pos = Search_backup.screen_top.pos end if Text.lt1(Cursor1, Screen_top1) or Text.lt1(Screen_bottom1, Cursor1) then Screen_top1.line = Cursor1.line local _, pos = Text.pos_at_start_of_cursor_screen_line() Screen_top1.pos = pos end end function Text.search_previous() -- search current line local pos = rfind(Lines[Cursor1.line].data, Search_term, Cursor1.pos) if pos then Cursor1.pos = pos end if pos == nil then for i=Cursor1.line-1,1,-1 do pos = rfind(Lines[i].data, Search_term) if pos then Cursor1.line = i Cursor1.pos = pos break end end end if pos == nil then -- wrap around for i=#Lines,Cursor1.line+1,-1 do pos = rfind(Lines[i].data, Search_term) if pos then Cursor1.line = i Cursor1.pos = pos break end end end if pos == nil then Cursor1.line = Search_backup.cursor.line Cursor1.pos = Search_backup.cursor.pos Screen_top1.line = Search_backup.screen_top.line Screen_top1.pos = Search_backup.screen_top.pos end if Text.lt1(Cursor1, Screen_top1) or Text.lt1(Screen_bottom1, Cursor1) then Screen_top1.line = Cursor1.line local _, pos = Text.pos_at_start_of_cursor_screen_line() Screen_top1.pos = pos end end function rfind(s, pat, i) local rs = s:reverse() local rpat = pat:reverse() if i == nil then i = #s end local ri = #s - i + 1 local rendpos = rs:find(rpat, ri) if rendpos == nil then return nil end local endpos = #s - rendpos + 1 assert (endpos >= #pat) return endpos-#pat+1 end