Git Product home page Git Product logo

vim-lua's Introduction

vim-lua

lua development plugin for Vim

lua

Features

  • syntax highlight
  • indent
  • omni complete
  • code runner

vim-lua's People

Contributors

jyscao avatar wsdjeg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vim-lua's Issues

foldexpr causing extreme slowness

As previously mentioned in the chat some days ago, enabling the Lua layer, which includes this plugin makes working with Lua files very slow. Originally, I'd thought it was only caused by the inherent slow nature of using expr as the foldmethod, since it calls the function for every single line. However, after some more digging, it appears the function lua#fold#foldlevel(linenum) used to calculate the fold levels also contributes a great deal to the slowness.

I've profiled this again using the same file from before (~8kb, and now down to 306 lines total), to make sure the slowness indeed is related to the function used for foldexpr. First using the plugin as is, then by removing all the patterns (ex. do, function, end, etc.) used to check for folds. See results below.

Results using the plugin as provided:

SCRIPT  /home/jyscao/.cache/vimfiles/repos/github.com/wsdjeg/vim-lua/autoload/lua/fold.vim
Sourced 1 time
Total time:   0.000015
 Self time:   0.000015

count  total (s)   self (s)
    1              0.000004 function! lua#fold#foldlevel(linenum) abort
                                lua require('luavi').fold(require('luavi.vimutils').eval('a:linenum'))
                            endfunction
                            
                            

FUNCTION  lua#fold#foldlevel()
Called 612 times
Total time:  89.391175
 Self time:  89.391175

count  total (s)   self (s)
  612             89.389752     lua require('luavi').fold(require('luavi.vimutils').eval('a:linenum'))

FUNCTIONS SORTED ON TOTAL TIME
count  total (s)   self (s)  function
  612  89.391175             lua#fold#foldlevel()

FUNCTIONS SORTED ON SELF TIME
count  total (s)   self (s)  function
  612             89.391175  lua#fold#foldlevel()

Results with the local variable patterns in function fold_iter from lua/luavi.lua set to {}:

SCRIPT  /home/jyscao/.cache/vimfiles/repos/github.com/wsdjeg/vim-lua/autoload/lua/fold.vim
Sourced 1 time
Total time:   0.000016
 Self time:   0.000016

count  total (s)   self (s)
    1              0.000005 function! lua#fold#foldlevel(linenum) abort
                                lua require('luavi').fold(require('luavi.vimutils').eval('a:linenum'))
                            endfunction
                            
                            

FUNCTION  lua#fold#foldlevel()
Called 612 times
Total time:   6.255300
 Self time:   6.255300

count  total (s)   self (s)
  612              6.254650     lua require('luavi').fold(require('luavi.vimutils').eval('a:linenum'))

FUNCTIONS SORTED ON TOTAL TIME
count  total (s)   self (s)  function
  612   6.255300             lua#fold#foldlevel()

FUNCTIONS SORTED ON SELF TIME
count  total (s)   self (s)  function
  612              6.255300  lua#fold#foldlevel()

So as we can see, calling the foldexpr function 2x for every line of any given .lua file is definitely problematic in itself, since even after removing all the fold checking patterns, it still takes 6+ seconds to complete. But checking against all the patterns in fold_iter causes the delay to become dramatically worse, requiring 1.5min before the buffer is ready for use.

Before both causes of this slowness are fixed, I think it best to not use expr as the foldmethod for the Lua layer.

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.