From c81104a0b1f16d437fed0d1f0af4bbc8a22d56d5 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 7 Jul 2018 16:36:05 +1200 Subject: Allow setting options any time --- plugin/big_file_options.vim | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'plugin/big_file_options.vim') diff --git a/plugin/big_file_options.vim b/plugin/big_file_options.vim index 067d15c..a64d648 100644 --- a/plugin/big_file_options.vim +++ b/plugin/big_file_options.vim @@ -13,26 +13,14 @@ if !has('autocmd') || v:version < 600 endif let g:loaded_big_file_options = 1 -" Default threshold is 10 MiB -let s:size = exists('g:big_file_size') - \ ? g:big_file_size - \ : 10 * 1024 * 1024 - -" Default to leaving syntax highlighting off -let s:syntax = exists('g:big_file_syntax') - \ ? g:big_file_syntax - \ : 0 - -" Cut 'synmaxcol' down to this or smaller for big files -let s:synmaxcol = exists('g:big_file_synmaxcol') - \ ? g:big_file_synmaxcol - \ : 256 - " Declare function for turning off slow options function! s:BigFileOptions() " Don't do anything if the buffer size is under the threshold - if line2byte(line('$') + 1) <= s:size + let l:size = exists('g:big_file_size') + \ ? g:big_file_size + \ : 10 * 1024 * 1024 + if line2byte(line('$') + 1) <= l:size return endif @@ -45,12 +33,18 @@ function! s:BigFileOptions() endif " Limit the number of columns of syntax highlighting - if exists('+synmaxcol') && &synmaxcol > s:synmaxcol - execute 'setlocal synmaxcol=' . s:synmaxcol + let l:synmaxcol = exists('g:big_file_synmaxcol') + \ ? g:big_file_synmaxcol + \ : 256 + if exists('+synmaxcol') && &synmaxcol > l:synmaxcol + execute 'setlocal synmaxcol=' . l:synmaxcol endif " Disable syntax highlighting if configured to do so - if !s:syntax + let l:syntax = exists('g:big_file_syntax') + \ ? g:big_file_syntax + \ : 0 + if !l:syntax setlocal syntax=OFF endif -- cgit v1.2.3