Open glyh opened 1 year ago
Before run vim.cmd('Telescope projects')
, run vim.cmd('Lazy load project_nvim')
first.
Or:
require('lazy').load({ plugins = { 'project_nvim' } })
vim.schedule(function()
vim.cmd('Telescope projects')
end)
Before run
vim.cmd('Telescope projects')
, runvim.cmd('Lazy load project_nvim')
first.Or:
require('lazy').load({ plugins = { 'project_nvim' } }) vim.schedule(function() vim.cmd('Telescope projects') end)
I still run into the same issue.
Paste your code.
I have the same issue.
I tried different lazy loading functions. Most would always open an empty telescope window on first load, without any projects, but would work every time after that. When wrapping it in vim.schedule()
, it sometimes shows projects on first try, sometimes not. Seems to be more likely to load the first time if I am slower with my keypresses, but that might be a coincidence. The line require('lazy').load({ plugins = { 'project_nvim' } })
doesn't seem to make a difference for me.
{
"ahmedkhalf/project.nvim",
keys = {
{ '<leader>hp',
function()
require('lazy').load({ plugins = { 'project_nvim' } })
vim.schedule(function()
vim.cmd('Telescope projects')
end)
end
}
},
config = function()
require("project_nvim").setup {}
require('telescope').load_extension('projects')
end,
dependencies = {
'nvim-telescope/telescope.nvim'
}
},
Could it be due to this (from readme):
Asynchronous file io so it will not slow down vim when reading the history file on startup.
Here is a minimal, working Lazy config for Telescope + Project.nvim:
{
"https://github.com/nvim-telescope/telescope.nvim",
branch = "0.1.x",
dependencies = {
"https://github.com/nvim-lua/plenary.nvim",
{
"https://github.com/ahmedkhalf/project.nvim",
config = function()
require("project_nvim").setup({})
end,
},
{
"https://github.com/nvim-telescope/telescope-fzf-native.nvim",
build = "make",
cond = function()
return vim.fn.executable("make") == 1
end,
},
},
config = function()
pcall(require("telescope").load_extension, "fzf")
pcall(require("telescope").load_extension, "projects")
vim.keymap.set(
"n",
"<leader>fp",
function() vim.cmd([[Telescope projects]]) end,
{ noremap = true }
)
}
@pbnj its easy to get it working, the problem is lazy loading it. I also have the same problem, its a blank window the first time, and only works every time after.
Here is project.nvim:
return {
'ahmedkhalf/project.nvim',
dependencies = {
'nvim-telescope/telescope.nvim',
},
config = function()
require('project_nvim').setup({
detection_methods = { 'pattern' },
patterns = { '.git' },
})
require('telescope').load_extension('projects')
end,
keys = {
{
'<Leader>p',
function() require('telescope').extensions.projects.projects() end,
desc = 'Switch project',
}
},
}
here is the relevant part of telescope plugin:
return {
'nvim-telescope/telescope.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-telescope/telescope-ui-select.nvim',
},
config = function()
...
end,
cmd = {
'Telescope',
},
So lazy.nvim is triggered when the Telescope
command is called, and for some reason vim.cmd('Telescope projects')
as well as require('telescope').extensions.projects.projects()
still cause the same issues
Note that adding event = 'VeryLazy'
added after the 'ahmedkhalf/project.nvim',
does work, but then that loads the entire telescope and all associated code there which is hefty code to load at boot when every single telescope plugin is triggered from a hotkey
I'm also having the same issue sadly
The same also happens to me.
not fixed yet, project.nvim keeps showing nothing
hello, you guys. I found this work for me
keys = {
{
"<leader>fp",
vim.schedule_wrap(function()
require("telescope").extensions.projects.projects({})
end),
},
},
so project.nvim
with trigger on keys.
The problem is that the plugin reads the file containing the history asynchronously when it's setup is ran. So when the plugin is lazy loaded, the Telescope picker opens before the history is read.
I haven't been able to dive in long enough to find a solution.
Do we require the asynchronous file reading? I can't imagine reading the history file takes a noticeable amount of time. It'd be simpler to read the history synchronous upon opening the picker.
Using vim.schedule_wrap
solved the problem for me
If I run project.nvim lazily, it won't show any projects registered the first time.
It's clear that it can be bring up by telescope. ![Uploading image.png…]()