2

Currently trying to understand my neovim setup better.

So, looked into what a few classical options are set to.

:set statusline

yields

  statusline=%{%v:lua.require'heirline'.eval_statusline()%}

:help %tab was not very helpful.

So, could someone help me pick this apart? I found out %{%…%} is a lambda expression which gets re-evaluated as statusline expression.

v: would suggest we're entering visual mode, but that makes no sense in the context.

So, I feel completely noobish, here.

3
  • Try :help v:lua
    – D. Ben Knoble
    Apr 25, 2023 at 13:04
  • wait. We have a vim variable that's actually not a variable at all, but evaluated lua code? Uff. That sounds like a design decision! Apr 25, 2023 at 13:13
  • I think it's basically exposing the global Lua namespace as Vim Dict, which is similar to a Lua table (but without prototypes, if I understand Lua correctly).
    – D. Ben Knoble
    Jul 25, 2023 at 13:47

1 Answer 1

1

v:lua is used to call Lua functions from Vimscript.

Quoting the v:lua-call help subject (lua.txt) from Neovim v0.10.0:

From Vimscript the special v:lua prefix can be used to call Lua functions which are global or accessible from global tables.

The expression

call v:lua.func(arg1, arg2)

is equivalent to the Lua chunk

return func(...)

where the args are converted to Lua values.

The expression

call v:lua.somemod.func(args)

is equivalent to the Lua chunk

return somemod.func(...)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.