From 8b579e948d20900df4957d30448be37dfc86ccef Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 31 May 2018 10:07:26 +1200 Subject: Junk detect_background.vim and thereby autoload It's too complicated and confusing, and doesn't do enough to justify wrecking Vim's own logic for doing this sort of thing. Better to just say `:set background=dark` and be done with it. This is the only one of my inline plugins with an `autoload` file, so we can get rid of that, too. Not worth packaging/publishing to www.vim.org. --- Makefile | 12 ------------ lint/vim.sh | 1 - vim/autoload/detect_background.vim | 37 ------------------------------------- vim/config/syntax.vim | 15 +++++---------- vim/doc/detect_background.txt | 37 ------------------------------------- 5 files changed, 5 insertions(+), 97 deletions(-) delete mode 100644 vim/autoload/detect_background.vim delete mode 100644 vim/doc/detect_background.txt diff --git a/Makefile b/Makefile index 605c10f9..78bab07a 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,6 @@ install-vim-after-ftdetect \ install-vim-after-indent \ install-vim-after-syntax \ - install-vim-autoload \ install-vim-bundle \ install-vim-compiler \ install-vim-config \ @@ -499,7 +498,6 @@ VIMDIR = $(HOME)/.vim VIMRC = $(HOME)/.vimrc install-vim: install-vim-after \ - install-vim-autoload \ install-vim-bundle \ install-vim-compiler \ install-vim-config \ @@ -528,10 +526,6 @@ install-vim-after-syntax: mkdir -p $(VIMDIR)/after/syntax cp -p -- vim/after/syntax/*.vim $(VIMDIR)/after/syntax -install-vim-autoload: - mkdir -p -- $(VIMDIR)/autoload - cp -p -- vim/autoload/*.vim $(VIMDIR)/autoload - install-vim-bundle: install-vim-config find vim/bundle/*/* \ -type d -exec sh -c \ @@ -675,7 +669,6 @@ dist-vim-plugin: dist-vim-plugin-auto-backupdir \ dist-vim-plugin-big-file-options \ dist-vim-plugin-command-typos \ dist-vim-plugin-copy-linebreak \ - dist-vim-plugin-detect-background \ dist-vim-plugin-mail-mutt \ dist-vim-plugin-strip-trailing-whitespace @@ -709,11 +702,6 @@ dist-vim-plugin-copy-linebreak: \ vim/doc/copy_linebreak.txt \ VERSION sh dist/vim-plugin.sh copy_linebreak -dist-vim-plugin-detect-background: \ - vim/autoload/detect_background.vim \ - vim/doc/detect_background.txt \ - VERSION - sh dist/vim-plugin.sh detect_background dist-vim-plugin-mail-mutt: \ vim/plugin/mail_mutt.vim \ vim/doc/mail_mutt.txt \ diff --git a/lint/vim.sh b/lint/vim.sh index 5c1bbe22..3c173518 100644 --- a/lint/vim.sh +++ b/lint/vim.sh @@ -1,6 +1,5 @@ set -- \ vim/after \ - vim/autoload \ vim/compiler \ vim/config \ vim/ftdetect \ diff --git a/vim/autoload/detect_background.vim b/vim/autoload/detect_background.vim deleted file mode 100644 index e4163a43..00000000 --- a/vim/autoload/detect_background.vim +++ /dev/null @@ -1,37 +0,0 @@ -" -" detect_background.vim: 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. -" -" Return the string to which we think the option should be set, to allow the -" caller to use it as they see fit. -" -" Author: Tom Ryder -" License: Same as Vim itself -" -if exists('g:loaded_detect_background') || &compatible - finish -endif -let g:loaded_detect_background = 1 - -" Declare autoload function for 'background' set -function! detect_background#DetectBackground() abort - - " Split up the value of $COLORFGBG (if any) by semicolons - let l:colorfgbg = split($COLORFGBG, ';') - - " Get the background color value, or an empty string if none - let l:bg = len(l:colorfgbg) - \ ? l:colorfgbg[-1] - \ : '' - - " Choose the background setting based on this value - if l:bg ==# 'default' - \ || l:bg == 7 - \ || l:bg == 15 - return 'light' - else - return 'dark' - endif - -endfunction diff --git a/vim/config/syntax.vim b/vim/config/syntax.vim index 2322db5b..a2186b1f 100644 --- a/vim/config/syntax.vim +++ b/vim/config/syntax.vim @@ -5,17 +5,12 @@ if has('syntax') && !has('g:syntax_on') silent! syntax enable silent! syntax sync minlines=100 - " If we can, detect a light background, but default to a dark one. This is - " only because it's more likely the author of this configuration will be - " using one. - if v:version >= 701 - silent! let &background = detect_background#DetectBackground() - else - set background=dark - endif + " Opinionated; if the author is using color at all, it will probably be with + " a dark background + set background=dark - " The 'sahara' colorscheme only works for dark backgrounds with 256 colors - if &background ==# 'dark' && (has('gui_running') || &t_Co == 256) + " The 'sahara' colorscheme only works in the GUI or with 256 colors + if has('gui_running') || &t_Co >= 256 silent! colorscheme sahara endif diff --git a/vim/doc/detect_background.txt b/vim/doc/detect_background.txt deleted file mode 100644 index 570ac47b..00000000 --- a/vim/doc/detect_background.txt +++ /dev/null @@ -1,37 +0,0 @@ -*detect_background.txt* For Vim version 7.0 Last change: 2017 November 12 - -DESCRIPTION *detect_background* - *detect_background#DetectBackground()* - -The |detect_background#DetectBackground()| function provided by this plugin -inspects the $COLORFGBG environment variable to determine whether the user is -using a terminal with a light background, and returns the word "dark" or -"light" accordingly, for use in setting 'background'. - -The function does roughly the reverse of Vim's built-in heuristics to set the -'background' option, which default to a light background in the absence of -hints otherwise. - -Note that this plugin does not inspect the value of the $TERM environment -variable or the |'term'| option at all, nor the |'t_RB'| option. - -REQUIREMENTS *detect_background-requirements* - -This plugin is only available if 'compatible' is not set. - -AUTHOR *detect_background-author* - -Written and maintained by Tom Ryder . - -LICENSE *detect_background-license* - -Licensed for distribution under the same terms as Vim itself (see |license|). - -DISTRIBUTION *detect_background-distribution* - -This plugin lives in Tom Ryder's "dotfiles" suite, and may eventually be spun -off into a separate distribution as it solidifies and this documentation -improves. See for more -information. - - vim:tw=78:ts=8:ft=help:norl: -- cgit v1.2.3