LazyVim.LazyVim/lua/lazyvim/plugins/xtras.lua
Jinfeng Guo 401ef48fcd
feat(snacks.picker): added support for Project shortcuts in other dashboards (#5607)
…shboard-nvim, and mini-starter

## Description

Though the snacks.picker extra provides a project picker, it only adds
the 'Projects' shortcut to snacks' dashboard, and no to the other three
dashboard extra: alpha, dashboard-nvim and mini-starter. In this PR, I
added the 'Projects' shortcuts to these three dashboard extras.

<!-- Describe the big picture of your changes to communicate to the
maintainers
  why we should accept this pull request. -->

## Related Issue(s)

<!--
  If this PR fixes any issues, please link to the issue here.
  - Fixes #<issue_number>
-->

- Fixes #5465

## Screenshots

<!-- Add screenshots of the changes if applicable. -->

alpha


![image](https://github.com/user-attachments/assets/c050f260-8602-4660-a386-62ab8400ef87)

dashboard-nvim


![image](https://github.com/user-attachments/assets/8973cd62-ba97-4330-9462-74163b58dca9)

mini.starter


![image](https://github.com/user-attachments/assets/a31ec27d-7efb-4aa3-a136-2a4ffedf5ba1)

## Checklist

- [x] I've read the
[CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md)
guidelines.
2025-02-15 08:30:45 +01:00

70 lines
1.9 KiB
Lua

-- Some extras need to be loaded before others
local prios = {
["lazyvim.plugins.extras.test.core"] = 1,
["lazyvim.plugins.extras.dap.core"] = 1,
["lazyvim.plugins.extras.coding.nvim-cmp"] = 2,
["lazyvim.plugins.extras.ui.edgy"] = 2,
["lazyvim.plugins.extras.lang.typescript"] = 5,
["lazyvim.plugins.extras.coding.blink"] = 5,
["lazyvim.plugins.extras.formatting.prettier"] = 10,
-- default core extra priority is 20
-- default priority is 50
["lazyvim.plugins.extras.editor.aerial"] = 100,
["lazyvim.plugins.extras.editor.outline"] = 100,
["lazyvim.plugins.extras.ui.alpha"] = 19,
["lazyvim.plugins.extras.ui.dashboard-nvim"] = 19,
["lazyvim.plugins.extras.ui.mini-starter"] = 19,
}
if vim.g.xtras_prios then
prios = vim.tbl_deep_extend("force", prios, vim.g.xtras_prios or {})
end
local extras = {} ---@type string[]
local defaults = LazyVim.config.get_defaults()
-- Add extras from LazyExtras that are not disabled
for _, extra in ipairs(LazyVim.config.json.data.extras) do
local def = defaults[extra]
if not (def and def.enabled == false) then
extras[#extras + 1] = extra
end
end
-- Add default extras
for name, extra in pairs(defaults) do
if extra.enabled then
prios[name] = prios[name] or 20
extras[#extras + 1] = name
end
end
---@type string[]
extras = LazyVim.dedup(extras)
local version = vim.version()
local v = version.major .. "_" .. version.minor
local compat = { "0_9" }
LazyVim.plugin.save_core()
if vim.tbl_contains(compat, v) then
table.insert(extras, 1, "lazyvim.plugins.compat.nvim-" .. v)
end
if vim.g.vscode then
table.insert(extras, 1, "lazyvim.plugins.extras.vscode")
end
table.sort(extras, function(a, b)
local pa = prios[a] or 50
local pb = prios[b] or 50
if pa == pb then
return a < b
end
return pa < pb
end)
---@param extra string
return vim.tbl_map(function(extra)
return { import = extra }
end, extras)