Repository navigation
Expand file tree
/
Copy path07_all_features_spec.lua
More file actions
72 lines (62 loc) · 3.31 KB
/
Copy path07_all_features_spec.lua
File metadata and controls
72 lines (62 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
-- This example demonstrates an exhaustive list of all available features
-- you can use when defining a plugin spec in pack.nvim.
-- Bootstrap pack.nvim via native vim.pack (Neovim 0.12+).
vim.pack.add({ "https://github.com/igmrrf/pack.nvim" })
vim.cmd.packadd("pack.nvim")
require("pack").setup({
plugins = {
{
-- 1. Plugin Source
"user/mega-plugin", -- Bare "owner/repo" -> GitHub
as = "mega-plugin-custom-name", -- Override the installed plugin name
-- "~/projects/mega-plugin", -- Alt source: absolute/file:// local path (native clones it)
-- "https://gitlab.com/user/repo", -- Alt source: any full git URL passes through untouched
-- 2. Loading Mechanics
lazy = true, -- Ensure it doesn't load on startup
priority = 100, -- If eager loaded, set priority (higher loads earlier)
enabled = true, -- Hard toggle to disable plugin tracking entirely
cond = function(plugin) -- Condition evaluated before loading
return not vim.g.vscode
end,
main = "mega.core", -- Specify main lua module if it differs from the repo name
-- 3. Lazy-Loading Triggers
cmd = { "MegaCommand", "MegaToggle" },-- Load when these commands are used
ft = { "lua", "python" }, -- Load when opening specific filetypes
event = "BufReadPre *.md", -- Load on specific Vim events (supports patterns)
keys = { -- Load on keymap
{ "<leader>m", "<cmd>MegaToggle<cr>", desc = "Toggle Mega Plugin" },
{ "M", function() require("mega.core").do_magic() end, mode = { "n", "x" } }
},
-- 4. Dependencies
dependencies = {
"nvim-lua/plenary.nvim", -- These load automatically before the main plugin
{ "kyazdani42/nvim-web-devicons", lazy = true }
},
-- 5. Hooks and Configuration
init = function(plugin)
-- Runs BEFORE the plugin loads. Useful for setting `vim.g` variables.
-- `plugin` object contains `.path` (filesystem path) and `.spec`
vim.g.mega_plugin_dir = plugin.path
end,
opts = { -- Automatically calls `require("mega.core").setup(opts)`
theme = "dark",
features = { advanced = true }
},
config = function(plugin, opts)
-- Overrides default `opts` behavior. Runs AFTER the plugin loads.
require("mega.core").setup(opts)
require("mega.core").apply_custom_logic()
end,
build = "make install", -- Shell command to run after install/update
-- build = function(plugin) -- Alternative: Lua function build hook
-- vim.fn.system({ "make", "-C", plugin.path })
-- end,
-- 6. Versioning (resolved to native vim.pack's `version`; native does the
-- checkout). Precedence: commit > tag > branch > version range.
branch = "main", -- Track a branch
-- tag = "v1.0.0", -- Pin to a tag
-- commit = "abcdef1", -- Pin to a commit hash
-- version = "^1.0.0", -- Or a semver range -> newest matching tag
}
}
})