From a0cc0969ee1cc1f295bc865161432d4be467cffa Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 2 Nov 2017 14:07:33 +1300 Subject: Move Vim big file options config into plugin Created targets install-vim-doc and install-vim-plugin with accompanying subdirectories of "vim". Added a very short summary of what the plugin does to bigfile.txt. I intend to spin off at least a couple of the blocks of my Vim configuration that are starting to coalesce into distinct plugins unto themselves, and will place the files in these directories. --- vim/config/bigfile.vim | 28 ---------------------------- vim/doc/bigfile.txt | 12 ++++++++++++ vim/plugin/bigfile.vim | 28 ++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 28 deletions(-) delete mode 100644 vim/config/bigfile.vim create mode 100644 vim/doc/bigfile.txt create mode 100644 vim/plugin/bigfile.vim (limited to 'vim') diff --git a/vim/config/bigfile.vim b/vim/config/bigfile.vim deleted file mode 100644 index 5c68b1a7..00000000 --- a/vim/config/bigfile.vim +++ /dev/null @@ -1,28 +0,0 @@ -" When opening a large file, take some measures to keep things loading quickly -if has('eval') && has('autocmd') - - " Threshold is 10 MiB - let g:big_file_size = 10 * 1024 * 1024 - - " Declare function for turning off slow options - function! s:BigFileMeasures() - let l:file = expand('') - if getfsize(l:file) > g:big_file_size - setlocal nobackup - setlocal nowritebackup - setlocal noswapfile - if has('persistent_undo') - setlocal noundofile - endif - if exists('&synmaxcol') - setlocal synmaxcol=256 - endif - endif - endfunction - - " Define autocmd for calling to check filesize - augroup dotfiles_big_file_measures - autocmd! - autocmd BufReadPre * call s:BigFileMeasures() - augroup end -endif diff --git a/vim/doc/bigfile.txt b/vim/doc/bigfile.txt new file mode 100644 index 00000000..d7e56f28 --- /dev/null +++ b/vim/doc/bigfile.txt @@ -0,0 +1,12 @@ +*bigfile.txt* Disable slow options for big files to speed things up + +Author: Tom Ryder +License: Same terms as Vim itself (see |license|) + +This plugin adds an |autocmd| hook to check the file size of an incoming +buffer, and if it's over a certain threshold, disables certain options in order +to make the file a bit easier to edit. + +This plugin lives in Tom Ryder's "dotfiles" suite, and will eventually be spun +off into a separate distribution as it solidifies and this documentation +improves. diff --git a/vim/plugin/bigfile.vim b/vim/plugin/bigfile.vim new file mode 100644 index 00000000..5c68b1a7 --- /dev/null +++ b/vim/plugin/bigfile.vim @@ -0,0 +1,28 @@ +" When opening a large file, take some measures to keep things loading quickly +if has('eval') && has('autocmd') + + " Threshold is 10 MiB + let g:big_file_size = 10 * 1024 * 1024 + + " Declare function for turning off slow options + function! s:BigFileMeasures() + let l:file = expand('') + if getfsize(l:file) > g:big_file_size + setlocal nobackup + setlocal nowritebackup + setlocal noswapfile + if has('persistent_undo') + setlocal noundofile + endif + if exists('&synmaxcol') + setlocal synmaxcol=256 + endif + endif + endfunction + + " Define autocmd for calling to check filesize + augroup dotfiles_big_file_measures + autocmd! + autocmd BufReadPre * call s:BigFileMeasures() + augroup end +endif -- cgit v1.2.3