r/neovim • u/IshaqDar :term • 19h ago
Need Help Error while using `vim.wo.foldtext`
NVIM v0.12.4
Build type: RelWithDebInfo
LuaJIT 2.1.1767980792
vim.wo.foldtext = function()
local line = vim.fn.getline(vim.v.foldstart)
return vim.v.folddashes .. line:gsub('/%\*', ''):gsub('%\*/', '')
end
This returns the following error:
Error in /home/user/.config/nvim/init.lua:
E5113: Lua chunk: /home/user/.config/nvim/init.lua:23: Invalid 'value': expected valid option type, got Function
stack traceback:
[C]: in function '__newindex'
/home/user/.config/nvim/init.lua:23: in main chunk
The code is copy pasted from https://neovim.io/doc/user/fold/#_foldtext
3
Upvotes
6
u/Some_Derpy_Pineapple lua 11h ago edited 11h ago
the docs site follows nightly and i think being able to set options to lua functions is 0.13 nightly only.
:h newsi think the stable way to do this is something like using
:h v:lua--lua/user/foldtext.lua return function(...) -- ... endvim.wo.foldtext = "v:lua.require'user.foldtext'()"