Skip to content

bug: Snaks picker integration doesn't respect cwd parameter #629

@achojo

Description

@achojo

Did you check docs and existing issues?

  • I have read all the trouble.nvim docs
  • I have updated the plugin to the latest version before submitting this issue
  • I have searched the existing issues of trouble.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.10.4

Operating system/version

Arch Linux

Describe the bug

when searching files with snacks files picker with other cwd

Snacks.picker.files({ cwd = other_cwd })

then using 'trouble_open' action to show results in trouble window, it actually shows the results without considering the cwd parameter, it shows files in neovim's working directory

same thing is happening with Snacks.picker.grep

Steps To Reproduce

  1. mkdir -p mydir/mysubdir
  2. echo test > mydir/mysubdir/test.txt
  3. cd mydir && nvim
  4. :lua Snacks.picker.files({ cwd = vim.fn.getcwd() .. '/mysubdir' })
  5. use 'trouble_open' action to show the results in trouble window then try to open the file, it will open mydir/test.txt
  6. :lua vim.print(vim.fn.bufname())

Expected Behavior

Using 'trouble_open' action should show files with right paths

Repro

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
	spec = {
		{
			"folke/trouble.nvim",
			opts = {},
			specs = {
				"folke/snacks.nvim",
				opts = function(_, opts)
					return vim.tbl_deep_extend("force", opts or {}, {
						picker = {
							actions = require("trouble.sources.snacks").actions,
							win = {
								input = {
									keys = {
										["<c-q>"] = {
											"trouble_open",
											mode = { "n", "i" },
										},
									},
								},
							},
						},
					})
				end,
			},
		},
		{ "folke/snacks.nvim" },
	},
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstale

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions