From a02c8793bfda7ddd386587c64246bec6aa78ff62 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Thu, 3 Mar 2016 12:50:55 +0100 Subject: [PATCH] New option: g:signify_skip_filename_pattern Closes #179. --- autoload/sy.vim | 35 +++++++++++++++++++++++++++++------ doc/signify.txt | 15 +++++++++++---- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/autoload/sy.vim b/autoload/sy.vim index b59081c..5c608a7 100644 --- a/autoload/sy.vim +++ b/autoload/sy.vim @@ -14,12 +14,7 @@ function! sy#start() abort let sy_path = resolve(expand('%:p')) - if &diff - \ || !filereadable(sy_path) - \ || (exists('g:signify_skip_filetype') && (has_key(g:signify_skip_filetype, &ft) - \ || (has_key(g:signify_skip_filetype, 'help') - \ && &bt == 'help'))) - \ || (exists('g:signify_skip_filename') && has_key(g:signify_skip_filename, sy_path)) + if s:skip(sy_path) if exists('b:sy') call sy#sign#remove_all_signs(bufnr('')) unlet! b:sy b:sy_info @@ -147,3 +142,31 @@ endfunction function! sy#buffer_is_active() return exists('b:sy') && b:sy.active endfunction + +function! s:skip(path) + if &diff || !filereadable(a:path) + return 1 + endif + + if exists('g:signify_skip_filetype') + if has_key(g:signify_skip_filetype, &filetype) + return 1 + elseif has_key(g:signify_skip_filetype, 'help') && (&buftype == 'help') + return 1 + endif + endif + + if exists('g:signify_skip_filename') && has_key(g:signify_skip_filename, a:path) + return 1 + endif + + if exists('g:signify_skip_filename_pattern') + for pattern in g:signify_skip_filename_pattern + if a:path =~ pattern + return 1 + endif + endfor + endif + + return 0 +endfunction diff --git a/doc/signify.txt b/doc/signify.txt index 1ba1332..405e24e 100644 --- a/doc/signify.txt +++ b/doc/signify.txt @@ -94,6 +94,7 @@ All available options:~ |g:signify_disable_by_default| |g:signify_skip_filetype| |g:signify_skip_filename| + |g:signify_skip_filename_pattern| |g:signify_update_on_bufenter| |g:signify_update_on_focusgained| |g:signify_line_highlight| @@ -200,17 +201,23 @@ This loads Sy, but it won't look for changes. You can toggle it anytime via :SignifyToggle. ------------------------------------------------------------------------------ - *g:signify_skip_filetype* + *g:signify_skip_filename_pattern* *g:signify_skip_filename* + *g:signify_skip_filetype* > let g:signify_skip_filetype = { 'vim': 1, 'c': 1 } let g:signify_skip_filename = { '/home/user/.vimrc': 1 } < -Don't activate the plugin for these filetypes and/or filenames. +Don't activate the plugin for these filetypes and/or filenames. Filenames have +to be absolute paths. -NOTE: Filenames have to be absolute paths. +These options must be |Dict|s for faster lookup. +> + let g:signify_skip_filename_pattern = [ 'foo.*bar', 'tmp' ] +< +Don't activate the plugin for filenames matching these patterns. -Default: Both are empty. +Default: ------------------------------------------------------------------------------ *g:signify_update_on_bufenter*