nvim-telescope/telescope.nvim

Telescope current_buffer_fuzzy_find not working when directory end with "git"

hmgle opened this issue ยท 3 comments

hmgle commented

Description

I've encountered a bug with the :Telescope current_buffer_fuzzy_find command when the directory of the currently edited file ends with "git".

Neovim version

NVIM v0.10.0-dev-3036+gab1c2220f
Build type: RelWithDebInfo
LuaJIT 2.1.1713484068

Operating system and version

Arch Linux / macOS 10.15.7

Telescope version / branch / rev

35f94f0

checkhealth telescope

telescope: require("telescope.health").check()

Checking for required plugins ~
- OK plenary installed.
- OK nvim-treesitter installed.

Checking external dependencies ~
- OK rg: found ripgrep 13.0.0
- OK fd: found fd 8.4.0

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

Telescope Extension: `fzf` ~
- OK lib working as expected
- OK file_sorter correctly configured
- OK generic_sorter correctly configured

Telescope Extension: `yank_history` ~
- No healthcheck provided

Steps to reproduce

  1. Create a new directory with a name that ends in "git" (e.g., mkdir testgit).
  2. Write some content to a file within this directory(e.g., cd testgit && echo "some content" > test.txt).
  3. Invoke the :Telescope current_buffer_fuzzy_find command(e.g., nvim test.txt and :Telescope current_buffer_fuzzy_find).

Expected behavior

No response

Actual behavior

Observe that the command does not function as expected, showing no results.

Minimal config

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

require("lazy").setup({
    {
        'nvim-telescope/telescope.nvim',
        config = function()
            require('config.telescope')
        end,
        enabled = true,
    },
})

require('telescope').setup{
  defaults = {
    mappings = {
      i = {
        ["<C-h>"] = "which_key"
      }
    }
  },
  pickers = {
  },
  extensions = {
  }
}

@hmgle, using this as minimal setup, does not seem to throw any errors or any malfunctions.

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", -- latest stable release
		lazypath,
	})
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
	{
		"nvim-telescope/telescope.nvim",
		dependencies = {
			"nvim-lua/plenary.nvim",
		},
		config = function()
			require("telescope").setup({
				defaults = {
					mappings = {
						i = {
							["<C-h>"] = "which_key",
						},
					},
				},
				pickers = {},
				extensions = {},
			})
		end,
		enabled = true,
	},
})

Important

In your minimal setup config.telescope does not exist, and plenary is not added but is required for telescope to work. Also lazy is not prepended to the runtime path in order to be required.

Telescope.current_buffer_fuzzy_find.with.minimal.mp4

Maybe your config.telescope has something wrong. If you can paste it to see if something is out of the ordinary so we can help you out to track down the problem.

Note

With my own config, it does not throw any errors either.

@hmgle I went through your config.telescope and I think I found the issue.

https://github.com/hmgle/nvim/blob/main/lua/config/telescope.lua#L54-L59

telescope.setup({
  defaults = {
    prompt_prefix = '๐Ÿ” ',
    file_ignore_patterns = {
-      '.git/',
+      '%.git/',
    },

Note

Using the patterns without % I think it means that is using . as RegEx, trying to match all that contains git in the word, not sure though.
But with % works perfectly.

I just tried with my config removing it and it :Telescope current_buffer_fuzzy_find didn't show any results, but with % it works.

hmgle commented

@AlejandroSuero Thank you so much taking the time and effort to investigate this issue and your patience in responding and providing valuable suggestions! This bug does come from my configuration and not a bug in telescope.
In the future, I will be more cautious when submitting issues, ensuring that I provide complete and accurate information to avoid causing unnecessary hassle for everyone.