lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


David Manura wrote:
LuaInspect (like a few others) is currently using a combination of the
plain Lua portions of the Metalua libraries and loadstring.  I'm
finding reparsing on every keystroke with larger files is a bit slow
via Metalua, but I think it can be made manageable with some
techniques.  One technique that helps is to invoke loadstring (which
is fast) as a quick syntax check prior to attempting the Metalua
parse.  Another technique that likely will be done is to incrementally
re-parse only the block that has changed.

I think it's probably better to only perform the semantic analysis and highlighting in Vim when the CursorHold event fires. This event fires when the user hasn't typed for 4 seconds. Thanks for the pointer to your LuaInspect (and for writing it of course!), I'm reading through update_ast() right now trying to see how much work it would be to transplant it into a Vim file type plug-in using the Lua interface.

I looked briefly at if_lua.html in vim73b but didn't see an example of
how this would be used for syntax-like things.  Is there a basic
example?

No there isn't and that's because the Lua interface is quite minimal. I've used Vim's message redirection to get completion candidates* (if-lua includes a modified print() which prints inside Vim, and using Vim's :redir => variable command you can intercept the printed output). This means I'll have to marshal all info back and forth using strings, but I'm used to that by now :-) (after scripting Vim for some years)

 - Peter Odding

* http://lua-users.org/lists/lua-l/2010-01/msg01319.html