Neovim raises attempt to call field 'get_load_fts' (a nil value) - lua

After upgrading my neovim to 0.7.2 I get the following error
Error detected while processing BufWinEnter Autocommands for "*":
E5108: Error executing lua ...pack/paqs/start/LuaSnip/lua/luasnip/loaders/from_lua.lua:97: attempt to call field 'get_load_fts' (a nil value)
stack traceback:
...pack/paqs/start/LuaSnip/lua/luasnip/loaders/from_lua.lua:97: in function '_load_lazy_loaded'
[string ":lua"]:1: in main chunk
E5108: Error executing lua [string ":lua"]:1: attempt to call field '_load_lazy_loaded' (a nil value)
stack traceback:
[string ":lua"]:1: in main chunk
E5108: Error executing lua [string ":lua"]:1: attempt to call field '_load_lazy_loaded' (a nil value)
stack traceback:
[string ":lua"]:1: in main chunk
Help on debugging very welcome!

The error was due to conflicting versions of the plugin, installed via two different plugin managers.
Looking into the different paths in the runtime path (as found with :set rtp) I found different installs and checked their "freshness" with git log.
I removed the folders related to the no longer used plugin manager.
The neovim config files did not really help, rather some lua and git command, but yes, the remark of #Icheylus is usually correct.

Related

Requiring luasnip to neovim causes errors

I am trying to use luasnip.
The configuration I am using is AstroNvim.
The modifications I made to this configuration are :
require("luasnip.loaders.from_snipmate").lazy_load() at the end of init.lua
Made a directory snippets in the same directory of init.lua, and added some basic snipmate styled snippets inside.
Commands Like :LuaSnipListAvailable works well, and snippets from friendly-snippets works well too.
However the following error message pops up when opening neovim.
Error detected while processing /Users/myusername/.config/nvim/init.lua:
E5113: Error while calling lua chunk: ...m/site/pack/packer/start/packer.nvim/lua/packer/load.lua:171: Vim(echomsg):E121: Undefined variable: Error
stack traceback:
[C]: in function 'cmd'
...m/site/pack/packer/start/packer.nvim/lua/packer/load.lua:171: in function <...m/site/pack/packer/start/packer.nvim/lua/packer/load.lua:16
7>
/Users/myusername/.local/share/nvim/packer_compiled.lua:496: in function </Users/myusername/.local/share/nvim/packer_compiled.lua:485>
[C]: in function 'require'
/Users/myusername/.config/nvim/init.lua:23: in main chunk
I tried other methods of adding snippets, but any sort of require("luasnip") seems to break all.

NeoVim - Check if a Vim function exists from Lua

I plan on using vim-plug with NeoVim. So, my init.lua file will have function calls such as
vim.fn['plug#begin'](vim.fn.stdpath('data') .. '/plugged')
vim.fn['plug#']('hoob3rt/lualine.nvim')
However, I don't want to assume vim-plug is definitely installed. I want my init.lua file to degrade gracefully if vim-plug is not installed, rather than throwing an error
E5113: Error while calling lua chunk: Vim:E117: Unknown function: plug#begin
stack traceback:
[C]: in function 'plug#begin'
/Users/andy/.config/nvim/init.lua:8: in main chunk
How can I check if the vim-plug functions exist before attempting to call them?
I tried print(vim.fn['plug#begin']) but that for some reason prints a non-null value: function: 0x0104ba36f0, even though the function doesn't exist.
I tried print(vim.fn['plug#begin']) but that for some reason prints a non-null value: function: 0x0104ba36f0, even though the function doesn't exist.
Presumably it's returning a function that throws the error you are getting. I would thus recommend using pcall:
local success, error = pcall(vim.fn['plug#begin'], vim.fn.stdpath('data') .. '/plugged')
if not success then --[[fail gracefully]] end
caveat: this will catch any error, so you'll probably want to perform some check like if error:find"Unknown function" then ... end to only catch this specific error.

Attempt to index global 'application' (a nil value) error

I'm trying to follow a Lua roguelike course to learn the language and by line 17 when I had attempted to run the program to see the title it came up with the error
lua: [string "<eval>"]:1: attempt to index global 'application' (a nil value)
stack traceback:
[string "<eval>"]:1: in main chunk
Here's all the code I've written and the link to the course
application:setOrientation(Application.LANDSCAPE_LEFT
application:setScaleMode("letterbox")
BLACK # 0x1A1A1A
application:setBackgroundColor(BLACK)
local fg = Bitmap.new(Texture.new("images/foreground.png", true))
fg:setX(1201)
stage:addChild(fg)
YELLOW # 0xDAD45E
local title = TextField.new(nil, "The Long Dark")
title:setTextColor(YELLOW)
title:setPosition(1320, 100)
stage:addChild(title)
https://programmingbymoonlight.com/roguelike-part-1-lua-and-gideros-an-introduction/
So I tried gideros and it worked properly, while it depends on lua it has it's own commands native to it's IDE framework.

Loadstring Error: attempted to call a nil value

loadstring("
\45\45\32\80\117\116\32\115\99\114\105\112\116\32\104\101\114\101\10\112\114\105\110\116\40\34\104\105\34\41\10")()
I keep getting an error stating this:
lua: /tmp/044957038/main.lua:12: attempt to call a nil value (global 'loadstring')
stack traceback:
/tmp/044957038/main.lua:12: in main chunk
[C]: in ?
Can anyone help me? (I’m using glot.io to run my script.)
Based on the comments and some testing in glot, this should work (the print() is just for reference):
print("\45\45\32\80\117\116\32\115\99\114\105\112\116\32\104\101\114\101\10\112\114\105\110\116\40\34\104\105\34\41\10")
load("\45\45\32\80\117\116\32\115\99\114\105\112\116\32\104\101\114\101\10\112\114\105\110\116\40\34\104\105\34\41\10")()
Output
-- Put script here
print("hi")
hi

Attempt to index global 'Grid' (a nil value)

I have been trying to run the following codes from Euler Equations Solver. It is a Lua script that I have been toying with using ZeroBrane Studio. But the project gave the following error every time I try to execute it.
attempt to index global 'Grid' (a nil value)
stack traceback:
...mming Codes\Project 1\Lua Script\Problem 1\Problem 1.lua:7: in main chunk
[C]: at 0x00401b00
I am completely new to Lua and I have been looking for the solutions everywhere. Appreciate any help that I can get.

Resources