aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-07-07 16:36:05 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-07-07 16:36:05 +1200
commitc81104a0b1f16d437fed0d1f0af4bbc8a22d56d5 (patch)
treee23687aa585d52189642985410fbc6c11a2b32b5
parentBump VERSION (diff)
downloadvim-big-file-options-c81104a0b1f16d437fed0d1f0af4bbc8a22d56d5.tar.gz
vim-big-file-options-c81104a0b1f16d437fed0d1f0af4bbc8a22d56d5.zip
Allow setting options any time
-rw-r--r--doc/big_file_options.txt3
-rw-r--r--plugin/big_file_options.vim32
2 files changed, 15 insertions, 20 deletions
diff --git a/doc/big_file_options.txt b/doc/big_file_options.txt
index bc133ae..72460bd 100644
--- a/doc/big_file_options.txt
+++ b/doc/big_file_options.txt
@@ -22,7 +22,8 @@ This plugin is only available if 'compatible' is not set. It also requires the
OPTIONS *big_file_options-options*
-There are a few options you can set in your |vimrc| before loading the plugin:
+There are a few options you can set at any time before loading big files; it's
+probably best to put them in your |vimrc|.
*g:big_file_size*
Set `g:big_file_size` to the threshold in bytes beyond which a file should be
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