From 2a4bd2bdbb3523f1a8d9f61888852842b6e4131b Mon Sep 17 00:00:00 2001 From: Micah Halter Date: Thu, 3 Oct 2024 12:14:07 -0400 Subject: [PATCH] feat(pack): add an NvChad UI pack --- lua/astrocommunity/pack/nvchad-ui/README.md | 5 + lua/astrocommunity/pack/nvchad-ui/init.lua | 276 ++++++++++++++++++++ 2 files changed, 281 insertions(+) create mode 100644 lua/astrocommunity/pack/nvchad-ui/README.md create mode 100644 lua/astrocommunity/pack/nvchad-ui/init.lua diff --git a/lua/astrocommunity/pack/nvchad-ui/README.md b/lua/astrocommunity/pack/nvchad-ui/README.md new file mode 100644 index 000000000..2637852a9 --- /dev/null +++ b/lua/astrocommunity/pack/nvchad-ui/README.md @@ -0,0 +1,5 @@ +# NvChad/ui + +Lightweight & high performance UI plugin for nvchad + +**Repository:** diff --git a/lua/astrocommunity/pack/nvchad-ui/init.lua b/lua/astrocommunity/pack/nvchad-ui/init.lua new file mode 100644 index 000000000..142d1583c --- /dev/null +++ b/lua/astrocommunity/pack/nvchad-ui/init.lua @@ -0,0 +1,276 @@ +return { + "NvChad/ui", + opts = { + base46 = { + theme = "onedark", -- default theme + hl_add = {}, + hl_override = {}, + integrations = {}, + changed_themes = {}, + transparency = false, + theme_toggle = { "onedark", "one_light" }, + }, + + ui = { + cmp = { + icons_left = false, -- only for non-atom styles! + lspkind_text = true, + style = "default", -- default/flat_light/flat_dark/atom/atom_colored + format_colors = { + tailwind = false, -- will work for css lsp too + icon = "󱓻", + }, + }, + + telescope = { style = "borderless" }, -- borderless / bordered + + statusline = { + theme = "default", -- default/vscode/vscode_colored/minimal + -- default/round/block/arrow separators work only for default statusline theme + -- round and block will work for minimal theme only + separator_style = "default", + order = nil, + modules = nil, + }, + + -- lazyload it when there are 1+ buffers + tabufline = { + enabled = true, + lazyload = true, + order = { "treeOffset", "buffers", "tabs", "btns" }, + modules = nil, + }, + }, + + nvdash = { + load_on_startup = false, + header = { + " █████ ███████ ████████ ██████ ██████", + "██ ██ ██ ██ ██ ██ ██ ██", + "███████ ███████ ██ ██████ ██ ██", + "██ ██ ██ ██ ██ ██ ██ ██", + "██ ██ ███████ ██ ██ ██ ██████", + " ", + " ███ ██ ██ ██ ██ ███ ███", + " ████ ██ ██ ██ ██ ████ ████", + " ██ ██ ██ ██ ██ ██ ██ ████ ██", + " ██ ██ ██ ██ ██ ██ ██ ██ ██", + " ██ ████ ████ ██ ██ ██", + "", + "", + "", + }, + + buttons = { + { txt = " Find File", keys = "Spc f f", cmd = "Telescope find_files" }, + { txt = " Recent Files", keys = "Spc f o", cmd = "Telescope oldfiles" }, + { txt = "󰈭 Find Word", keys = "Spc f w", cmd = "Telescope live_grep" }, + { txt = "󱥚 Themes", keys = "Spc f t", cmd = ":lua require('nvchad.themes').open()" }, + { txt = " Last Session", keys = "Spc S l", cmd = "NvCheatsheet" }, + + { txt = "─", hl = "NvDashLazy", no_gap = true, rep = true }, + + { + txt = function() + local stats = require("lazy").stats() + local ms = math.floor(stats.startuptime) .. " ms" + return " Loaded " .. stats.loaded .. "/" .. stats.count .. " plugins in " .. ms + end, + hl = "NvDashLazy", + no_gap = true, + }, + + { txt = "─", hl = "NvDashLazy", no_gap = true, rep = true }, + }, + }, + + colorify = { + enabled = true, + mode = "virtual", -- fg, bg, virtual + virt_text = "󱓻 ", + highlight = { hex = true, lspvars = true }, + }, + }, + init = function() + -- load the lazy opts on module load + package.preload["chadrc"] = function() + local plugin = require("lazy.core.config").spec.plugins["ui"] + return require("lazy.core.plugin").values(plugin, "opts", false) -- resolve mini.clue options + end + end, + config = function() + pcall(function() + dofile(vim.g.base46_cache .. "defaults") + dofile(vim.g.base46_cache .. "statusline") + end) + require "nvchad" + end, + specs = { + { + "hrsh7th/nvim-cmp", + optional = true, + opts = function(_, opts) return vim.tbl_deep_extend("force", opts, require "nvchad.cmp") end, + }, + { + "AstroNvim/astrocore", + opts = { + options = { opt = { showtabline = 0 } }, + autocmds = { + nvdash_autostart = { + { + event = "VimEnter", + desc = "Start Alpha when vim is opened with no arguments", + callback = function() + local should_skip + local lines = vim.api.nvim_buf_get_lines(0, 0, 2, false) + if + vim.fn.argc() > 0 -- don't start when opening a file + or #lines > 1 -- don't open if current buffer has more than 1 line + or (#lines == 1 and lines[1]:len() > 0) -- don't open the current buffer if it has anything on the first line + or #vim.tbl_filter(function(bufnr) return vim.bo[bufnr].buflisted end, vim.api.nvim_list_bufs()) > 1 -- don't open if any listed buffers + or not vim.o.modifiable -- don't open if not modifiable + then + should_skip = true + else + for _, arg in pairs(vim.v.argv) do + if arg == "-b" or arg == "-c" or vim.startswith(arg, "+") or arg == "-S" then + should_skip = true + break + end + end + end + if should_skip then return end + require("nvchad.nvdash").open() + vim.schedule(function() vim.cmd.doautocmd "FileType" end) + end, + }, + }, + }, + mappings = { + n = { + ["h"] = { + function() + local is_valid_win = function(win) + local bufnr = vim.api.nvim_win_get_buf(win) + return require("astrocore.buffer").is_valid(bufnr) or vim.bo[bufnr].filetype == "alpha" + end + local cur_win = vim.api.nvim_get_current_win() + -- try to find the most suitable window for Alpha + if not is_valid_win(cur_win) then + for _, win in ipairs(vim.api.nvim_tabpage_list_wins(0)) do + if win ~= cur_win and is_valid_win(win) then + vim.fn.win_gotoid(win) + break + end + end + end + require("nvchad.nvdash").open() + end, + desc = "Home Screen", + }, + ["ft"] = { function() require("nvchad.themes").open() end, desc = "Find themes" }, + }, + }, + }, + }, + -- Disable unnecessary plugins + { "rebelot/heirline.nvim", opts = { statusline = false, tabline = false } }, + { "goolord/alpha-nvim", enabled = false }, + { "brenoprata10/nvim-highlight-colors", enabled = false }, + { "NvChad/nvim-colorizer.lua", enabled = false }, + -- add lazy loaded dependencies + { "nvim-lua/plenary.nvim", lazy = true }, + { "NvChad/volt", lazy = true }, + { "NvChad/minty", lazy = true }, + { "NvChad/menu", lazy = true }, + { + "NvChad/base46", + lazy = true, + init = function() vim.g.base46_cache = vim.fn.stdpath "data" .. "/base46_cache/" end, + build = function() require("base46").load_all_highlights() end, + -- load base46 cache when necessary + specs = { + { + "nvim-treesitter/nvim-treesitter", + optional = true, + opts = function() + pcall(function() + dofile(vim.g.base46_cache .. "syntax") + dofile(vim.g.base46_cache .. "treesitter") + end) + end, + }, + { + "folke/which-key.nvim", + optional = true, + opts = function() + pcall(function() dofile(vim.g.base46_cache .. "whichkey") end) + end, + }, + { + "lukas-reineke/indent-blankline.nvim", + optional = true, + opts = function() + pcall(function() dofile(vim.g.base46_cache .. "blankline") end) + end, + }, + { + "nvim-telescope/telescope.nvim", + optional = true, + opts = function() + pcall(function() dofile(vim.g.base46_cache .. "telescope") end) + end, + }, + { + "neovim/nvim-lspconfig", + optional = true, + opts = function() + pcall(function() dofile(vim.g.base46_cache .. "lsp") end) + end, + }, + { + "nvim-tree/nvim-tree.lua", + optional = true, + opts = function() + pcall(function() dofile(vim.g.base46_cache .. "nvimtree") end) + end, + }, + { + "williamboman/mason.nvim", + optional = true, + opts = function() + pcall(function() dofile(vim.g.base46_cache .. "mason") end) + end, + }, + { + "lewis6991/gitsigns.nvim", + optional = true, + opts = function() + pcall(function() dofile(vim.g.base46_cache .. "git") end) + end, + }, + { + "nvim-tree/nvim-web-devicons", + optional = true, + opts = function() + pcall(function() dofile(vim.g.base46_cache .. "devicons") end) + end, + }, + { + "echasnovski/mini.icons", + optional = true, + opts = function() + pcall(function() dofile(vim.g.base46_cache .. "devicons") end) + end, + }, + { + "hrsh7th/nvim-cmp", + optional = true, + opts = function() + pcall(function() dofile(vim.g.base46_cache .. "cmp") end) + end, + }, + }, + }, + }, +}