git.kak (2691B)
1 hook global BufCreate .*(COMMIT_EDITMSG|MERGE_MSG) %{ 2 set-option buffer filetype git-commit 3 } 4 5 hook global BufCreate .*/NOTES_EDITMSG %{ 6 set-option buffer filetype git-notes 7 } 8 9 hook global BufCreate .*(\.git(config|modules)|git/config) %{ 10 set-option buffer filetype ini 11 } 12 13 hook global BufCreate .*\.gitignore %{ 14 set-option buffer filetype git-ignore 15 } 16 17 hook global BufCreate .*git-rebase-todo %{ 18 set-option buffer filetype git-rebase 19 } 20 21 hook global WinSetOption filetype=git-(commit|ignore|notes|rebase) %{ 22 require-module "git-%val{hook_param_capture_1}" 23 } 24 25 hook -group git-commit-highlight global WinSetOption filetype=git-commit %{ 26 add-highlighter window/git-commit ref git-commit 27 hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/git-commit } 28 } 29 30 hook -group git-ignore-highlight global WinSetOption filetype=git-ignore %{ 31 add-highlighter window/git-ignore ref git-ignore 32 hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/git-ignore } 33 } 34 35 hook -group git-notes-highlight global WinSetOption filetype=git-notes %{ 36 add-highlighter window/git-notes ref git-notes 37 hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/git-notes } 38 } 39 40 hook -group git-rebase-highlight global WinSetOption filetype=git-rebase %{ 41 add-highlighter window/git-rebase ref git-rebase 42 hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/git-rebase } 43 } 44 45 provide-module git-commit %{ 46 require-module diff 47 add-highlighter shared/git-commit regions 48 add-highlighter shared/git-commit/diff region '^diff --git' '^(?=diff --git)' ref diff # highlight potential diffs from the -v option 49 add-highlighter shared/git-commit/comments region ^# $ group 50 add-highlighter shared/git-commit/comments/ fill comment 51 add-highlighter shared/git-commit/comments/ regex "\b(?:(modified)|(deleted)|(new file)|(renamed|copied)):(\N*)$" 1:yellow 2:red 3:green 4:blue 5:magenta 52 } 53 54 provide-module git-ignore %{ 55 add-highlighter shared/git-ignore group 56 add-highlighter shared/git-ignore/glob regex '(?<!\\)(?:\\\\)*\K(\*\*?|\?|\[.*?(?<!\\)(?:\\\\)*\])' 0:operator 57 add-highlighter shared/git-ignore/negate regex '^!' 0:operator 58 add-highlighter shared/git-ignore/comments regex '^#.*?$' 0:comment 59 } 60 61 provide-module git-notes %{ 62 add-highlighter shared/git-notes regex ^#\N*$ 0:comment 63 } 64 65 provide-module git-rebase %{ 66 add-highlighter shared/git-rebase group 67 add-highlighter shared/git-rebase/ regex "^\h*#\N*\n" 0:comment 68 add-highlighter shared/git-rebase/ regex "^(?:(pick|p)|(edit|reword|squash|fixup|exec|break|drop|label|reset|merge|[ersfxbdltm])) (\w+)" 1:keyword 2:value 3:meta 69 }