lightspeed.nvim icon indicating copy to clipboard operation
lightspeed.nvim copied to clipboard

Error executing lua vim.lua:0: attempt to call method 'byte' (a nil value)

Open diegologs opened this issue 3 years ago • 30 comments

Hi,

I'm using neovim version v0.7.0-dev, along with packer and this plugin, but I can't use the s command an the Scommand cause an exception is thrown. The f and the F command is working properly.

Mi packer config is just:

 use { "ggandor/lightspeed.nvim" }

Here is the error:

E5108: Error executing lua vim.lua:0: attempt to call method 'byte' (a nil value)                                                                                                                                                       
stack traceback:                                                                                                                                                                                                                        
        vim.lua: in function 'region'                                                                                                                                                                                                   
        /usr/share/nvim/runtime/lua/vim/highlight.lua:37: in function 'grey_out_search_area'                                                                                                                                            
        .../site/pack/packer/opt/lightspeed.nvim/lua/lightspeed.lua:2139: in function 'go'                                                                                                                                              
        [string ":lua"]:1: in main chunk 

Thanks for your time!

diegologs avatar Feb 28 '22 08:02 diegologs

(Fortunately) I cannot reproduce with the latest nightly. But I have no clue about the problem.

In Lightspeed, grey-out-search-area calls highlight-range-compat, with "v" passed in as regtype: https://github.com/ggandor/lightspeed.nvim/blob/3a8759e10c315d4fe36bfb15a7e243fdee5f33e7/fnl/lightspeed.fnl#L343-L349

highlight-range-compat calls vim.highlight.range (that even defaults to "v" if the regtype argument is missing, so it actually shouldn't matter at all what we are doing in the plugin's code),

https://github.com/neovim/neovim/blob/e383543342db8e9dcf40f7d5237edeab29638880/runtime/lua/vim/highlight.lua#L38-L49

that in turn calls vim.region (passing on regtype to it), which throws the exception, when trying to call the byte method on "v".

https://github.com/neovim/neovim/blob/e383543342db8e9dcf40f7d5237edeab29638880/src/nvim/lua/vim.lua#L319-L332.

At least, if I'm not missing anything.

ggandor avatar Feb 28 '22 11:02 ggandor

Ok, I think I have found it. #126, again :D It's insane how could both me and the author overlook so many errors, in such a small PR (and not test it...). There are three tables passed in, instead of one, in grey-out-search-area, in the single-window branch. Fixing this right now. (Now I'm actually wondering, why does it work for me, and apparently, for others, without errors? Edit: Because {regtype :v} is a perfectly valid opts table in itself, and the following ones are simply ignored. So, while it is good that we corrected this, it's not relevant.)

ggandor avatar Feb 28 '22 11:02 ggandor

Hi, unfortunately this issue persists for me.

2022-02-28T15:42:10+03:00

As the original author i use an unconfigured lightspeed.

2022-02-28T15:50:28+03:00

I'm using latest neovim nightly and (surely) this plugin after fix commit

ghost avatar Feb 28 '22 12:02 ghost

Okay, then first test it with stable Nvim, and then try older commits of Lightspeed...

ggandor avatar Feb 28 '22 13:02 ggandor

The regtype argument apparently exists (not nil), because otherwise we'd have a message of "attempt to index... a nil value".

As a desperate sanity check, try lua local a = "v"; print(a:byte()) on the Nvim command line first.

ggandor avatar Feb 28 '22 14:02 ggandor

FWIW, I got this error until I updated to the latest neovim master.

jacksonludwig avatar Feb 28 '22 15:02 jacksonludwig

Sorry for late response.

Latest version works on nvim v0.6.1.

Commit 005320ff9e128de8689c6e675fa64ed5963e2d1c seems to be the last working with ~~0.7.1~~ 0.7.0 for me. Commit 8fd73360e89a219b5701339c08a469f5703cf163 doesn't make any keymaps. Commit e53a14b2b279e92fbca9646ec14188ab76dd009a shows error described above.

ghost avatar Feb 28 '22 17:02 ghost

Could you give me the exact version of the nightly you are using? Is it possible that you are not using the actual latest one, but one that is before merging https://github.com/neovim/neovim/pull/17462, not including the breaking change in the signature of vim.highlight.range?

ggandor avatar Feb 28 '22 18:02 ggandor

NVIM v0.7.0-dev+995-g255935903
Build type: Release
LuaJIT 2.1.0-beta3

ghost avatar Feb 28 '22 19:02 ghost

Just realized two neovims were installed on the system, and older one was chosen. It works on the true latest version.

I apologize and thanks.

ghost avatar Feb 28 '22 19:02 ghost

Okay, great, no problem!

ggandor avatar Feb 28 '22 20:02 ggandor

This occurs for me with (an older) Neovim nightly NVIM v0.7.0-dev+1032-g01e58fb14 making the plugin unusable, so does this mean that the minimum required Neovim version has changed? The readme still mentions 0.5+.

smjonas avatar Mar 02 '22 09:03 smjonas

@smjonas No. The plugin works with any stable Nvim (0.5+), but if you are on the nightly branch, you should always update to the current latest release.

ggandor avatar Mar 02 '22 10:03 ggandor

This still happens for me on the absolute latest master branch.

NVIM v0.7.0-dev+e23af71d3 Build type: Debug LuaJIT 2.1.0-beta3

mattdemichele-pearson avatar Mar 04 '22 02:03 mattdemichele-pearson

@mattdemichele-pearson I cannot reproduce. At least on

NVIM v0.7.0-dev+1182-ge23af71d3
Build type: RelWithDebInfo

Maybe it has something to do with the Debug build(?)

ggandor avatar Mar 04 '22 17:03 ggandor

I'm having this problem as well since today, I build from source, did it just now.

image

yngwi avatar Mar 04 '22 21:03 yngwi

@yngwi And you're pretty sure that you're using the latest Lightspeed too?

ggandor avatar Mar 05 '22 09:03 ggandor

@yngwi And you're pretty sure that you're using the latest Lightspeed too?

I thought I was as I am using a docker container that automatically updates everything on command, but apparently I was mistaken. I tried again today (updating my environment) and the error is gone now. Thanks and sorry for the confusion.

yngwi avatar Mar 05 '22 09:03 yngwi

I removed and reinstalled it and still get this error.

E5108: Error executing lua vim.lua:0: attempt to call method 'byte' (a nil value)
stack traceback:
        vim.lua: in function 'region'
        /usr/local/share/nvim/runtime/lua/vim/highlight.lua:37: in function 'grey_out_search_area'
        ...ite/pack/packer/start/lightspeed.nvim/lua/lightspeed.lua:2145: in function 'go'
        [string ":lua"]:1: in main chunk

simanga-dev avatar Mar 09 '22 06:03 simanga-dev

@h3ndry This should work now, double-check that it's the latest Nvim nightly and the latest Lightspeed you're using.

ggandor avatar Mar 09 '22 23:03 ggandor

Same error here and updated from v0.7.0-dev+1077-g2c4efc034 to v0.7.0-dev+1237-g76769b8a1 and now it works like a charm :)

josex2r avatar Mar 11 '22 16:03 josex2r

I reverted to the neovim stable version https://launchpad.net/~neovim-ppa/+archive/ubuntu/stable and that seemed to fix it too

lars-vc avatar Mar 12 '22 16:03 lars-vc

@h3ndry This should work now, double-check that it's the latest Nvim nightly and the latest Lightspeed you're using.

Thank you. I updated neovim to v0.7.0-dev+1245-gf291a0339. and that seemed to fix it.

simanga-dev avatar Mar 13 '22 04:03 simanga-dev

I have this issue in NVIM v0.7.0-dev+1280-gf2e5f509d. Is anyone able to repro?

vidjul avatar Mar 19 '22 17:03 vidjul

@vidjul Update Lightspeed too.

ggandor avatar Mar 25 '22 14:03 ggandor

I was using neovim version v0.7.0-dev+882-g9304ee387. Uninstalled then installed stable (0.6.1) and this now works like a charm. Thanks!

danielo515 avatar Mar 29 '22 16:03 danielo515

Same here, Ubuntu with latest neovim from ppa, lightspeed updated.

otavioschwanck avatar Mar 29 '22 18:03 otavioschwanck

Reverting to 005320ff9e128de8689c6e675fa64ed5963e2d1c fixes the problem

otavioschwanck avatar Mar 29 '22 18:03 otavioschwanck

Issue remains on latest release.

:version
NVIM v0.7.0
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by nixbld

YodaEmbedding avatar Apr 27 '22 00:04 YodaEmbedding

switching to Commit 005320ff9e128de8689c6e675fa64ed5963e2d1c fixed it for me

` NVIM v0.7.0 Build type: Release LuaJIT 2.1.0-beta3 Compiled by runner@fv-az316-460

Features: +acl +iconv +tui See ":help feature-compile"

system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/share/nvim"

Run :checkhealth for more info `

justinsgithub avatar Apr 29 '22 15:04 justinsgithub