Comment code sections.

This commit is contained in:
Andy Stewart
2014-01-16 11:33:46 +01:00
parent 9e99e4d4f1
commit 811d9af7a9

View File

@@ -36,7 +36,7 @@ call highlight#define_signs()
" }}} " }}}
" Public interface {{{ " Primary functions {{{
function! GitGutterAll() function! GitGutterAll()
for buffer_id in tabpagebuflist() for buffer_id in tabpagebuflist()
@@ -81,6 +81,11 @@ function! GitGutter(file, realtime)
endfunction endfunction
command GitGutter call GitGutter(utility#current_file(), 0) command GitGutter call GitGutter(utility#current_file(), 0)
" }}}
" The plugin: enable / disable / toggle {{{
function! GitGutterDisable() function! GitGutterDisable()
let g:gitgutter_enabled = 0 let g:gitgutter_enabled = 0
call sign#clear_signs(utility#file()) call sign#clear_signs(utility#file())
@@ -104,6 +109,11 @@ function! GitGutterToggle()
endfunction endfunction
command GitGutterToggle call GitGutterToggle() command GitGutterToggle call GitGutterToggle()
" }}}
" Line highlights: enable / disable / toggle {{{
function! GitGutterLineHighlightsDisable() function! GitGutterLineHighlightsDisable()
let g:gitgutter_highlight_lines = 0 let g:gitgutter_highlight_lines = 0
call highlight#define_sign_line_highlights() call highlight#define_sign_line_highlights()
@@ -125,16 +135,6 @@ function! GitGutterLineHighlightsToggle()
endfunction endfunction
command GitGutterLineHighlightsToggle call GitGutterLineHighlightsToggle() command GitGutterLineHighlightsToggle call GitGutterLineHighlightsToggle()
function! GitGutterNextHunk(count)
if utility#is_active()
let current_line = line('.')
let hunk_count = 0
for hunk in s:hunks
if hunk[2] > current_line
let hunk_count += 1
if hunk_count == a:count
execute 'normal!' hunk[2] . 'G'
break
" }}} " }}}
@@ -167,6 +167,16 @@ command GitGutterSignsToggle call GitGutterSignsToggle()
" Hunks: jump to next/previous {{{ " Hunks: jump to next/previous {{{
function! GitGutterNextHunk(count)
if utility#is_active()
let current_line = line('.')
let hunk_count = 0
for hunk in s:hunks
if hunk[2] > current_line
let hunk_count += 1
if hunk_count == a:count
execute 'normal!' hunk[2] . 'G'
break
endif endif
endif endif
endfor endfor
@@ -191,6 +201,11 @@ function! GitGutterPrevHunk(count)
endfunction endfunction
command -count=1 GitGutterPrevHunk call GitGutterPrevHunk(<count>) command -count=1 GitGutterPrevHunk call GitGutterPrevHunk(<count>)
" }}}
" Hunks: stage/revert {{{
function! GitGutterStageHunk() function! GitGutterStageHunk()
if utility#is_active() if utility#is_active()
" Ensure the working copy of the file is up to date. " Ensure the working copy of the file is up to date.
@@ -253,6 +268,11 @@ function! GitGutterRevertHunk()
endfunction endfunction
command GitGutterRevertHunk call GitGutterRevertHunk() command GitGutterRevertHunk call GitGutterRevertHunk()
" }}}
" Hunk stats {{{
" Returns the git-diff hunks for the file or an empty list if there " Returns the git-diff hunks for the file or an empty list if there
" aren't any hunks. " aren't any hunks.
" "
@@ -281,6 +301,10 @@ function! GitGutterGetHunkSummary()
return hunk#summary() return hunk#summary()
endfunction endfunction
" }}}
" Maps {{{
nnoremap <silent> <expr> <Plug>GitGutterNextHunk &diff ? ']c' : ":\<C-U>execute v:count1 . 'GitGutterNextHunk'\<CR>" nnoremap <silent> <expr> <Plug>GitGutterNextHunk &diff ? ']c' : ":\<C-U>execute v:count1 . 'GitGutterNextHunk'\<CR>"
nnoremap <silent> <expr> <Plug>GitGutterPrevHunk &diff ? '[c' : ":\<C-U>execute v:count1 . 'GitGutterPrevHunk'\<CR>" nnoremap <silent> <expr> <Plug>GitGutterPrevHunk &diff ? '[c' : ":\<C-U>execute v:count1 . 'GitGutterPrevHunk'\<CR>"
@@ -307,6 +331,10 @@ if g:gitgutter_map_keys
endif endif
endif endif
" }}}
" Autocommands {{{
augroup gitgutter augroup gitgutter
autocmd! autocmd!
@@ -341,4 +369,5 @@ augroup END
" }}} " }}}
" vim:set et sw=2 fdm=marker: " vim:set et sw=2 fdm=marker: