nvim-telescope / telescope-fzf-native.nvim

FZF sorter for telescope written in c
1.4k stars 46 forks source link

Unable to load fzf extension #105

Closed exosyphon closed 1 year ago

exosyphon commented 1 year ago

Hello! This is almost certainly user error in trying to install this but I am getting the following error when trying to source the below line in my telescope.lua file:

require('telescope').load_extension('fzf')

telescope.lua

local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})

local telescope = require("telescope")
local telescopeConfig = require("telescope.config")

-- Clone the default Telescope configuration
local vimgrep_arguments = { unpack(telescopeConfig.values.vimgrep_arguments) }

-- I want to search in hidden/dot files.
table.insert(vimgrep_arguments, "--hidden")
-- I don't want to search in the `.git` directory.
table.insert(vimgrep_arguments, "--glob")
table.insert(vimgrep_arguments, "!**/.git/*")

telescope.setup({
    defaults = {
        -- `hidden = true` is not supported in text grep commands.
        vimgrep_arguments = vimgrep_arguments,
    },
    pickers = {
        find_files = {
            -- `hidden = true` will still show the inside of `.git/` as it's not `.gitignore`d.
            find_command = { "rg", "--files", "--hidden", "--glob", "!**/.git/*" },
        },
    },
    extensions = {
        fzf = {
            fuzzy = true,                    -- false will only do exact matching
            override_generic_sorter = true,  -- override the generic sorter
            override_file_sorter = true,     -- override the file sorter
            case_mode = "smart_case",        -- or "ignore_case" or "respect_case"
            -- the default case_mode is "smart_case"
        }
    }
})

require('telescope').load_extension('fzf')

Error:

E5108: Error executing lua: vim/_editor.lua:0: nvim_exec2()..:source (no file): Vim(source):E5108: Error executing lua .../start/telescope.nvim/lua/telescope/_extensions/init.lua:10: 'fzf' extension doesn't exist or isn't installed: loop or previous error loading module 'telescope._extensions.fzf'
stack traceback:
        [C]: in function 'error'
        .../start/telescope.nvim/lua/telescope/_extensions/init.lua:10: in function 'load_extension'
        .../start/telescope.nvim/lua/telescope/_extensions/init.lua:62: in function 'load_extension'
        [string ":source (no file)"]:41: in main chunk
        [C]: in function 'nvim_exec2'
        vim/_editor.lua: in function 'cmd'
        [string ":source (no file)"]:67: in function <[string ":source (no file)"]:66>
stack traceback:
        [C]: in function 'nvim_exec2'
        vim/_editor.lua: in function 'cmd'
        [string ":source (no file)"]:67: in function <[string ":source (no file)"]:66>

I have zoxide and it is using fzf so I believe I have fzf setup correctly. Any help would be greatly appreciated. Thank you!

packer.lua

  use {
      'nvim-telescope/telescope.nvim', tag = '0.1.1',
      requires = { {'nvim-lua/plenary.nvim'} }
  }
  use { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' }
 use { 'junegunn/fzf', run = ":call fzf#install()" }
 use 'junegunn/fzf.vim'
KapilSyamasundar commented 1 year ago

Ran into this too. I solved it by directly going to where the plugin was located and running make again. You'll find the plugin in your neovim data directory.

You can check if the extension properly installed with :checkhealth telescope and you should see fzf under Installed Extensions.

exosyphon commented 1 year ago

Thank you! This helped me track down the issue. I had forgotten I installed fzf using Homebrew and went back and ran this command $(brew --prefix)/opt/fzf/install to install the binary extensions and then removed use { 'junegunn/fzf', run = ":call fzf#install()" } from my packer.lua file and it all worked.