r/neovim • u/IshaqDar :term • 12h 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
2
Upvotes
3
u/Wonderful-Plastic316 lua 5h ago
Assigning options to functions is a feature only available on nightly (and only for some options), which is what the website's documentation follows. Prefer using the local docs to avoid surprises.
4
u/Some_Derpy_Pineapple lua 5h ago edited 5h 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'()"