nvim-telescope / telescope.nvim

Find, Filter, Preview, Pick. All lua, all the time.
MIT License
15.96k stars 838 forks source link

current_buffer_fuzzy_find fails if using get_generic_fuzzy_sorter #2941

Closed szevzol closed 8 months ago

szevzol commented 8 months ago

Description

I experienced this issue in NvChad but I was able to narrow it down to telescope and fzf extension.

current_buffer_fuzzy_find throws the following error when tryin to jump to the searched word.

E5108: Error executing lua: ...r\start\telescope.nvim/lua/telescope/builtin/__files.lua:552: attempt to compare two table values
stack traceback:
        ...r\start\telescope.nvim/lua/telescope/builtin/__files.lua:552: in function 'run_replace_or_original'
        ...packer\start\telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'key_func'
        ...k\packer\start\telescope.nvim/lua/telescope/mappings.lua:269: in function <...k\packer\start\telescope.nvim/lua/telescope/mappings.lua:268>

My investigation follows.

NvChad is using the following generic_sorter setting:

generic_sorter = require('telescope.sorters').get_generic_fuzzy_sorter

If I set this at the setup() funtion in minimal.lua then issue can be reproduced.

As a workaround, in NvChad custom/plugins.lua I can either:

Neovim version

NVIM v0.9.5
Build type: RelWithDebInfo
LuaJIT 2.1.1703942320
Compilation: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe /MD /Zi /O2 /Ob1  -W3 -wd4311 -wd4146 -DUNIT_TESTING -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_WIN32_WINNT=0x0602 -DMSWIN -DINCLUDE_GENERATED_DECLARATIONS -ID:/a/neovim/neovim/.deps/usr/include/luajit-2.1 -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/build/src/nvim/auto -ID:/a/neovim/neovim/build/include -ID:/a/neovim/neovim/build/cmake.config -ID:/a/neovim/neovim/src -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include

   system vimrc file: "$VIM\sysinit.vim"
  fall-back for $VIM: "C:/Program Files (x86)/nvim/share/nvim"

Operating system and version

Microsoft Windows 10 Enterprise 10.0.19045 Build 19045

Telescope version / branch / rev

master / a5b69afa484038f1c4793e979d023edb478ebc0c

checkhealth telescope

telescope: require("telescope.health").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.0 (rev e50df40a19)
- OK fd: found fd 9.0.0

===== Installed extensions =====

Steps to reproduce

  1. add generic sorter setting to setup in minimal.lua
  2. nvim -u minimal.lua
  3. :Telescope current_buffer_fuzzy_find
  4. search for a word and enter

Expected behavior

Jumping to the searched word

Actual behavior

Following error is thrown:

E5108: Error executing lua: ...r\start\telescope.nvim/lua/telescope/builtin/__files.lua:552: attempt to compare two table values
stack traceback:
        ...r\start\telescope.nvim/lua/telescope/builtin/__files.lua:552: in function 'run_replace_or_original'
        ...packer\start\telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'key_func'
        ...k\packer\start\telescope.nvim/lua/telescope/mappings.lua:269: in function <...k\packer\start\telescope.nvim/lua/telescope/mappings.lua:268>

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 {
    defaults = {
      generic_sorter = require('telescope.sorters').get_generic_fuzzy_sorter
    }
  }
  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()]]
jamestrew commented 8 months ago

Thanks, should be good now.