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

utils/fs.lua overwrites global M, breaking other extension #646

Closed
zivarah opened this issue Jan 6, 2024 · 1 comment
Closed

utils/fs.lua overwrites global M, breaking other extension #646

zivarah opened this issue Jan 6, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@zivarah
Copy link

zivarah commented Jan 6, 2024

Describe the bug

orgmode appears to be unconditionally setting M in lua/orgmode/utils/fs.lua:

M = {}

This results in benfowler/telescope-luasnip.nvim not working if orgmode is loaded after it:

:Telescope luasnip disable_ft=true

Error executing Lua callback: vim/shared.lua:305: after the second argument: expected table, got nil
stack traceback:
        [C]: in function 'error'
        vim/shared.lua:764: in function 'validate'
        vim/shared.lua:305: in function 'tbl_extend'
        ...scope-luasnip.nvim/lua/telescope/_extensions/luasnip.lua:74: in function <...scope-luasnip.nvim/lua/telescope/_extensions/luasnip.lua:73>
        .../nvim-data/lazy/telescope.nvim/lua/telescope/command.lua:193: in function 'run_command'
        .../nvim-data/lazy/telescope.nvim/lua/telescope/command.lua:259: in function 'load_command'
        ...Local/nvim-data/lazy/telescope.nvim/plugin/telescope.lua:108: in function <...Local/nvim-data/lazy/telescope.nvim/plugin/telescope.lua:107>

This issue does not occur if I swap the event= { "VeryLazy" } lines so that orgmode loads first. That said, it appears that telescope-luasnip also is doing an unconditional set of the global M (link, and it seems like that would break orgmode?

I am very new to nvim plugins and lua in general so I can't speak to whether this is an unexpected pattern or not. Should we be using a more distinct global name? Should we be doing M = M or {} instead? I did confirm that M = M or {} appears to address this.

Steps to reproduce

With the minimal config below:

  • Open nvim
  • Run :Telescope luasnip disable_ft=true
  • See the error

Expected behavior

orgmode should not wipe out global state set from other extensions.

Emacs functionality

No response

Minimal init.lua

-- Ensure that Lazy is cloned
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
	vim.fn.system({
		"git",
		"clone",
		"--filter=blob:none",
		"https://github.com/folke/lazy.nvim.git",
		"--branch=stable",
		lazypath,
	})
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
	{
		"nvim-telescope/telescope.nvim",
		dependencies = {
			"nvim-lua/plenary.nvim",
		},
		config = function()
			local telescope = require("telescope")

			telescope.setup({
				extensions = {
					luasnip = {},
				},
			})

			telescope.load_extension('luasnip')
		end
	},
	{
		"benfowler/telescope-luasnip.nvim",
		--event = { "VeryLazy" },

	},
	{
		"L3MON4D3/LuaSnip",
		dependencies = {
			"benfowler/telescope-luasnip.nvim",
		},
	},
	{
		"nvim-treesitter/nvim-treesitter",
		build = ":TSUpdate",
		config = function()
			require("nvim-treesitter.configs").setup({})
		end
	},
	{
		'nvim-orgmode/orgmode',
		event = { "VeryLazy" },
		dependencies = {
			{ "nvim-treesitter/nvim-treesitter" },
		},
		config = function()
			require('orgmode').setup_ts_grammar()
			require('orgmode').setup({})
		end,
	},
})

Screenshots and recordings

No response

OS / Distro

Windows 10

Neovim version/commit

0.9.2

Additional context

No response

@zivarah zivarah added the bug Something isn't working label Jan 6, 2024
@kristijanhusak
Copy link
Member

Should be fixed now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants