In my current setup, if I enter neovim with nvim dir
, instead of opening with Netrw, I get the :Telescope find_files
prompt. To achieve that, I have to disable Netrw, or it opens in the background. Here's the configuration to achieve this:
-- Disable netrw
vim.g.loaded_netrwPlugin = 1
vim.g.loaded_netrw = 1
-- Open Telescope on startup if the first argument is a directory
local ts_group = vim.api.nvim_create_augroup("TelescopeOnEnter", { clear = true })
vim.api.nvim_create_autocmd({ "VimEnter" }, {
callback = function()
local first_arg = vim.v.argv[3]
if first_arg and vim.fn.isdirectory(first_arg) == 1 then
-- Vim creates a buffer for folder. Close it.
vim.cmd(":bd 1")
require("telescope.builtin").find_files({ search_dirs = { first_arg } })
end
end,
group = ts_group,
})
However, I still want to be able to invoke :Explore
sometimes, which is not possible with the configuration above.
How can I do that?
Take a look at https://github.com/nvim-telescope/telescope-file-browser.nvim, it should be customisable enough to add the normal fuzzy finder at startup. It has a hijack_netrw property that you can set to true. When you set it to true it will come up instead of netrw.