nvimdev / dashboard-nvim

vim dashboard
MIT License
2.3k stars 187 forks source link

dashboard dont show project #357

Open TheElegantCoding opened 1 year ago

TheElegantCoding commented 1 year ago

This is mi setup of neovim and currently i am using 'ahmedkhalf/project.nvim' for load projects with telescope

dashboard.setup({
  theme = 'hyper',
    config = {
      packages = { enable = false },
        project = {
          limit = 5,
            label = 'projects',
            action = 'Telescope projects',
        },
        mru = {
          limit = 5,
      label = 'recent files',
      action = 'Telescope oldfiles',
     },
   },
})

This config show no projects and also even if i put Telescope find_files cwd=some_path dont show nothing, but there are projects in my telescope

Here is the list of the projects

image

glepnir commented 1 year ago

project on dashboard is not relate any 3rd part plugin. i have own implemention. it will record your project when you quit neovim and when you open next time you will see the projects you opened.

TheElegantCoding commented 1 year ago

as i say even without the command Telescope find_files cwd=some_path, witout any third party show nothing, the ./cache file is empty only if i put manually in the cache file the table show something

basically is like the action is not working

glepnir commented 1 year ago

hmm that' mean no data in cache or data is correct just action not work ?

TheElegantCoding commented 1 year ago

@glepnir Yes no data in cache the file is empty, no mather what i run the action, i dont speak chinesse but with translate @LeeeSe say is an error in hyper theme

glepnir commented 1 year ago

looks like a bug in windows. I need a windows env to reproduce probably

LeeeSe commented 1 year ago

M1 Mac also

glepnir commented 1 year ago

can't reproduce it works fine on my mac. btw the project need lspconfig . so maybe you don't use lspconfig ?

Dhagash4 commented 11 months ago

I am having the same issue, can someone share the config if its working for them. I have mac m2.

I did some checking and manually added

local data = 'return {"path to project"}' to this line

And then it showed the project folder in the recent projects but then telescope find files withing the folder was not working. I guess the problem might be not having the correct path to data or data is empty.

But as I am new don't know what to do with this as, any help is appreciated. Thanks :D Attached my dashboard.lua

require("dashboard").setup({
  theme = "hyper",
  config = {
    plugin = {
      enable = false,
    },
    week_header = {
      enable = true,
    },
    project = {
      enable = true,
      action = "Telescope find_files cwd="
    },
    shortcut = {
      {
        icon = " ",
        icon_hl = "@variable",
        desc = "Files",
        group = "Label",
        action = "Telescope find_files",
        key = "f",
      },
      {
        desc = " Config",
        action = "e ~/.config/nvim/init.vim",
        key = "e",
      },
    },
  },
})
Riyyi commented 7 months ago

I wrote some glue to sync projects entries between dashboard-nvim and projects.nvim. This can be put anywhere in your config:

-- Add syncing between project.nvim and dashboard-nvim project entries
vim.api.nvim_create_autocmd({ "VimLeavePre" }, {
    pattern = { "*" },
    callback = function()
        local merge_unique = function(t1, t2)
            local result = {}
            local seen_values = {}
            for _, value in ipairs(vim.tbl_flatten({ t1, t2 })) do
                if not seen_values[value] then
                    seen_values[value] = true
                    table.insert(result, value)
                end
            end

            return result
        end

        -- Fetch project.nvim projects
        local project = require("project_nvim.project")
        local history = require("project_nvim.utils.history")
        local recent = history.recent_projects or {}
        local session = history.session_projects or {}
        local recent_plus_session = merge_unique(recent, session)

        -- Fetch dashboard-nvim projects
        local utils = require("dashboard.utils")
        local path = utils.path_join(vim.fn.stdpath("cache"), "dashboard/cache")
        local projects = utils.read_project_cache(path) or {}

        -- Add any projects that project.nvim uniquely knows about to dashboard-nvim
        local all_projects = merge_unique(recent_plus_session, projects)
        vim.fn.writefile({ "return " .. vim.inspect(all_projects) }, path)

        -- Add any projects that dashboard-nvim uniquely knows about to project.nvim
        local should_save = false
        for _, value in ipairs(projects) do
            if not vim.tbl_contains(recent_plus_session, value) then
                pcall(project.set_pwd, value, "manual") -- skip non-existent directories, dont error
                should_save = true
            end
        end
        if should_save then history.write_projects_to_history() end -- < remove this line
    end,
})
-- put setup here

Note that with this code the files dashboard/cache and project_nvim/project_history are saved twice on exit. You can prevent the duplicate save of project_nvim, to do this you can remove the write history line and put your project_nvim setup call (require("project_nvim").setup({...})) after the entire block, so its VimLeavePre autocmd is configured after the glue code.

itamark-targa commented 7 months ago

project on dashboard is not relate any 3rd part plugin. i have own implemention. it will record your project when you quit neovim and when you open next time you will see the projects you opened.

Sorry I know it's an ultra-old issue but I searched everywhere inc the source code, and I just can't figure out - how to save a project? The Only cmd available in nvim is Dashboard which brings the main plugin window, but my projects list is empty and I couldn't find any cmd to save a project.. do I have to define some folder etc. where projects are saves? This is my minimal setup using Lazy:

return {
    'nvimdev/dashboard-nvim',
    event = 'VimEnter',
    config = function()
        require('dashboard').setup {
            -- config
            shortcut_type = 'number'       
        }
    end,
    dependencies = { {'nvim-tree/nvim-web-devicons'}}
}
Riyyi commented 7 months ago

@itamark-targa it stores projects when you exit neovim to vim.fn.stdpath("cache")/dashboard/cache, which has a table of string filepaths:

return { "/full/path/to/project1", "/full/path/to/project2" }

It asks the builtin vim lsp API for the projects to register, that are open at the moment of closing, vim.lsp.get_active_clients() found in /lua/dashboard/events.lua

itamark-targa commented 7 months ago

@itamark-targa it stores projects when you exit neovim to vim.fn.stdpath("cache")/dashboard/cache, which has a table of string filepaths:

return { "/full/path/to/project1", "/full/path/to/project2" }

It asks the builtin vim lsp API for the projects to register, that are open at the moment of closing, vim.lsp.get_active_clients() found in /lua/dashboard/events.lua

Thanks, I am quitting neovim using qa, checking the file vim.fn.stdpath("cache")/dashboard/cache which points to ~/.cache/nvim/dashboard/cache I see it is empty, and next time I open neovim, the project list in the Dashboard screen is empty. Any idea?

hydroakri commented 6 months ago

Now I edit ~/.cache/nvim/dashboard/cache manually to use the projects in the dashboard. :\

claf commented 4 months ago

Same here, this cache file got two entries at some point (I don't know how) but nothing new is added to this file. Something must be broken somewhere (using latest LazyVim here).

nydragon commented 3 months ago

For me it only adds a project if I open a file through the most recent files list