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

Telescope Setup -- find_command #2299

Closed
mthomps4 opened this issue Jan 4, 2023 · 7 comments
Closed

Telescope Setup -- find_command #2299

mthomps4 opened this issue Jan 4, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@mthomps4
Copy link

mthomps4 commented Jan 4, 2023

Description

The below works from both the command line and keybindings, but does not seem to work when placing within the telescope.setup({pickers block

Works:

:Telescope find_files find_command=rg,--ignore,--hidden,--files,-u,--glob,!**/.git/*,--glob,!**/node_modules/*
vim.keymap.set('n', '<leader>ff', ":Telescope find_files find_command=rg,--ignore,--hidden,--files,-u,--glob,!**/.git/*,--glob,!**/node_modules/*,--glob,!**/.next/*<CR>")

Not working

    pickers = {
      find_files = {
        find_command = {"rg", "--files", "--hidden", "--ignore", "-u", "--glob=!**/.git/*", "--glob=!**/node_modules/*"},    
      }
    },

Neovim version

NVIM v0.8.2
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@Ventura

Operating system and version

macOS 13.0.1

Telescope version / branch / rev

telescope branch: 0.1.x

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
  - WARNING: fd: not found. Install [sharkdp/fd](https://github.com/sharkdp/fd) for extended capabilities

## ===== Installed extensions =====

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

Steps to reproduce

Keybindings reverted back to below via docs:

vim.keymap.set('n', '<leader>ff', builtin.find_files, {})

add to setup

    pickers = {
      find_files = {
        find_command = {"rg", "--files", "--hidden", "--ignore", "-u", "--glob=!**/.git/*", "--glob=!**/node_modules/*"},    
      }
    },
  • open a project in nvim
  • ff
  • Search for hidden file or ignored file.

Expected behavior

Hidden and Ignored files are found.
Example:

  • ff
  • search .env.loc
  • see .env.local file

image

Actual behavior

With setup > long string keybind

  • ff
  • search .env.loc
  • no files found

image

Minimal config

vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvim/site]]
local package_root = '/tmp/nvim/site/pack'
local install_path = package_root .. '/packer/start/packer.nvim'
local function load_plugins()
  require('packer').startup {
    {
      'wbthomason/packer.nvim',
      {
        'nvim-telescope/telescope.nvim',
        requires = {
          'nvim-lua/plenary.nvim',
          { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' },
        },
      },
      -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. '/plugin/packer_compiled.lua',
      display = { non_interactive = true },
    },
  }
end
_G.load_config = function()
  require('telescope').setup({
    pickers = {
      find_files = {
        find_command = {"rg", "--files", "--hidden", "--ignore", "-u", "--glob=!**/.git/*", "--glob=!**/node_modules/*", "--glob=!**/.next/*"},    
      }
    }
})
  require('telescope').load_extension('fzf')
  -- ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
end
if vim.fn.isdirectory(install_path) == 0 then
  print("Installing Telescope and dependencies.")
  vim.fn.system { 'git', 'clone', '--depth=1', 'https://github.com/wbthomason/packer.nvim', install_path }
end
load_plugins()
require('packer').sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua load_config()]]
@mthomps4 mthomps4 added the bug Something isn't working label Jan 4, 2023
@Conni2461
Copy link
Member

it works with the minimal rc for me. Could you reproduce this issue with running the minimal rc? nvim -nu min.lua

@Conni2461
Copy link
Member

found the issue, i forgot to backport a fix to 0.1.x that was already merged into master. I am going to do that now

@Conni2461
Copy link
Member

The fix (and a bunch of more fixes) are now all backported. Can you confirm that it works? Then we can close this issue

@mthomps4
Copy link
Author

mthomps4 commented Jan 7, 2023

@Conni2461 Thank you so much for the quick reply.
Making sure I'm not overlooking something, but seem to still be hitting the same issue.

  • resaved plugin-config -- saw changes from 11 hours ago
  • Keybinding is now vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
  • telescope config:
    pickers = {
      find_files = {
        find_command = {"rg", "--files", "--hidden", "--ignore", "-u", "--glob=!**/.git/*", "--glob=!**/node_modules/*"},    
      }
    },

@mthomps4
Copy link
Author

mthomps4 commented Jan 9, 2023

Tried a few more things -- more of the same.
Deleted the plugin download cache from packer.
Reinstalled
Tried both tag and branch
Added fd
I see the fixes that were merged -- but it's still only working for me if I do the long hand below.

vim.keymap.set('n', '<leader>ff', ":Telescope find_files find_command=rg,--ignore,--hidden,--files,-u,--glob,!**/.git/*,--glob,!**/node_modules/*,--glob,!**/.next/*<CR>")

Left with ☝🏼 for now.

@jneidel
Copy link

jneidel commented Apr 16, 2023

I couldn't make it work with --glob or --iglob with rg, but declaring the stuff I want to ignore in file_ignore_patterns works as expected:

telescope.setup {
    defaults = {
      file_ignore_patterns = {
        "node_modules/",
        "vendor/",
        ".git/"
    }
  }
}

@jamestrew
Copy link
Contributor

pretty the glob flag and the glob pattern should be in their own separate strings.
something like
"--glob=!**/.git/*" -> "--glob", "!**/.git/*"

I've been using this for a while.

I'm going to close this as I don't think this is a bug and at worst it looks like there's some workarounds.

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

4 participants