diff options
| author | jdhao <jdhao@hotmail.com> | 2022-08-15 00:08:16 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-15 00:08:16 +0800 |
| commit | f491e26676547f98c4830037752a6e74c99484ce (patch) | |
| tree | 137865974193a012c5d750faf9dbbee50ac7e2f9 | |
| parent | a52a362b028d83a349a311e80bb4c29fe06b0849 (diff) | |
| parent | e7e4892c22c6973b25083d9654a778cf79cd3cb9 (diff) | |
Merge pull request #63 from jdhao/large-file
handle large file better
| -rw-r--r-- | core/autocommands.vim | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/core/autocommands.vim b/core/autocommands.vim index c055c49..70b40db 100644 --- a/core/autocommands.vim +++ b/core/autocommands.vim @@ -135,3 +135,23 @@ augroup auto_create_dir autocmd! autocmd BufWritePre * lua require('utils').may_create_dir() augroup END + +" ref: https://vi.stackexchange.com/a/169/15292 +function! s:handle_large_file() abort + let g:large_file = 10485760 " 10MB + let f = expand("<afile>") + + if getfsize(f) > g:large_file || getfsize(f) == -2 + set eventignore+=all + " turning off relative number helps a lot + set norelativenumber + setlocal noswapfile bufhidden=unload buftype=nowrite undolevels=-1 + else + set eventignore-=all relativenumber + endif +endfunction + +augroup LargeFile + autocmd! + autocmd BufReadPre * call s:handle_large_file() +augroup END |
