From ac847c00fe46e82e65008b6d23e1f8d89e755232 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 29 Oct 2017 23:50:23 +1300 Subject: Require minimum Vim version for background detect On an ancient Vim (6.1), the block of code checking the value of COLORFGBG does not work at all, raising the following error output: Error detected while processing function DetectBackground: line 3: E117: Unknown function: split E15: Invalid expression: split($COLORFGBG, ';') line 6: E121: Undefined variable: l:colorfgbg E15: Invalid expression: len(l:colorfgbg) ? l:colorfgbg[-1] : '' line 9: E121: Undefined variable: l:bg E15: Invalid expression: l:bg == 'default' || l:bg == '7' || l:bg == '15' line 11: :else without :if: else line 13: :endif without :if: endif I'm unlikely to need such an ancient Vim very often, so I've simply added an error guard around the block. --- vim/config/syntax.vim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'vim/config/syntax.vim') diff --git a/vim/config/syntax.vim b/vim/config/syntax.vim index 250ce924..32993572 100644 --- a/vim/config/syntax.vim +++ b/vim/config/syntax.vim @@ -7,7 +7,7 @@ if has('syntax') " Invert Vim's built-in logic for choosing dark or light backgrounds; we'll " default to choosing a dark background unless we find some reason *not* to. - if has('eval') + if has('eval') && v:version >= 701 " Wrap all this logic in a function function! DetectBackground() @@ -30,6 +30,9 @@ if has('syntax') " Cull the function just defined directly call DetectBackground() + " Ancient or cut-down Vim? Just go dark + else + set background=dark endif endif -- cgit v1.2.3