dashboard-nvim icon indicating copy to clipboard operation
dashboard-nvim copied to clipboard

dashboard dont show project

Open TheElegantCoding opened this issue 2 years ago • 15 comments

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

TheElegantCoding avatar May 17 '23 06:05 TheElegantCoding

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.

glepnir avatar May 17 '23 07:05 glepnir

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

TheElegantCoding avatar May 17 '23 14:05 TheElegantCoding

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

glepnir avatar May 18 '23 06:05 glepnir

同样的错误,仅仅是切换到 Doom 即可看到项目列表,切回Hyper则不可以,action是一样的

local status, db = pcall(require, "dashboard")
if not status then
  vim.notify("没有找到 dashboard")
  return
end

db.setup({
  -- theme = 'Doom',
  theme = 'Hyper',
  config = {
    header = {
      [[]],
      [[]],
      [[]],
      [[]],
      [[]],
      [[██╗     ███████╗███████╗███████╗███████╗███████╗]],
      [[██║     ██╔════╝██╔════╝██╔════╝██╔════╝██╔════╝]],
      [[██║     █████╗  █████╗  █████╗  ███████╗█████╗  ]],
      [[██║     ██╔══╝  ██╔══╝  ██╔══╝  ╚════██║██╔══╝  ]],
      [[███████╗███████╗███████╗███████╗███████║███████╗]],
      [[╚══════╝╚══════╝╚══════╝╚══════╝╚══════╝╚══════╝]],
      [[                                                ]],
      [[                                                ]],
      [[]],
      [[]],
    },

    center = {
      {
        icon = "  ",
        desc = "Projects                            ",
        action = "Telescope projects",
      },
      {
        icon = "  ",
        desc = "Recently files                      ",
        action = "Telescope oldfiles",
      },
      {
        icon = "  ",
        desc = "Edit keybindings                    ",
        action = "edit ~/.config/nvim/lua/keybindings.lua",
      },
      {
        icon = "  ",
        desc = "Edit Projects                       ",
        action = "edit ~/.local/share/nvim/project_nvim/project_history",
      },
      -- {
      --   icon = "  ",
      --   desc = "Edit .bashrc                        ",
      --   action = "edit ~/.bashrc",
      -- },
      -- {
      --   icon = "  ",
      --   desc = "Change colorscheme                  ",
      --   action = "ChangeColorScheme",
      -- },
      -- {
      --   icon = "  ",
      --   desc = "Edit init.lua                       ",
      --   action = "edit ~/.config/nvim/init.lua",
      -- },
      -- {
      --   icon = "  ",
      --   desc = "Find file                           ",
      --   action = "Telescope find_files",
      -- },
      -- {
      --   icon = "  ",
      --   desc = "Find text                           ",
      --   action = "Telescopecope live_grep",
      -- },
    },

    footer = {
      "",
      "",
      "https://github.com/LeeeSe",
    },
    project = { limit = 8, action = 'Telescope projects' },
  }
})

LeeeSe avatar May 18 '23 10:05 LeeeSe

@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

TheElegantCoding avatar May 18 '23 20:05 TheElegantCoding

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

glepnir avatar May 19 '23 00:05 glepnir

M1 Mac also

LeeeSe avatar May 19 '23 04:05 LeeeSe

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

glepnir avatar May 19 '23 04:05 glepnir

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",
      },
    },
  },
})

Dhagash4 avatar Sep 16 '23 16:09 Dhagash4

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.

Riyyi avatar Feb 03 '24 22:02 Riyyi

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'}}
}

itamark-targa avatar Feb 07 '24 15:02 itamark-targa

@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

Riyyi avatar Feb 07 '24 19:02 Riyyi

@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?

itamark-targa avatar Feb 08 '24 12:02 itamark-targa

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

hydroakri avatar Mar 06 '24 14:03 hydroakri

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).

claf avatar Apr 29 '24 19:04 claf

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

nydragon avatar May 22 '24 06:05 nydragon