Skip to content

Error in set_editor_opts in LightspeedLeave autocommand #152

Open
@Gelio

Description

@Gelio

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions