From 8345c35770ffc6fc4088c36406d1e24170aabcc6 Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Mon, 23 Mar 2015 11:36:34 +0100 Subject: [PATCH] Stop early when file is in .git directory. --- autoload/gitgutter/utility.vim | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/autoload/gitgutter/utility.vim b/autoload/gitgutter/utility.vim index 60d62f1..c97937a 100644 --- a/autoload/gitgutter/utility.vim +++ b/autoload/gitgutter/utility.vim @@ -9,8 +9,14 @@ function! gitgutter#utility#warn(message) let v:warningmsg = a:message endfunction +" Returns truthy when the buffer's file should be processed; and falsey when it shouldn't. +" This function does not and should not make any system calls. function! gitgutter#utility#is_active() - return g:gitgutter_enabled && gitgutter#utility#exists_file() + return g:gitgutter_enabled && gitgutter#utility#exists_file() && gitgutter#utility#not_git_dir() +endfunction + +function! gitgutter#utility#not_git_dir() + return gitgutter#utility#full_path_to_directory_of_file() !~ '\.git\([/\\].*\)\?$' endfunction " A replacement for the built-in `shellescape(arg)`. @@ -51,6 +57,10 @@ function! gitgutter#utility#extension() return fnamemodify(s:file, ':e') endfunction +function! gitgutter#utility#full_path_to_directory_of_file() + return fnamemodify(s:file, ':p:h') +endfunction + function! gitgutter#utility#directory_of_file() return fnamemodify(s:file, ':h') endfunction