### Plugin Specification Example with Configuration and Keys (Lua) Source: https://github.com/birdeehub/lze/blob/master/README.md Provides an example of a plugin specification within a Lua module, demonstrating how to configure plugin commands, key mappings, and pre-initialization settings. It also shows how to import other plugin specification files. ```lua return { { "undotree", cmd = { "UndotreeToggle", "UndotreeHide", "UndotreeShow", "UndotreeFocus", "UndotreePersistUndo", }, keys = { { "U", "UndotreeToggle", mode = { "n" }, desc = "Undo Tree" }, }, before = function(_) vim.g.undotree_WindowLayout = 1 vim.g.undotree_SplitWidth = 40 end, }, { import = "plugins.afile" }, { import = "plugins.another" }, { import = "plugins.another_file" }, { import = "plugins.yet_another_file" }, } ``` -------------------------------- ### Example Plugin Load with Custom After Directory Loader (Lua) Source: https://github.com/birdeehub/lze/blob/master/README.md Shows a practical example of using the custom `load_with_after` function within the `lze.load` configuration to manage a plugin ('cmp-cmdline') that depends on another plugin ('nvim-cmp') and its 'after' directory. ```lua require("lze").load { "cmp-cmdline", on_plugin = { "nvim-cmp" }, load = load_with_after, } ``` -------------------------------- ### Build Integration Tests with Nix Source: https://github.com/birdeehub/lze/blob/master/CONTRIBUTING.md Builds the integration tests for a specific system (e.g., x86_64-linux) using Nix. Replace with your target system architecture. ```Console nix build .#checks..integration-nightly -L --option sandbox false ``` ```Console nix build .#checks.x86_64-linux.integration-nightly -L --option sandbox false ``` -------------------------------- ### Enter Nix Development Shell Source: https://github.com/birdeehub/lze/blob/master/CONTRIBUTING.md This command allows you to enter the development shell provided by the project's flake.nix, which bootstraps all necessary development tools. ```Console nix develop ``` -------------------------------- ### Run All Pre-commit Hooks Source: https://github.com/birdeehub/lze/blob/master/CONTRIBUTING.md Executes all pre-commit hooks, including formatting and linting, within the Nix development shell. ```Console pre-commit run --all ``` -------------------------------- ### Run Pre-commit Checks with Nix Source: https://github.com/birdeehub/lze/blob/master/CONTRIBUTING.md Executes the pre-commit checks (formatting and linting) using Nix for the specified system. Replace with your target system architecture. ```Console nix build .#checks..pre-commit-check -L ``` -------------------------------- ### Alejandra Formatting Source: https://github.com/birdeehub/lze/blob/master/CONTRIBUTING.md Alejandra is a tool used for formatting Nix code within the project. ```Nix # Alejandra is a formatter for Nix code. ``` -------------------------------- ### Allow Direnv Environment Source: https://github.com/birdeehub/lze/blob/master/CONTRIBUTING.md If using direnv, this command allows the project's environment to be loaded automatically when entering the directory. ```Console direnv allow ``` -------------------------------- ### NixCats Plugin Configuration for lze Source: https://github.com/birdeehub/lze/blob/master/README.md This Nix configuration snippet illustrates how to integrate the 'lze' plugin within a nixCats setup. It shows how to define startup and optional plugins. ```nix categoryDefinitions = { pkgs, settings, categories, name, ... }: { startupPlugins = with pkgs.vimPlugins; { someName = [ lze ]; }; optionalPlugins = with pkgs.vimPlugins; { someName = [ ]; }; }; packageDefinitions = { nvim = {pkgs , ... }: { settings = {/* your settings */}; categories = { someName = true; }; }; }; ``` -------------------------------- ### Busted Testing Framework Source: https://github.com/birdeehub/lze/blob/master/CONTRIBUTING.md Busted is the testing framework used for the project, with Neovim configured as the Lua interpreter. ```Lua -- Busted is used for running tests with Neovim as the Lua interpreter. ``` -------------------------------- ### Run Static Type Checking with Nix Source: https://github.com/birdeehub/lze/blob/master/CONTRIBUTING.md Performs static type checking using Nix for the specified system. Replace with your target system architecture. ```Console nix build .#checks..type-check-nightly -L ``` -------------------------------- ### Load Plugins with paq-nvim and lze Source: https://github.com/birdeehub/lze/blob/master/README.md Illustrates how to use 'paq-nvim' to install 'lze', 'telescope.nvim', and 'sweetie.nvim'. It then shows how to load 'telescope.nvim' by command and 'sweetie.nvim' by colorscheme using 'lze.load'. ```lua require "paq" { "BirdeeHub/lze", { "nvim-telescope/telescope.nvim", opt = true }, { "NTBBloodBatch/sweetie.nvim", opt = true } } require("lze").load { { "telescope.nvim", cmd = "Telescope", }, { "sweetie.nvim", colorscheme = "sweetie", }, } ``` -------------------------------- ### Lua Language Server for Type Checking Source: https://github.com/birdeehub/lze/blob/master/CONTRIBUTING.md The lua-language-server provides static type checking capabilities for Lua code. ```Lua -- lua-language-server is used for static type checking in Lua. ``` -------------------------------- ### Markdownlint Linting Source: https://github.com/birdeehub/lze/blob/master/CONTRIBUTING.md Markdownlint is used for linting Markdown files, ensuring consistency and adherence to standards. ```Markdown ``` -------------------------------- ### Run All Nix Flake Checks Source: https://github.com/birdeehub/lze/blob/master/CONTRIBUTING.md This command runs all checks defined in the Nix flake, including formatting, linting, and type checking. The -L option shows logs and --option sandbox false disables the sandbox for potentially better compatibility. ```Console nix flake check -L --option sandbox false ``` -------------------------------- ### StyLua Formatting Source: https://github.com/birdeehub/lze/blob/master/CONTRIBUTING.md StyLua is a tool used for formatting Lua code within the project. ```Lua -- StyLua is a formatter for Lua code. ``` -------------------------------- ### Lazy Loading Plugins with lze Source: https://github.com/birdeehub/lze/blob/master/README.md Demonstrates the core functionality of lze for lazy-loading Neovim plugins. It involves queuing plugins and specifying handlers to trigger their loading based on various events or conditions. The library aims to simplify complex autocommand setups. ```lua require('lze').trigger_load(name) ``` -------------------------------- ### Integrate lze with vim.pack.add Source: https://github.com/birdeehub/lze/blob/master/README.md Shows how to add 'lze' and other plugins using 'vim.pack.add'. It includes examples of preventing immediate loading and configuring the loading behavior, followed by loading specific plugins with 'lze.load' and their configurations. ```lua vim.pack.add({ "https://github.com/BirdeeHub/lze", "https://github.com/Wansmer/treesj", { src = "https://github.com/NTBBloodBatch/sweetie.nvim", name = "sweetie" } }, { -- prevent packadd! or packadd like this to allow on_require handler to load plugin spec load = function() end, -- choose your preference for install confirmation confirm = true, }) vim.cmd.packadd("lze") require("lze").load { { "sweetie", -- note the name change above colorscheme = "sweetie", }, { "treesj", cmd = { "TSJToggle" }, keys = { { "Tt", ":TSJToggle", mode = { "n" }, desc = "treesj split/join" }, }, after = function(_) require('treesj').setup({}) end } } ``` ```lua vim.pack.add({ "https://github.com/BirdeeHub/lze", { src = "https://github.com/Wansmer/treesj", data = { opt = true, } }, { src = "https://github.com/NTBBloodBatch/sweetie.nvim", name = "sweetie", data = { opt = true, } } }, { load = function(p) if not (p.spec.data or {}).opt then vim.cmd.packadd(p.spec.name) end end, -- choose your preference for install confirmation confirm = true, }) require("lze").load { { "sweetie", -- note the name change above colorscheme = "sweetie", }, { "treesj", cmd = { "TSJToggle" }, keys = { { "Tt", ":TSJToggle", mode = { "n" }, desc = "treesj split/join" }, }, after = function(_) require('treesj').setup({}) end } } ``` ```lua vim.pack.add({ "https://github.com/BirdeeHub/lze", }, { confirm = false --[[or true, up to you]], }) vim.pack.add({ { src = "https://github.com/NTBBloodBatch/sweetie.nvim", data = { colorscheme = "sweetie", } }, { src = "https://github.com/Wansmer/treesj", data = { cmd = { "TSJToggle" }, -- spec.data rejects mixed tables, so for keys, use lhs and rhs instead of [1] and [2] -- see: https://github.com/neovim/neovim/issues/35550 keys = { { lhs = "Tt", rhs = ":TSJToggle", mode = { "n" }, desc = "treesj split/join" }, }, after = function(_) require('treesj').setup({}) end, } } }, { load = function(p) local spec = p.spec.data or {} spec.name = p.spec.name require('lze').load(spec) end, -- choose your preference for install confirmation confirm = true, }) ``` -------------------------------- ### Luacheck Linting Source: https://github.com/birdeehub/lze/blob/master/CONTRIBUTING.md Luacheck is a tool used for linting Lua code, helping to identify potential issues. ```Lua -- Luacheck is a linter for Lua code. ``` -------------------------------- ### Configure Neovim plugins with Nix Home Manager Source: https://github.com/birdeehub/lze/blob/master/README.md Provides a Nix configuration snippet for Home Manager to enable Neovim and include the 'lze' plugin. It also shows commented-out lines for optional custom configuration or registering handlers. ```nix programs.neovim = { enable = true; plugins = with pkgs.vimPlugins [ { plugin = lze; # config = '' # -- optional, add extra handlers # -- require("lze").register_handlers(some_custom_handler_here) # ''; } ]; }; ``` -------------------------------- ### Load Plugins with lze and Lazy-loading Source: https://github.com/birdeehub/lze/blob/master/README.md Demonstrates loading multiple plugins using 'lze.load' with different lazy-loading strategies. Plugins can be loaded based on key mappings, filetypes ('toml'), colorscheme ('sweetie'), commands ('StartupTime'), or events ('InsertEnter'). ```lua require("lze").load { { "neo-tree.nvim", keys = { -- Create a key mapping and lazy-load when it is used { "ft", "Neotree toggle", desc = "NeoTree toggle" }, }, after = function() require("neo-tree").setup() end, }, { "crates.nvim", -- lazy-load when opening a toml file ft = "toml", }, { "sweetie.nvim", -- lazy-load when setting the `sweetie` colorscheme colorscheme = "sweetie", }, { "vim-startuptime", cmd = "StartupTime", before = function() -- Configuration for plugins that don't force you to call a `setup` function -- for initialization should typically go in a `before` -- or `beforeAll` function. vim.g.startuptime_tries = 10 end, }, { "care.nvim", -- load care.nvim on InsertEnter event = "InsertEnter", }, { "dial.nvim", -- lazy-load on keys. -- Mode is `n` by default. keys = { "", { "", mode = "n" } }, }, } ``` -------------------------------- ### Load Plugin with After Directory (Lua) Source: https://github.com/birdeehub/lze/blob/master/README.md Demonstrates how to load a plugin that utilizes 'after' directories by adding a custom load function. This ensures that the plugin's 'after' scripts are correctly sourced, addressing potential initialization order issues. ```lua local function load_with_after(name) vim.cmd.packadd(name) vim.cmd.packadd(name .. "/after") end ``` -------------------------------- ### Load Plugins from Directory Spec (Lua) Source: https://github.com/birdeehub/lze/blob/master/README.md Illustrates how to load multiple plugin specifications from a Lua module located in a directory. This approach allows for organized management of plugin configurations, enabling selective imports and custom ordering. ```lua require("lze").load("plugins") ``` -------------------------------- ### Configure Sweetie Plugin with lze Source: https://github.com/birdeehub/lze/blob/master/README.md This snippet demonstrates loading the sweetie-nvim plugin with 'lze' in Lua, including setting a specific colorscheme. ```lua require("lze").load { "sweetie.nvim", colorscheme = "sweetie", } ``` -------------------------------- ### Add lze from Flake Input Source: https://github.com/birdeehub/lze/blob/master/README.md This Nix code shows how to add the 'lze' plugin as a flake input if it's not available on nixpkgs-unstable. ```nix inputs = { lze.url = "github:BirdeeHub/lze"; }; ``` -------------------------------- ### Define Plugin Loading Hooks in Lua Source: https://github.com/birdeehub/lze/blob/master/README.md This snippet demonstrates how to define various hooks for controlling plugin loading behavior within the lze.nvim configuration. It includes properties like `beforeAll`, `before`, `after`, and `priority` to manage the execution order and conditions of plugins. ```lua { "plugin_name", enabled = true, -- or a function returning boolean beforeAll = function(plugin_spec) -- runs before any plugin specs from this call are triggered -- ... end, before = function(plugin_spec) -- runs before a plugin is loaded -- ... end, after = function(plugin_spec) -- runs after a plugin is loaded -- ... end, priority = 50, -- default priority, useful for start plugins in the same load call load = function(plugin_name) -- overrides the default vim.g.lze.load(name) function -- ... end, allow_again = false, -- allows adding an already loaded plugin again lazy = true -- set manually or automatically by a handler } ``` -------------------------------- ### Configure lze Global Settings Source: https://github.com/birdeehub/lze/blob/master/doc/lze.txt Sets the global configuration table for the lze plugin manager. This allows customization of default behaviors like plugin loading, verbosity, and default priority. ```lua ---@type lze.Config vim.g.lze = vim.g.lze ``` -------------------------------- ### Retrieve lze from Flake Inputs Source: https://github.com/birdeehub/lze/blob/master/README.md This Nix snippet demonstrates how to access the 'lze' plugin package from flake inputs. ```nix inputs.lze.packages.${pkgs.system}.default ``` -------------------------------- ### Configure Telescope Plugin with lze Source: https://github.com/birdeehub/lze/blob/master/README.md This snippet shows how to load the telescope-nvim plugin using the 'lze' plugin manager in Lua. It specifies the plugin name and the command to be used. ```lua require("lze").load { "telescope.nvim", cmd = "Telescope", } ``` -------------------------------- ### Default lze Configuration Options Source: https://github.com/birdeehub/lze/blob/master/README.md This Lua code block displays the default configuration options for the 'lze' plugin, including injects, load function, verbosity, and priority. ```lua vim.g.lze = { injects = {}, ---@type fun(name: string) load = vim.cmd.packadd, ---@type boolean verbose = true, ---@type integer default_priority = 50, ---@type boolean without_default_handlers = false, } ``` -------------------------------- ### Neovim Packadd Integration Source: https://github.com/birdeehub/lze/blob/master/README.md Illustrates how 'lze' interacts with Neovim's built-in package management system, specifically the `:h packadd` command. This allows 'lze' to manage plugins loaded via Neovim's native packpath. ```vimscript vim.cmd.packadd ``` -------------------------------- ### Trigger Plugin Loading in lze Source: https://github.com/birdeehub/lze/blob/master/doc/lze.txt Triggers the loading of lze.Plugin loading hooks, used by handlers to load plugins. It returns the names of plugins that were skipped due to being already loaded or not added to the queue. ```lua lze.trigger_load(plugin_names:string[]|string):string[] ``` -------------------------------- ### Load Plugins with lze Source: https://github.com/birdeehub/lze/blob/master/README.md Loads plugins using the `lze` utility. The `plugins` argument can be a table of plugin specifications or a string representing a Lua module containing plugin specifications. This function can be called multiple times. ```lua require("lze").load(plugins) ``` -------------------------------- ### Trigger Load Function in LUA Source: https://github.com/birdeehub/lze/blob/master/README.md Demonstrates the usage of the `trigger_load` function in LUA, which is used to load plugins. It accepts a plugin name or an array of plugin names and returns a list of skipped plugin names if called multiple times for the same plugin. ```lua --@overload fun(plugin_name: string | string[]): string[] require('lze').trigger_load ``` -------------------------------- ### Load Plugins with lze Source: https://github.com/birdeehub/lze/blob/master/doc/lze.txt Loads plugin specifications or module names into the lze system. This function can be called multiple times and returns duplicate plugin objects. Priority affects the order of non-lazy plugins within a single load call. ```lua lze.load(spec:string|lze.Spec):lze.Plugin[] ``` -------------------------------- ### lze Handlers Exposed Data Source: https://github.com/birdeehub/lze/blob/master/doc/lze.txt Explains how handlers can expose data through their `lib` table using the `lze.h` accessor. Exposed data is populated on use and removed if the handler is removed. ```lua require('lze').h.. ``` -------------------------------- ### Register Custom Handlers for Lazy Loading (Lua) Source: https://github.com/birdeehub/lze/blob/master/README.md Demonstrates how to register custom handlers with `lze` to define new triggers for lazy-loading plugins. This allows for flexible plugin loading based on custom conditions beyond the default `ft` or `event` triggers. ```lua --@param handlers lze.Handler[]|lze.Handler|lze.HandlerSpec[]|lze.HandlerSpec --@return string[] handlers_registered require("lze").register_handlers({ require("my_handlers.module1"), require("my_handlers.module2"), { handler = require("my_handlers.module3"), enabled = true, }, }) ``` -------------------------------- ### Access lze State Source: https://github.com/birdeehub/lze/blob/master/doc/lze.txt Provides access to the state of loaded plugins within the lze module. The state indicates if a plugin is loaded (`false`), being loaded (`false`), or never added (`nil`). Direct table access returns a copy. ```lua local snapshot = -require('lze').state local state = require('lze').state ``` -------------------------------- ### Configure Lazy-Loading Triggers in Lua Source: https://github.com/birdeehub/lze/blob/master/README.md This snippet shows how to configure various triggers for lazy-loading plugins using the lze.nvim plugin. It covers triggers based on events, commands, filetypes, key mappings, and module dependencies. ```lua { "plugin_name", event = "BufEnter", -- or {event = "BufEnter *.lua"}, or {"BufEnter", "BufRead"} cmd = "MyCommand", -- or {"Command1", "Command2"} ft = "lua", -- or {"lua", "vim"} keys = "f", -- or { { "f", mode = "n" } }, or a table of keyspecs colorscheme = "tokyonight", -- or {"tokyonight", "gruvbox"} dep_of = "another_plugin", -- or {"plugin1", "plugin2"} on_plugin = "dependency_plugin", -- or {"pluginA", "pluginB"} on_require = "my_module" -- or {"module1", "module2"} } ``` -------------------------------- ### lze State Function and Table Access Source: https://github.com/birdeehub/lze/blob/master/doc/lze.txt Defines how to access the lze state, either through a function that returns a boolean for a specific plugin name or by accessing a table that returns a copy of the state for that plugin. ```lua -- Faster, returns `boolean?` -- | fun(name: string): boolean? -- Access returns COPY of state for that plugin name. -- | table (lze.State) ``` -------------------------------- ### lze PluginBase Type Definition Source: https://github.com/birdeehub/lze/blob/master/doc/lze.txt Defines the base properties for a `lze.Plugin`, including options to enable/disable, set priority, override the load function, allow re-adding, and define lifecycle hooks (`beforeAll`, `before`, `after`), and lazy loading. ```lua --@meta error("Cannot import a meta module") --@class lze.PluginBase -- Whether to enable this plugin. Useful to disable plugins under certain conditions. --@field enabled? boolean|(fun():boolean) -- Only useful for lazy=false plugins to force loading certain plugins first. -- Default priority is 50 --@field priority? number -- Set this to override the `load` function for an individual plugin. -- Defaults to `vim.g.lze.load()`, see |lze.Config|. --@field load? fun(name: string) -- True will allow a plugin to be added to the queue again after it has already been triggered. --@field allow_again? boolean -- Will be run before loading any plugins in that require('lze').load() call --@field beforeAll? fun(self:lze.Plugin) -- Will be run before loading this plugin --@field before? fun(self:lze.Plugin) -- Will be executed after loading this plugin --@field after? fun(self:lze.Plugin) -- Whether to lazy-load this plugin. Defaults to `false`. -- Using a handler's field sets this automatically. --@field lazy? boolean ``` -------------------------------- ### Set Custom Event Aliases in Lua Source: https://github.com/birdeehub/lze/blob/master/README.md This snippet demonstrates how to define custom event aliases for lazy-loading plugins using the `set_event_alias` function provided by the lze.nvim event handler. ```lua require('lze').h.event.set_event_alias("MyCustomEvent", { event = "BufEnter", pattern = "*.txt" }) ``` -------------------------------- ### lze Event Type Definition Source: https://github.com/birdeehub/lze/blob/master/doc/lze.txt Defines the `lze.Event` type for specifying Neovim autocommand events, including the event name(s), optional pattern(s), and the autogroup ID. ```lua --@alias lze.Event {id:string, event:string[]|string, pattern?:string[]|string, augroup:integer} ``` -------------------------------- ### lze KeysSpec Type Definition Source: https://github.com/birdeehub/lze/blob/master/doc/lze.txt Defines the `lze.KeysSpec` type for specifying key mappings, extending `lze.KeysBase`. It includes fields for the left-hand side (lhs), right-hand side (rhs), and mode of the key mapping. ```lua --@class lze.KeysBase: vim.keymap.set.Opts --@field desc? string --@field noremap? boolean --@field remap? boolean --@field expr? boolean --@field nowait? boolean --@field ft? string|string[] --@class lze.KeysSpec: lze.KeysBase --@field [1]? string [1] or lhs required, [1] wins --@field [2]? string|fun()|false will override rhs --@field lhs? string [1] or lhs required, [1] wins --@field rhs? string|fun()|false [2] will override rhs if set --@field mode? string|string[] ``` -------------------------------- ### lze Keys Type Definition Source: https://github.com/birdeehub/lze/blob/master/doc/lze.txt Defines the `lze.Keys` type, representing a specific key mapping with its `lhs`, optional `rhs`, `mode`, unique `id`, and `name`. ```lua --@class lze.Keys: lze.KeysBase --@field lhs string lhs --@field rhs? string|fun() rhs --@field mode? string --@field id string --@field name string ``` -------------------------------- ### Register Handlers with lze Source: https://github.com/birdeehub/lze/blob/master/doc/lze.txt Registers handlers with the lze module to add new spec fields. This function should be called before any calls to lze.load. It returns a list of spec_field values that were added. ```lua lze.register_handlers(handlers:lze.Handler[]|lze.Handler|lze.HandlerSpec[]|lze.HandlerSpec):string[] ``` -------------------------------- ### Clear Handlers in lze Source: https://github.com/birdeehub/lze/blob/master/doc/lze.txt Clears all registered handlers from the lze module. This function should be called before any calls to lze.load. It returns the list of cleared handlers. ```lua lze.clear_handlers():lze.Handler[] ``` -------------------------------- ### Remove Handlers from lze Source: https://github.com/birdeehub/lze/blob/master/doc/lze.txt Removes specified handlers from the lze module. This function should be called before any calls to lze.load. It returns the list of handlers that were removed. ```lua lze.remove_handlers(handler_names:string|string[]):lze.Handler[] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.