reorganize folding text
This commit is contained in:
parent
38c65ee15e
commit
be6666bb84
@ -8,7 +8,7 @@ if exists('g:loaded_signify') || !has('signs') || &cp
|
||||
endif
|
||||
let g:loaded_signify = 1
|
||||
|
||||
" Default values {{{1
|
||||
" Init: values {{{1
|
||||
let s:sy = {} " the main data structure
|
||||
let s:line_highlight = 0 " disable line highlighting
|
||||
let s:other_signs_line_numbers = {}
|
||||
@ -35,37 +35,7 @@ else
|
||||
let s:difftool = 'diff'
|
||||
endif
|
||||
|
||||
" Default mappings {{{1
|
||||
if !maparg('[c', 'n')
|
||||
nnoremap <silent> ]c :<c-u>execute v:count .'SignifyJumpToNextHunk'<cr>
|
||||
nnoremap <silent> [c :<c-u>execute v:count .'SignifyJumpToPrevHunk'<cr>
|
||||
endif
|
||||
|
||||
if exists('g:signify_mapping_next_hunk')
|
||||
execute 'nnoremap <silent> '. g:signify_mapping_next_hunk .' :<c-u>execute v:count ."SignifyJumpToNextHunk"<cr>'
|
||||
else
|
||||
nnoremap <silent> <leader>gj :<c-u>execute v:count .'SignifyJumpToNextHunk'<cr>
|
||||
endif
|
||||
|
||||
if exists('g:signify_mapping_prev_hunk')
|
||||
execute 'nnoremap <silent> '. g:signify_mapping_prev_hunk .' :<c-u>execute v:count ."SignifyJumpToPrevHunk"<cr>'
|
||||
else
|
||||
nnoremap <silent> <leader>gk :<c-u>execute v:count .'SignifyJumpToPrevHunk'<cr>
|
||||
endif
|
||||
|
||||
if exists('g:signify_mapping_toggle_highlight')
|
||||
execute 'nnoremap <silent> '. g:signify_mapping_toggle_highlight .' :SignifyToggleHighlight<cr>'
|
||||
else
|
||||
nnoremap <silent> <leader>gh :SignifyToggleHighlight<cr>
|
||||
endif
|
||||
|
||||
if exists('g:signify_mapping_toggle')
|
||||
execute 'nnoremap <silent> '. g:signify_mapping_toggle .' :SignifyToggle<cr>'
|
||||
else
|
||||
nnoremap <silent> <leader>gt :SignifyToggle<cr>
|
||||
endif
|
||||
|
||||
" Default signs {{{1
|
||||
" Init: signs {{{1
|
||||
if exists('g:signify_sign_add')
|
||||
execute 'sign define SignifyAdd text='. g:signify_sign_add .' texthl=SignifyAdd linehl=none'
|
||||
else
|
||||
@ -98,7 +68,7 @@ endif
|
||||
|
||||
sign define SignifyPlaceholder text=. texthl=SignifyChange linehl=none
|
||||
|
||||
" Initial stuff {{{1
|
||||
" Init: autocmds {{{1
|
||||
augroup signify
|
||||
autocmd!
|
||||
|
||||
@ -119,12 +89,43 @@ augroup signify
|
||||
autocmd BufEnter,BufWritePost * call s:start(s:path)
|
||||
augroup END
|
||||
|
||||
" Init: commands {{{1
|
||||
com! -nargs=0 -bar SignifyToggle call s:toggle_signify()
|
||||
com! -nargs=0 -bar SignifyToggleHighlight call s:toggle_line_highlighting()
|
||||
com! -nargs=0 -bar -count SignifyJumpToNextHunk call s:jump_to_next_hunk(<count>)
|
||||
com! -nargs=0 -bar -count SignifyJumpToPrevHunk call s:jump_to_prev_hunk(<count>)
|
||||
|
||||
" Functions -> s:start() {{{1
|
||||
" Init: mappings {{{1
|
||||
if !maparg('[c', 'n')
|
||||
nnoremap <silent> ]c :<c-u>execute v:count .'SignifyJumpToNextHunk'<cr>
|
||||
nnoremap <silent> [c :<c-u>execute v:count .'SignifyJumpToPrevHunk'<cr>
|
||||
endif
|
||||
|
||||
if exists('g:signify_mapping_next_hunk')
|
||||
execute 'nnoremap <silent> '. g:signify_mapping_next_hunk .' :<c-u>execute v:count ."SignifyJumpToNextHunk"<cr>'
|
||||
else
|
||||
nnoremap <silent> <leader>gj :<c-u>execute v:count .'SignifyJumpToNextHunk'<cr>
|
||||
endif
|
||||
|
||||
if exists('g:signify_mapping_prev_hunk')
|
||||
execute 'nnoremap <silent> '. g:signify_mapping_prev_hunk .' :<c-u>execute v:count ."SignifyJumpToPrevHunk"<cr>'
|
||||
else
|
||||
nnoremap <silent> <leader>gk :<c-u>execute v:count .'SignifyJumpToPrevHunk'<cr>
|
||||
endif
|
||||
|
||||
if exists('g:signify_mapping_toggle_highlight')
|
||||
execute 'nnoremap <silent> '. g:signify_mapping_toggle_highlight .' :SignifyToggleHighlight<cr>'
|
||||
else
|
||||
nnoremap <silent> <leader>gh :SignifyToggleHighlight<cr>
|
||||
endif
|
||||
|
||||
if exists('g:signify_mapping_toggle')
|
||||
execute 'nnoremap <silent> '. g:signify_mapping_toggle .' :SignifyToggle<cr>'
|
||||
else
|
||||
nnoremap <silent> <leader>gt :SignifyToggle<cr>
|
||||
endif
|
||||
|
||||
" Function: s:start {{{1
|
||||
function! s:start(path) abort
|
||||
if exists('b:signmode') && b:signmode
|
||||
execute 'sign place 99999 line=1 name=SignifyPlaceholder file='. a:path
|
||||
@ -174,7 +175,7 @@ function! s:start(path) abort
|
||||
let s:sy[a:path].id_top = (s:id_top - 1)
|
||||
endfunction
|
||||
|
||||
" Functions -> s:stop() {{{1
|
||||
" Function: s:stop {{{1
|
||||
function! s:stop(path) abort
|
||||
if !has_key(s:sy, a:path)
|
||||
return
|
||||
@ -193,7 +194,7 @@ function! s:stop(path) abort
|
||||
augroup END
|
||||
endfunction
|
||||
|
||||
" Functions -> s:sign_get_others() {{{1
|
||||
" Function: s:sign_get_others {{{1
|
||||
function! s:sign_get_others(path) abort
|
||||
redir => signlist
|
||||
silent! execute 'sign place file='. a:path
|
||||
@ -205,7 +206,7 @@ function! s:sign_get_others(path) abort
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
" Functions -> s:sign_set() {{{1
|
||||
" Function: s:sign_set {{{1
|
||||
function! s:sign_set(lnum, type, path)
|
||||
" Preserve non-signify signs
|
||||
if !s:sign_overwrite && has_key(s:other_signs_line_numbers, a:lnum)
|
||||
@ -218,7 +219,7 @@ function! s:sign_set(lnum, type, path)
|
||||
let s:id_top += 1
|
||||
endfunction
|
||||
|
||||
" Functions -> s:sign_remove_all() {{{1
|
||||
" Function: s:sign_remove_all {{{1
|
||||
function! s:sign_remove_all(path) abort
|
||||
for id in s:sy[a:path].ids
|
||||
execute 'sign unplace '. id
|
||||
@ -229,7 +230,7 @@ function! s:sign_remove_all(path) abort
|
||||
let s:sy[a:path].ids = []
|
||||
endfunction
|
||||
|
||||
" Functions -> s:repo_detect() {{{1
|
||||
" Function: s:repo_detect {{{1
|
||||
function! s:repo_detect(path) abort
|
||||
for type in s:vcs_list
|
||||
let diff = s:repo_get_diff_{type}(a:path)
|
||||
@ -241,7 +242,7 @@ function! s:repo_detect(path) abort
|
||||
return [ '', '' ]
|
||||
endfunction
|
||||
|
||||
" Functions -> s:repo_get_diff_git {{{1
|
||||
" Function: s:repo_get_diff_git {{{1
|
||||
function! s:repo_get_diff_git(path) abort
|
||||
if executable('git')
|
||||
let diff = system('cd '. s:escape(fnamemodify(a:path, ':h')) .' && git diff --no-ext-diff -U0 -- '. s:escape(a:path))
|
||||
@ -249,7 +250,7 @@ function! s:repo_get_diff_git(path) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Functions -> s:repo_get_diff_hg {{{1
|
||||
" Function: s:repo_get_diff_hg {{{1
|
||||
function! s:repo_get_diff_hg(path) abort
|
||||
if executable('hg')
|
||||
let diff = system('hg diff --nodates -U0 -- '. s:escape(a:path))
|
||||
@ -257,7 +258,7 @@ function! s:repo_get_diff_hg(path) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Functions -> s:repo_get_diff_svn {{{1
|
||||
" Function: s:repo_get_diff_svn {{{1
|
||||
function! s:repo_get_diff_svn(path) abort
|
||||
if executable('svn')
|
||||
let diff = system('svn diff --diff-cmd '. s:difftool .' -x -U0 -- '. s:escape(a:path))
|
||||
@ -265,7 +266,7 @@ function! s:repo_get_diff_svn(path) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Functions -> s:repo_get_diff_bzr {{{1
|
||||
" Function: s:repo_get_diff_bzr {{{1
|
||||
function! s:repo_get_diff_bzr(path) abort
|
||||
if executable('bzr')
|
||||
let diff = system('bzr diff --using '. s:difftool .' --diff-options=-U0 -- '. s:escape(a:path))
|
||||
@ -273,7 +274,7 @@ function! s:repo_get_diff_bzr(path) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Functions -> s:repo_get_diff_darcs {{{1
|
||||
" Function: s:repo_get_diff_darcs {{{1
|
||||
function! s:repo_get_diff_darcs(path) abort
|
||||
if executable('darcs')
|
||||
let diff = system('cd '. s:escape(fnamemodify(a:path, ':h')) .' && darcs diff --no-pause-for-gui --diff-command="'. s:difftool .' -U0 %1 %2" -- '. s:escape(a:path))
|
||||
@ -281,7 +282,7 @@ function! s:repo_get_diff_darcs(path) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Functions -> s:repo_get_diff_cvs {{{1
|
||||
" Function: s:repo_get_diff_cvs {{{1
|
||||
function! s:repo_get_diff_cvs(path) abort
|
||||
if executable('cvs')
|
||||
let diff = system('cd '. s:escape(fnamemodify(a:path, ':h')) .' && cvs diff -U0 -- '. s:escape(fnamemodify(a:path, ':t')))
|
||||
@ -289,7 +290,7 @@ function! s:repo_get_diff_cvs(path) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Functions -> s:repo_get_diff_rcs {{{1
|
||||
" Function: s:repo_get_diff_rcs {{{1
|
||||
function! s:repo_get_diff_rcs(path) abort
|
||||
if executable('rcs')
|
||||
let diff = system('rcsdiff -U0 '. s:escape(a:path) .' 2>/dev/null')
|
||||
@ -297,7 +298,7 @@ function! s:repo_get_diff_rcs(path) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Functions -> s:repo_process_diff() {{{1
|
||||
" Function: s:repo_process_diff {{{1
|
||||
function! s:repo_process_diff(path, diff) abort
|
||||
" Determine where we have to put our signs.
|
||||
for line in filter(split(a:diff, '\n'), 'v:val =~ "^@@"')
|
||||
@ -351,7 +352,7 @@ function! s:repo_process_diff(path, diff) abort
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
" Functions -> s:colors_set() {{{1
|
||||
" Function: s:colors_set {{{1
|
||||
function! s:colors_set() abort
|
||||
if has('gui_running')
|
||||
if exists('g:signify_sign_color_guibg')
|
||||
@ -438,7 +439,7 @@ function! s:colors_set() abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Functions -> s:toggle_signify() {{{1
|
||||
" Function: s:toggle_signify {{{1
|
||||
function! s:toggle_signify() abort
|
||||
if empty(s:path)
|
||||
echo 'signify: I cannot sy empty buffers!'
|
||||
@ -458,7 +459,7 @@ function! s:toggle_signify() abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Functions -> s:toggle_line_highlighting() {{{1
|
||||
" Function: s:toggle_line_highlighting {{{1
|
||||
function! s:toggle_line_highlighting() abort
|
||||
if !has_key(s:sy, s:path)
|
||||
echo 'signify: I cannot detect any changes!'
|
||||
@ -489,30 +490,7 @@ function! s:toggle_line_highlighting() abort
|
||||
call s:start(s:path)
|
||||
endfunction
|
||||
|
||||
" Functions -> s:jump_to_next_hunk() {{{1
|
||||
function! s:jump_to_next_hunk(count)
|
||||
if !has_key(s:sy, s:path) || s:sy[s:path].id_jump == -1
|
||||
echo 'signify: I cannot detect any changes!'
|
||||
return
|
||||
endif
|
||||
|
||||
if s:sy[s:path].last_jump_was_next == 0
|
||||
let s:sy[s:path].id_jump += 2
|
||||
endif
|
||||
|
||||
let s:sy[s:path].id_jump += a:count ? (a:count - 1) : 0
|
||||
|
||||
if s:sy[s:path].id_jump > s:sy[s:path].id_top
|
||||
let s:sy[s:path].id_jump = s:sy[s:path].ids[0]
|
||||
endif
|
||||
|
||||
execute 'sign jump '. s:sy[s:path].id_jump .' file='. s:path
|
||||
|
||||
let s:sy[s:path].id_jump += 1
|
||||
let s:sy[s:path].last_jump_was_next = 1
|
||||
endfunction
|
||||
|
||||
" Functions -> s:jump_to_prev_hunk() {{{1
|
||||
" Function: s:jump_to_prev_hunk {{{1
|
||||
function! s:jump_to_prev_hunk(count)
|
||||
if !has_key(s:sy, s:path) || s:sy[s:path].id_jump == -1
|
||||
echo 'signify: I cannot detect any changes!'
|
||||
@ -535,7 +513,7 @@ function! s:jump_to_prev_hunk(count)
|
||||
let s:sy[s:path].last_jump_was_next = 0
|
||||
endfunction
|
||||
|
||||
" Functions -> s:s:escape() {{{1
|
||||
" Function: s:escape {{{1
|
||||
function s:escape(path) abort
|
||||
if exists('+shellslash')
|
||||
let old_ssl = &shellslash
|
||||
@ -551,7 +529,7 @@ function s:escape(path) abort
|
||||
return path
|
||||
endfunction
|
||||
|
||||
" Functions -> SignifyDebugListActiveBuffers() {{{1
|
||||
" Function: SignifyDebugListActiveBuffers() {{{1
|
||||
function! SignifyDebugListActiveBuffers() abort
|
||||
if empty(s:sy)
|
||||
echo 'No active buffers!'
|
||||
|
Loading…
x
Reference in New Issue
Block a user