Git Product home page Git Product logo

Comments (3)

gilsondev avatar gilsondev commented on June 30, 2024

Interesting. But this not disabled others plugins?

from vim-bootstrap.

luffah avatar luffah commented on June 30, 2024

I don't think disabling plugins is useful, but disable their usage is.

Below a simple script to do that, i hope the code is clear :

fu! s:ProcessCommandList(alist)
  for l:opt_set in a:alist
    exe l:opt_set
  endfor
endfu

" file is large over 10mb; small under 24kb
let g:LargeFileSize = 1024 * 1024 * 10
let g:MediumFileSize = 1024 * 24

let s:LargeFileMsg = 'The file is larger than '
      \. (g:LargeFileSize / 1024 / 1024)
      \. ' MB, so some options are changed (see g:LargeFileSize).'

let g:SmallFileActionsOpen=['set eventignore-=Filetype']
let g:SmallFileActionsEnter=[]
let g:MediumFileActionsOpen=['set eventignore-=Filetype']
let g:MediumFileActionsEnter=[]
let g:LargeFileActionsEnter=[]
let g:LargeFileActionsOpen=[
      \ 'set eventignore+=Filetype',
      \ 'setlocal bufhidden=unload',
      \ 'setlocal buftype=nowrite',
      \ 'setlocal undolevels=-1',
      \ 'au VimEnter * echo "'.s:LargeFileMsg.'"'
      \]

fu! s:LargeFileSupport(...)
  if len(a:000)
    let b:filesize=a:000[0]
    let l:event='Open'
  elseif exists('b:filesize')
    let l:event='Enter'
  else
    return
  endif
  let l:size = ((b:filesize > g:LargeFileSize
        \ || b:filesize == -2) ? 'Large' :
        \ (b:filesize > g:MediumFileSize ? 'Medium' : 'Small'))
  echo 'call s:ProcessCommandList(g:'.l:size.'FileActions'.l:event.')'
  exe 'call s:ProcessCommandList(g:'.l:size.'FileActions'.l:event.')'
endfu

augroup LargeFile 
  autocmd BufReadPre * silent call s:LargeFileSupport(getfsize(expand("<afile>")))
  autocmd BufWinEnter * silent call s:LargeFileSupport()
augroup END

The script allows customization.

For example, in vim config file, you can say you want to see line numbers only in small files :

let g:SmallFileActionsOpen+=['setlocal nu']

from vim-bootstrap.

cassiobotaro avatar cassiobotaro commented on June 30, 2024

We can use vim -u NONE to disable plugins on large files, or script above. Thanks @luffah !

from vim-bootstrap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.