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

live_grep with additional_args doesn't work (neovim 0.11) #3339

Open
archilkarchava opened this issue Oct 25, 2024 · 0 comments
Open

live_grep with additional_args doesn't work (neovim 0.11) #3339

archilkarchava opened this issue Oct 25, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@archilkarchava
Copy link

Description

The problem is with this code:

lua/telescope/utils.lua

local flatten = function(t)
  return vim.iter(t):flatten():totable()
end
utils.flatten = vim.fn.has "nvim-0.11" == 1 and flatten or vim.tbl_flatten

In the code above vim.iter(t):flatten():totable() is not equivalent to vim.tbl_flatten, since vim.iter(t):flatten():totable() will throw if we pass a non-array-like table where's vim.tbl_flatten will include the items with valid numeric keys (1..n) and will stop once it encounters an invalid one (additional_args in this case, but could be a different one, e.g. bufnr, etc)

Neovim version

NVIM v0.11.0-dev-1043+ge4a74e986
Build type: RelWithDebInfo
LuaJIT 2.1.1727870382

Operating system and version

macOS 14.7

Telescope version / branch / rev

master (df534c3 commit)

checkhealth telescope

telescope:                                              health#telescope#check

Checking for required plugins ~
- OK plenary installed.
- WARNING nvim-treesitter not found. (Required for `:Telescope treesitter`.)

Checking external dependencies ~
- OK rg: found ripgrep 14.1.1
- OK fd: found fd 10.2.0

===== Installed extensions ===== ~

Steps to reproduce

  1. nvim -nu minimal.lua
  2. Press space on a keyboard

Expected behavior

Telescope opens and searching works.

Actual behavior

Telescope doesn't open and the following error is shown:

E5108: Error executing lua: ...talls/neovim/nightly/share/nvim/runtime/lua/vim/iter.lua:251: flatten() requires an array-like table
stack traceback:
[C]: in function 'error'
...talls/neovim/nightly/share/nvim/runtime/lua/vim/iter.lua:251: in function 'flatten'
/tmp/nvim/site/telescope/lua/telescope/utils.lua:23: in function 'flatten'
/tmp/nvim/site/telescope/lua/telescope/builtin/__files.lua:156: in function 'v'
/tmp/nvim/site/telescope/lua/telescope/builtin/__files.lua:645: in function 'v'
/tmp/nvim/site/telescope/lua/telescope/builtin/init.lua:587: in function 'live_grep'
/Users/archil/scripts/minimal.lua:15: in function </Users/archil/scripts/minimal.lua:14>

Minimal config

local plugins = {
	plenary = "https://github.com/nvim-lua/plenary.nvim",
	telescope = "https://github.com/nvim-telescope/telescope.nvim",
}

for name, url in pairs(plugins) do
	local install_path = "/tmp/nvim/site/" .. name
	if vim.fn.isdirectory(install_path) == 0 then
		vim.fn.system({ "git", "clone", "--depth=1", url, install_path })
	end
	vim.o.runtimepath = install_path .. "," .. vim.o.runtimepath
end

vim.keymap.set("n", "<space>", function()
	require("telescope.builtin").live_grep({
		additional_args = function(args)
			return vim.list_extend(args, { "--hidden", "--no-ignore" })
		end,
	})
end)
@archilkarchava archilkarchava added the bug Something isn't working label Oct 25, 2024
@archilkarchava archilkarchava changed the title Telescope doesn't work when dict-like tables are passed to the flatten util live_grep doesn't work with additional_args (neovim 0.11) Oct 25, 2024
@archilkarchava archilkarchava changed the title live_grep doesn't work with additional_args (neovim 0.11) live_grep with additional_args doesn't work (neovim 0.11) Oct 25, 2024
archilkarchava added a commit to archilkarchava/astronvim_config that referenced this issue Oct 27, 2024
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

1 participant