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.run_command] : Unknown command #235

Closed
AyushSehrawat opened this issue Feb 18, 2023 · 4 comments
Closed

[telescope.run_command] : Unknown command #235

AyushSehrawat opened this issue Feb 18, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@AyushSehrawat
Copy link

AyushSehrawat commented Feb 18, 2023

Description

Initiating the file browser via the custom keybindings is giving the error of saying unknown command

Neovim version

NVIM v0.8.3
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by runner@fv-az183-550

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/share/nvim"

Run :checkhealth for more info

Operating system and version

Ubuntu 22.10

Steps to reproduce

1.) Add file-browser.lua in your plugins folder of nvim config
2.) Copy the following code

return {
  "nvim-telescope/telescope-file-browser.nvim",
  keys = {
    {
      "<leader>sB",
      ":Telescope file_browser path=%:p:h=%:p:h<cr>",
      desc = "Browse Files",
    },
    config = function()
      require("telescope").load_extension("file_browser")
    end,
  },
}

Expected behavior

To open the file browser

Actual behavior

Giving error while running the command

image

Minimal config

// no minimal config provided
@AyushSehrawat AyushSehrawat added the bug Something isn't working label Feb 18, 2023
@AyushSehrawat
Copy link
Author

I am sorry for not adding the minimal config, since i am not that good with neovim config and was using LazyVim.
I added the config to ~/.config/nvim/lua/plugins folder

@AyushSehrawat
Copy link
Author

Also mentioned in doom-neovim/doom-nvim#357 with no response

@jamestrew
Copy link
Collaborator

I see several issues/potential issues with your config.
Main one being you missed a closing bracket for your keys table; so you config function is actually inside of keys and so it's not being called -> file_browser extension isn't being loaded.

But beyond that, just looking at your config file structure via neo-tree, I just want to confirm that you have all the dependencies for telescope and that you're calling the setup function (which I think you are).
Also, in the key mapping itself, I think you have an extra =%:p:h in there. Don't think it's an issue but yeah.

Here's a minimal config if you want to test/see for yourself. I can copy this into a directory in /tmp and start neovim using it with nvim -nu min.lua.

-- DO NOT change the paths and don't remove the colorscheme
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.nvim",
	dependencies = {
		"nvim-lua/plenary.nvim",
		"nvim-telescope/telescope-file-browser.nvim",
	},
	keys = {
		{
			"<leader>sB",
			":Telescope file_browser path=%:p:h<cr>",
			desc = "Browse Files",
		},
	},
	config = function()
		require("telescope").setup({})
		require("telescope").load_extension("file_browser")
	end,
}

vim.g.mapleader = " " -- change this to your preferred leader key
require("lazy").setup(plugins, {
	root = root .. "/plugins",
})

vim.cmd.colorscheme("habamax")

@AyushSehrawat
Copy link
Author

Thanks @jamestrew , after some modifies to the lua file from the minimal config you provided, it's working fine

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

2 participants