Created
September 7, 2022 15:55
-
-
Save sbeckeriv/d737ca6334bfcd1bf07c393716421880 to your computer and use it in GitHub Desktop.
disable plugins on big files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" disable syntax highlighting in big files found on reddit | |
" https://www.reddit.com/r/neovim/comments/pz3wyc/comment/heyy4qf/?utm_source=reddit&utm_medium=web2x&context=3 | |
" https://www.reddit.com/r/neovim/comments/s9kdsm/disable_treesitter_for_files_larger_than_x_lines/ lua version? | |
function DisableSyntaxTreesitter() | |
echo("Big file, disabling syntax, treesitter and folding") | |
if exists(':TSBufDisable') | |
exec 'TSBufDisable autotag' | |
exec 'TSBufDisable highlight' | |
" etc... | |
endif | |
set foldmethod=manual | |
syntax clear | |
syntax off " hmmm, which one to use? | |
filetype off | |
set noundofile | |
set noswapfile | |
set noloadplugins | |
endfunction | |
augroup BigFileDisable | |
autocmd! | |
" autocmd BufWinEnter * if getfsize(expand("%")) > 512 * 1024 | exec DisableSyntaxTreesitter() | endif | |
autocmd BufReadPre,FileReadPre * if getfsize(expand("%")) > 512 * 1024 | exec DisableSyntaxTreesitter() | endif | |
augroup END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment