Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in set_editor_opts in LightspeedLeave autocommand #152

Open
Gelio opened this issue Jun 21, 2022 · 3 comments
Open

Error in set_editor_opts in LightspeedLeave autocommand #152

Gelio opened this issue Jun 21, 2022 · 3 comments

Comments

@Gelio
Copy link

Gelio commented Jun 21, 2022

Hey! Thanks for this great plugin!

Today after updating my neovim build to the latest nightly (neovim/neovim@6d52a29), I started seeing errors originating from the set_editor_opts function executed by the LightspeedLeave autocommand.

Error detected while processing User Autocommands for "LightspeedLeave":
Error executing lua callback: ...ite/pack/packer/start/lightspeed.nvim/lua/lightspeed.lua:2764: E487: Argument must be positive
stack traceback:
        [C]: in function '__newindex'
        ...ite/pack/packer/start/lightspeed.nvim/lua/lightspeed.lua:2764: in function <...ite/pack/packer/start/lightspeed.nvim/lua/lightsp
eed.lua:2757>
        [C]: in function 'exec_user_autocmds'
        ...ite/pack/packer/start/lightspeed.nvim/lua/lightspeed.lua:2047: in function '_396_'
        ...ite/pack/packer/start/lightspeed.nvim/lua/lightspeed.lua:2050: in function 'get_first_input'
        ...ite/pack/packer/start/lightspeed.nvim/lua/lightspeed.lua:2369: in function 'go'
        ...m/site/pack/packer/start/lightspeed.nvim/plugin/init.lua:3: in function <...m/site/pack/packer/start/lightspeed.nvim/plugin/init
.lua:3>

The line that fails is

_G.vim[scope][name] = val
. The line number does not match because I added some print statements to debug it.

Investigation

I added a print to see which option cannot be set.

    print({ scope = scope, name = name, val = val })

It turns out, this code tries to set vim.wo.scrolloff = -1, which fails with that error.

{
  name = "scrolloff",
  scope = "wo",
  val = -1
}

I checked the results of the following neovim commands:

:lua print(vim.wo.scrolloff)
0

:echo &scrolloff
0

:echo &l:scrolloff
-1

:setlocal scrolloff?
-1

I believe the result of &l:scrolloff may be a problem. After all, this is the value that is requested in

if (opt == "vim.wo.scrolloff") then
_532_ = api.nvim_eval("&l:scrolloff")

Possibly related to neovim/neovim#18743

Possible solution

If &l:scrolloff is -1, then looks like setlocal scrolloff is not set, so there is no need to restore it, unless I am mistaken.

@ggandor
Copy link
Owner

ggandor commented Jun 22, 2022

Thanks for the thorough report! I had no mental energy to further investigate and really grok what causes this issue, but it seems we don't need that offending part in the code anymore (neovim/neovim#13964), so I just inserted a conditional check as a temporary fix.

@ggandor
Copy link
Owner

ggandor commented Jun 22, 2022

Let's keep this open for a while for discoverability.

@ggandor ggandor reopened this Jun 22, 2022
@lewis6991
Copy link

FYI, this is due to a regression in core which I'm planning to fix with neovim/neovim#19041

Testing is welcomed 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants