nvim-telescope / telescope-file-browser.nvim

File Browser extension for telescope.nvim
MIT License
1.6k stars 89 forks source link

File Browser won't work if there is a dir named github.com like "~/go/src/github.com/KRook/app/" #387

Closed KRook0110 closed 2 months ago

KRook0110 commented 2 months ago

Description

File Browser wont work if one of the parent dirs is named "github.com", it won't even detect the directory. ( I'm sorry for bad English, it's not my native language )

Neovim version

NVIM v0.9.4
Build type: Release
LuaJIT 2.1.1692716794

Operating system and version

debian 12 bookworm

Steps to reproduce

Here is my Telescope file browser pluigin

return {
    "nvim-telescope/telescope-file-browser.nvim",
    dependencies = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" },
    event="VeryLazy",
    config= function ()
        -- You don't need to set any of these options.
        -- IMPORTANT!: this is only a showcase of how you can set default options!
        require("telescope").setup {
            extensions = {
                file_browser = {
                    -- theme = "ivy",
                    -- disables netrw and use telescope-file-browser in its place
                    hijack_netrw = true,
                    mappings = {
                        ["i"] = {
                            -- your custom insert mode mappings
                        },
                        ["n"] = {
                            -- your custom normal mode mappings
                        },
                    },
                },
            },
        }
        -- To get telescope-file-browser loaded and working with telescope,
        -- you need to call load_extension, somewhere after setup function:
        require("telescope").load_extension "file_browser"

        vim.keymap.set("n", "<leader>e", function()
            require("telescope").extensions.file_browser.file_browser({

            })
        end)
    end
}

Telescope Config ( I doubt this is needed but just in case"

return {
    'nvim-telescope/telescope.nvim', tag = '0.1.6',
    -- or                              , branch = '0.1.x',
    dependencies = {
        'nvim-lua/plenary.nvim',
    },
    config = function()

        local actions = require("telescope.actions")
        require('telescope').setup {
            defaults = {
                file_ignore_patterns = {
                    "node_modules",
                    ".undo",
                    "undo",
                    ".git",
                },
                theme = "center",
                sorting_strategy = "ascending",
                layout_config = {
                    horizontal = {
                        prompt_position = "top",
                        preview_width = 0.3,
                    },
                },
                mappings = {
                    i = {
                        ["<esc>"] = actions.close,
                    },
                    n = {
                        ["q"] = actions.close,
                    }
                },
            },
        }

        local builtin = require('telescope.builtin')
        vim.keymap.set('n', '<leader>f', function() builtin.find_files({previewer = false}) end, {desc = "files"})
        vim.keymap.set('n', '<leader>S', builtin.current_buffer_fuzzy_find, {desc = "current buffer"})
        vim.keymap.set('n', '<leader>A', builtin.live_grep, {desc = "All"})
        vim.keymap.set('n', '<leader>FC', builtin.colorscheme, {desc = "Colorscheme"})
        vim.keymap.set('n', '<leader>Fc', builtin.registers, {desc= "Clipboard"})
        vim.keymap.set('n', '<leader>b', builtin.buffers, {desc = "Buffers"})
        vim.keymap.set('n', '<leader>o', builtin.treesitter, {desc = "Treesitter", silent=true, noremap = true})
        vim.keymap.set('n', '<leader>m', builtin.marks, {desc = "Marks", silent=true, noremap = true})
    end,

}

I have tried using no_ignore=true, hidden=true, and use_fd=false, nothing I try to configure works.

Expected behavior

file browser shows everything image

Actual behavior

File browser shows nothing image

Minimal config

local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/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",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  {
    "nvim-telescope/telescope-file-browser.nvim",
    dependencies = {
      "nvim-telescope/telescope.nvim",
      "nvim-lua/plenary.nvim",
    },
    config = function()
      require("telescope").setup({})
      require("telescope").load_extension("file_browser")
    end,
  },
}

require("lazy").setup(plugins, {
  root = root .. "/plugins",
})
jamestrew commented 2 months ago

Sorry I can seem to replicate this image

Maybe it's a directory permissions problem? There's nothing special about "github.com" being in the path I don't think.

KRook0110 commented 2 months ago

I apparently had ".git" in file_ignore_patterns in my telescope config. My bad...