From 83ace2014a626c6348359b5e27b9ac90c5946a1d Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Mon, 21 Jul 2014 16:36:16 +0200 Subject: [PATCH] Suppress signs when there are more than 500. --- README.mkd | 5 +++++ autoload/gitgutter.vim | 6 ++++++ autoload/gitgutter/utility.vim | 6 ++++++ plugin/gitgutter.vim | 1 + 4 files changed, 18 insertions(+) diff --git a/README.mkd b/README.mkd index 4b37292..54403db 100644 --- a/README.mkd +++ b/README.mkd @@ -80,6 +80,11 @@ Note that if you have line highlighting on and signs off, you will have an empty If you switch off both line highlighting and signs, you won't see the sign column. That is unless you have set `let g:gitgutter_sign_column_always = 1` so it's always there. +To keep your Vim snappy, vim-gitgutter will suppress itself when a file has more than 500 changes. As soon as the number of changes falls below the limit vim-gitgutter will show the signs again. You can configure the threshold with: + +```viml +let g:gitgutter_max_signs = 500 " default value +``` #### Hunks diff --git a/autoload/gitgutter.vim b/autoload/gitgutter.vim index 63a241a..3391734 100644 --- a/autoload/gitgutter.vim +++ b/autoload/gitgutter.vim @@ -23,6 +23,12 @@ function! gitgutter#process_buffer(file, realtime) call gitgutter#hunk#set_hunks(gitgutter#diff#parse_diff(diff)) let modified_lines = gitgutter#diff#process_hunks(gitgutter#hunk#hunks()) + if len(modified_lines) > g:gitgutter_max_signs + call gitgutter#utility#warn('exceeded maximum number of signs (configured by g:gitgutter_max_signs).') + call gitgutter#sign#clear_signs(a:file) + return + endif + if g:gitgutter_signs || g:gitgutter_highlight_lines call gitgutter#sign#update_signs(a:file, modified_lines) endif diff --git a/autoload/gitgutter/utility.vim b/autoload/gitgutter/utility.vim index 0137094..3a057eb 100644 --- a/autoload/gitgutter/utility.vim +++ b/autoload/gitgutter/utility.vim @@ -2,6 +2,12 @@ let s:file = '' let s:using_xolox_shell = -1 let s:exit_code = 0 +function! gitgutter#utility#warn(message) + echohl WarningMsg + echomsg 'vim-gitgutter: ' . a:message + echohl None + let b:warningmsg = a:message +endfunction function! gitgutter#utility#is_active() return g:gitgutter_enabled && gitgutter#utility#exists_file() diff --git a/plugin/gitgutter.vim b/plugin/gitgutter.vim index a60d8ba..e559c85 100644 --- a/plugin/gitgutter.vim +++ b/plugin/gitgutter.vim @@ -28,6 +28,7 @@ function! s:set(var, default) endfunction call s:set('g:gitgutter_enabled', 1) +call s:set('g:gitgutter_max_signs', 500) call s:set('g:gitgutter_signs', 1) call s:set('g:gitgutter_highlight_lines', 0) call s:set('g:gitgutter_sign_column_always', 0)