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 +++++++++++++++++++++++++++++++++++++++++++++++++ vim/plugin/bigfile.vim | 60 ------------------------------------------------- 2 files changed, 60 insertions(+), 60 deletions(-) create mode 100644 vim/plugin/big_file.vim delete mode 100644 vim/plugin/bigfile.vim (limited to 'vim/plugin') 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 diff --git a/vim/plugin/bigfile.vim b/vim/plugin/bigfile.vim deleted file mode 100644 index fece3d9b..00000000 --- a/vim/plugin/bigfile.vim +++ /dev/null @@ -1,60 +0,0 @@ -" -" bigfile.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:bigfile_size') - let g:bigfile_size = 10 * 1024 * 1024 - endif - - " Default to leaving syntax highlighting off - if !exists('g:bigfile_syntax') - let g:bigfile_syntax = 0 - endif - - " Cut 'synmaxcol' down to this or smaller for big files - if !exists('g:bigfile_size_synmaxcol') - let g:bigfile_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:bigfile_size_synmaxcol - execute 'setlocal synmaxcol=' . g:bigfile_size_synmaxcol - endif - - " Disable syntax highlighting if configured to do so - if !g:bigfile_syntax - setlocal syntax=OFF - endif - - endfunction - - " Define autocmd for calling to check filesize - augroup bigfile_options_bufreadpre - autocmd! - autocmd BufReadPre * call s:BigFileOptions(expand(''), g:bigfile_size) - augroup end - -endif -- cgit v1.2.3