From 17d0781bb4d6eb12f79729f36b09e55bae7391a2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 4 Nov 2017 02:02:36 +1300 Subject: Rename bigfile plugin to big_file Just for consistency with the other plugins I'm making. I don't think I really like the cutesy names given to Vim plugins. I prefer the slightly longer and maybe even namespaced names like Perl distributions and modules have. Let's see how well this works. --- vim/plugin/big_file.vim | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 vim/plugin/big_file.vim (limited to 'vim/plugin/big_file.vim') diff --git a/vim/plugin/big_file.vim b/vim/plugin/big_file.vim new file mode 100644 index 00000000..4c07d7c3 --- /dev/null +++ b/vim/plugin/big_file.vim @@ -0,0 +1,60 @@ +" +" big_file.vim: When opening a large file, take some measures to keep things +" loading quickly. +" +" Author: Tom Ryder +" Copyright: 2017 +" License: Same as Vim itself +" +if has('eval') && has('autocmd') + + " Default threshold is 10 MiB + if !exists('g:big_file_size') + let g:big_file_size = 10 * 1024 * 1024 + endif + + " Default to leaving syntax highlighting off + if !exists('g:big_file_syntax') + let g:big_file_syntax = 0 + endif + + " Cut 'synmaxcol' down to this or smaller for big files + if !exists('g:big_file_size_synmaxcol') + let g:big_file_size_synmaxcol = 256 + endif + + " Declare function for turning off slow options + function! s:BigFileOptions(name, size) + + " Don't do anything if the file is under the threshold + if getfsize(a:name) <= a:size + return + endif + + " Turn off backups, swap files, and undo files + setlocal nobackup + setlocal nowritebackup + setlocal noswapfile + if has('persistent_undo') + setlocal noundofile + endif + + " Limit the number of columns of syntax highlighting + if exists('&synmaxcol') && &synmaxcol > g:big_file_size_synmaxcol + execute 'setlocal synmaxcol=' . g:big_file_size_synmaxcol + endif + + " Disable syntax highlighting if configured to do so + if !g:big_file_syntax + setlocal syntax=OFF + endif + + endfunction + + " Define autocmd for calling to check filesize + augroup big_file_options_bufreadpre + autocmd! + autocmd BufReadPre * call s:BigFileOptions(expand(''), g:big_file_size) + augroup end + +endif -- cgit v1.2.3 From 41b748050659534927267bbf6240e42fd1182e79 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 4 Nov 2017 02:03:56 +1300 Subject: Rename a misnamed variable in big_file.vim The word "size" was added to this variable's name unnecesarily. --- vim/plugin/big_file.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'vim/plugin/big_file.vim') diff --git a/vim/plugin/big_file.vim b/vim/plugin/big_file.vim index 4c07d7c3..5ccad7d2 100644 --- a/vim/plugin/big_file.vim +++ b/vim/plugin/big_file.vim @@ -19,8 +19,8 @@ if has('eval') && has('autocmd') endif " Cut 'synmaxcol' down to this or smaller for big files - if !exists('g:big_file_size_synmaxcol') - let g:big_file_size_synmaxcol = 256 + if !exists('g:big_file_synmaxcol') + let g:big_file_synmaxcol = 256 endif " Declare function for turning off slow options @@ -40,8 +40,8 @@ if has('eval') && has('autocmd') endif " Limit the number of columns of syntax highlighting - if exists('&synmaxcol') && &synmaxcol > g:big_file_size_synmaxcol - execute 'setlocal synmaxcol=' . g:big_file_size_synmaxcol + if exists('&synmaxcol') && &synmaxcol > g:big_file_synmaxcol + execute 'setlocal synmaxcol=' . g:big_file_synmaxcol endif " Disable syntax highlighting if configured to do so -- cgit v1.2.3 From 562c9ce6fbbd6fc8b9c5e470121dcc8e731de21e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 4 Nov 2017 17:39:23 +1300 Subject: Use same comment boilerplate for custom plugins A brief explanation, an author name, and the license should do fine. --- vim/plugin/big_file.vim | 1 - 1 file changed, 1 deletion(-) (limited to 'vim/plugin/big_file.vim') diff --git a/vim/plugin/big_file.vim b/vim/plugin/big_file.vim index 5ccad7d2..ec30158a 100644 --- a/vim/plugin/big_file.vim +++ b/vim/plugin/big_file.vim @@ -3,7 +3,6 @@ " loading quickly. " " Author: Tom Ryder -" Copyright: 2017 " License: Same as Vim itself " if has('eval') && has('autocmd') -- cgit v1.2.3