I have a function that builds my status line by appending values with statusline+=
depending on the context. Everything works, except that if I try to call a function in the following form:
setlocal statusline=%{MyFunction(a:my_parameter)}
It fails with
E121: Undefined variable a:my_parameter
E116: Invalid arguments for function MyFunction
E15: Invalid expression: MyFunction(a:my_parameter)
Of course I checked that a:my_parameter
is in scope and I can echo its value just before the function call. What is more, if I use a local variable instead (i.e. l:my_parameter
) it fails in the same way, but I can pass hardcoded values without problem. I think it may be a limitation of %{}
, but I cannot find anything in the documentation.
So, is it possible to pass variables to functions inside %{}
somehow?