diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-11-02 14:07:33 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-11-02 14:10:35 +1300 |
commit | a0cc0969ee1cc1f295bc865161432d4be467cffa (patch) | |
tree | bc8820ff410dfbc5f5124a525691fa633b669edc /vim/plugin | |
parent | Merge branch 'hotfix/v0.3.2' (diff) | |
download | dotfiles-a0cc0969ee1cc1f295bc865161432d4be467cffa.tar.gz dotfiles-a0cc0969ee1cc1f295bc865161432d4be467cffa.zip |
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.
Diffstat (limited to 'vim/plugin')
-rw-r--r-- | vim/plugin/bigfile.vim | 28 |
1 files changed, 28 insertions, 0 deletions
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('<afile>') + 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 |