Closed jczhang02 closed 4 months ago
Using gentoo and compile neovim with USE flags LUA_SINGLE_TARGET="luajit
Based on the error it seems that this issue is caused by the nvim_buf_call
added to strategy
in the last commit, so for now you can probably go back one commits to get around this problem.
I can reproduce the error by setting up the (default) strategy via a function instead of setting it up immediately.
An easy fix for now is to not use nvim_buf_call
for strategy
(like it was before).
@HiPhish: If you switch to a setup where the functions can accept an optional bufnr
, you should probably double check setting up the strategy
via a function, since it has a different behavior in the current version compared to query
and priority
(both of those work fine with functions for me). I haven't really looked into this, but I can't immediately tell what causes this difference.
This is really weird because it works for the query. I can confirm that it is broken for strategies though, but only if using nvim_buf_call
. I will switch to a function that uses an optional bufnr
argument. The error is really weird, I don't understand why it is happening. It looks like returning a table that has function values is where things break. Here is a minimal example which replicates the error:
vim.api.nvim_buf_call(0, function() return {a = function() return 'x' end} end)
@jczhang02 Pleas revert one commit back for the time being. I will fix this shortly.
This is really weird because it works for the query. I can confirm that it is broken for strategies though, but only if using
nvim_buf_call
. I will switch to a function that uses an optionalbufnr
argument. The error is really weird, I don't understand why it is happening. It looks like returning a table that has function values is where things break.
Apparently this is a known limitation (that nvim_buf_call
cannot contain functions in the return value), since quote:
"nvim_buf_call is within the general Nvim API which adheres to msgpack and thus cannot return function values."
See https://github.com/neovim/neovim/issues/26531#issuecomment-1852179283.
Please try the current master
branch now, it should be fixed. The configuration function can now take the current buffer number as an argument if you want to.
Please try the current
master
branch now, it should be fixed. The configuration function can now take the current buffer number as an argument if you want to.
It works as I would expect (and LuaLS doesn't even complain about functions of the form function() return ... end
which I thought it would with the given type annotations).
I have one note/question: In lib.lua
line 71, we have ---@param bufnr integer? Use this buffer as the current buffer
, but can bufnr ever be nil? By the type annotations of the query, we expect a function that takes a non-nil bufnr.
You are right, the question mark was an oversight. I have corrected it now.
Closing this as done.
Neovim version
0.9.4
Language affected
All filetype
Query
No response
Strategy
No response
Description