Tip
🇷🇺 Русская версия: API.ru.md
Complete API documentation for lazyvimx utility functions and modules.
Module: lazyvimx
Location: lua/lazyvimx/init.lua
Initialize lazyvimx with custom configuration.
Signature:
function M.setup(opts?: table)Parameters:
opts(table, optional) - Configuration options
Configuration Schema:
{
colorscheme?: string, -- Base colorscheme name
colorscheme_flavors?: {
[string]: { string, string } -- { dark_variant, light_variant }
},
bufferline_groups?: {
[string]: string -- { group_name: pattern }
}
}Default Configuration:
{
colorscheme = "catppuccin",
colorscheme_flavors = {
catppuccin = { "catppuccin-macchiato", "catppuccin-latte" },
tokyonight = { "tokyonight-storm", "tokyonight-day" },
},
bufferline_groups = {},
}Usage:
require("lazyvimx").setup({
colorscheme = "tokyonight",
bufferline_groups = {
["React"] = "%.tsx$",
},
})Returns: None
Side Effects:
- Sets
M.configwith merged configuration - Available globally as
require("lazyvimx").config
Access current configuration.
Type: table
Usage:
local config = require("lazyvimx").config
print(config.colorscheme) -- "catppuccin"Module: lazyvimx.util.general
Location: lua/lazyvimx/util/general.lua
Blends two hex colors by percentage.
Signature:
function M.color_blend(
color_first: string,
color_second: string,
percentage: number
): stringParameters:
color_first(string) - First hex color (e.g., "#FF0000")color_second(string) - Second hex color (e.g., "#0000FF")percentage(number) - Blend percentage (0-100)
Returns: (string) - Blended hex color
Example:
local util = require("lazyvimx.util.general")
-- Blend red with blue at 50%
local purple = util.color_blend("#FF0000", "#0000FF", 50)
-- Returns: "#7F007F"
-- Blend with 25% of second color
local light_red = util.color_blend("#FF0000", "#FFFFFF", 25)
-- Returns: "#FF3F3F"Use Cases:
- Theme customization
- Dynamic highlight generation
- Color interpolation
Implementation Note: Uses RGB color space for blending.
Execute shell command and return trimmed output.
Signature:
function M.popen_get_result(cmd: string): stringParameters:
cmd(string) - Shell command to execute
Returns: (string) - Command output (trimmed, no newlines)
Example:
local util = require("lazyvimx.util.general")
local result = util.popen_get_result("echo hello")
-- Returns: "hello"
local theme = util.popen_get_result("defaults read -g AppleInterfaceStyle 2>&1")
-- Returns: "Dark" or ""Error Handling: Returns empty string if command fails or handle is nil.
Check if macOS is in dark mode.
Signature:
function M.theme_is_dark(): booleanReturns: (boolean) - true if dark mode, false otherwise
Example:
local util = require("lazyvimx.util.general")
if util.theme_is_dark() then
print("Dark mode active")
else
print("Light mode active")
endPlatform: macOS only
Implementation:
defaults read -g AppleInterfaceStyle
-- Returns "Dark" in dark mode
-- Returns error in light modeGet dotfiles source path from environment.
Signature:
function M.get_dotfiles_path(): stringReturns: (string) - Dotfiles path or empty string
Example:
local util = require("lazyvimx.util.general")
local path = util.get_dotfiles_path()
if path ~= "" then
print("Dotfiles at:", path)
endEnvironment Variable: DOTFILES_SRC_PATH
Usage in Code:
local dotfiles = util.get_dotfiles_path()
if dotfiles ~= "" then
local lazy_lock = vim.fn.stdpath("config") .. "/lazy-lock.json"
vim.fn.system(string.format("chezmoi add %s", lazy_lock))
endGet appropriate colorscheme variant based on system theme.
Signature:
function M.get_flavor(colorscheme?: string): stringParameters:
colorscheme(string, optional) - Colorscheme name (defaults to config value)
Returns: (string) - Colorscheme variant name
Example:
local util = require("lazyvimx.util.general")
-- In dark mode:
local flavor = util.get_flavor("catppuccin")
-- Returns: "catppuccin-macchiato"
-- In light mode:
local flavor = util.get_flavor("catppuccin")
-- Returns: "catppuccin-latte"
-- Use configured colorscheme:
local flavor = util.get_flavor()Logic:
- Checks system theme with
theme_is_dark() - Selects index 1 (dark) or 2 (light)
- Returns variant from
config.colorscheme_flavors
Check if specific extra is loaded.
Signature:
function M.has_extra(extra: string): booleanParameters:
extra(string) - Extra name (e.g., "ui.winbar")
Returns: (boolean) - true if extra is loaded
Example:
local util = require("lazyvimx.util.general")
if util.has_extra("ui.winbar") then
print("Winbar is enabled")
end
-- Conditional configuration:
if util.has_extra("ui.edgy") then
-- Configure edgy integration
endChecks:
- Lazy.nvim loaded modules
- LazyVim extras JSON data
Create callback that warns if extra is missing.
Signature:
function M.warn_missing_extra(extra_name: string): functionParameters:
extra_name(string) - Extra name to check
Returns: (function) - Callback function
Example:
local util = require("lazyvimx.util.general")
return {
{
"plugin/name",
init = util.warn_missing_extra("ui.diff-view"),
}
}
-- Shows notification if ui.diff-view is not loaded:
-- "Missing extra: `ui.diff-view`"Use Case: Warn users about required extras for optional features.
Module: lazyvimx.util.layout
Location: lua/lazyvimx/util/layout.lua
Manages consistent sizing for sidebars and panels.
Internal State:
local size = {
left = 40,
right = 40,
top = 10,
bottom = 10,
}
M.step = 3 -- Resize step sizeGet current size for position.
Signature:
function M.get_size(pos: string): numberParameters:
pos(string) - Position: "left", "right", "top", or "bottom"
Returns: (number) - Size value
Example:
local layout = require("lazyvimx.util.layout")
local left_width = layout.get_size("left")
-- Returns: 40
local bottom_height = layout.get_size("bottom")
-- Returns: 10Create function that returns size for position.
Signature:
function M.get_size_create(pos: string): functionParameters:
pos(string) - Position: "left", "right", "top", or "bottom"
Returns: (function) - Function returning size
Example:
local layout = require("lazyvimx.util.layout")
-- Used in plugin configuration:
{
"plugin/name",
opts = {
width = layout.get_size_create("left"),
}
}
-- Equivalent to:
{
opts = {
width = function() return 40 end,
}
}Use Case: Edgy.nvim and other plugins that accept size functions.
Create function that increases window size.
Signature:
function M.increase_create(dir: string): functionParameters:
dir(string) - Direction: "width" or "height"
Returns: (function) - Function that increases size
Example:
local layout = require("lazyvimx.util.layout")
-- Used in keybinding:
vim.keymap.set("n", "<C-w>+", function()
local win = require("edgy").get_win()
if win then
layout.increase_create("height")(win)
end
end)Behavior:
- Increases size by
M.step(default: 3) - Updates internal state
- Resizes window
Create function that decreases window size.
Signature:
function M.decrease_create(dir: string): functionParameters:
dir(string) - Direction: "width" or "height"
Returns: (function) - Function that decreases size
Example:
local layout = require("lazyvimx.util.layout")
-- Used in keybinding:
vim.keymap.set("n", "<C-w>-", function()
local win = require("edgy").get_win()
if win then
layout.decrease_create("height")(win)
end
end)Behavior:
- Decreases size by
M.step(default: 3) - Updates internal state
- Resizes window
{
"folke/edgy.nvim",
opts = function()
local layout = require("lazyvimx.util.layout")
return {
left = {
size = layout.get_size_create("left"),
},
bottom = {
size = layout.get_size_create("bottom"),
},
keys = {
["<c-Left>"] = function(win) layout.decrease_create("width")(win) end,
["<c-Right>"] = function(win) layout.increase_create("width")(win) end,
["<c-Up>"] = function(win) layout.increase_create("height")(win) end,
["<c-Down>"] = function(win) layout.decrease_create("height")(win) end,
},
}
end,
}Module: Boot system
Location: lua/lazyvimx/boot.lua
Internal functions used during bootstrap. Not intended for direct use.
Sets global variables for LazyVim configuration.
Internal Function
Sets:
vim.g.lazyvim_check_order = false
vim.g.xtras_prios = {}
vim.g.lazyvim_explorer = "neo-tree"Configures Vim options.
Internal Function
See CONFIGURATION.md#vim-options for details.
Registers lazyvimx extras in LazyVim extras UI.
Internal Function
Adds Source:
{
name = "[ ]",
desc = "Some recipes (extras) for enhance lazyvim",
module = "lazyvimx.extras",
}Sets colorscheme based on system theme.
Internal Function
Usage:
opts.colorscheme = require("lazyvimx.util.general").get_flavor()Checks if user has custom plugins directory.
Internal Function
Returns: (boolean) - true if lua/plugins/*.lua exists
Function: custom_groups_create()
Location: lua/lazyvimx/overrides/bufferline/add-groups.lua
Creates custom buffer groups from configuration.
Returns: (table) - Bufferline groups configuration
Usage in Config:
require("lazyvimx").setup({
bufferline_groups = {
["React"] = "%.tsx$",
},
})Generated Groups:
{
name = "React",
matcher = function(buf)
return buf.path:match("%.tsx$")
end,
}For reference, here are the main type shapes:
---@class lazyvimxConfig
---@field colorscheme string
---@field colorscheme_flavors table<string, string[]>
---@field bufferline_groups table<string, string>---@alias LayoutPosition "left"|"right"|"top"|"bottom"
---@alias LayoutDirection "width"|"height"-- lua/config/lazyvimx.lua
require("lazyvimx").setup({
colorscheme = "catppuccin",
colorscheme_flavors = {
catppuccin = { "catppuccin-macchiato", "catppuccin-latte" },
},
})
-- lua/plugins/theme.lua
local util = require("lazyvimx.util.general")
return {
{
"catppuccin/nvim",
opts = {
custom_highlights = function(colors)
-- Use color blending
local subtle = util.color_blend(colors.base, colors.overlay0, 30)
return {
Comment = { fg = subtle },
}
end,
},
},
}-- lua/plugins/conditional.lua
local util = require("lazyvimx.util.general")
return {
{
"plugin/name",
cond = function()
return util.has_extra("ui.winbar")
end,
opts = {
-- Configuration
},
},
}-- lua/plugins/sidebar.lua
local layout = require("lazyvimx.util.layout")
return {
{
"sidebar/plugin",
opts = {
width = layout.get_size_create("left"),
resize_keys = {
["<C-w>>"] = layout.increase_create("width"),
["<C-w><"] = layout.decrease_create("width"),
},
},
},
}-- lua/plugins/chezmoi.lua
local util = require("lazyvimx.util.general")
vim.api.nvim_create_autocmd("BufWritePost", {
pattern = "*/nvim/lua/**/*.lua",
callback = function()
local dotfiles = util.get_dotfiles_path()
if dotfiles ~= "" then
local file = vim.fn.expand("%:p")
vim.fn.system(string.format("chezmoi add %s", file))
print("Added to chezmoi:", vim.fn.fnamemodify(file, ":t"))
end
end,
})Always check if extras are loaded before using their features:
local util = require("lazyvimx.util.general")
if util.has_extra("ui.edgy") then
-- Configure edgy integration
endUse layout utilities instead of hardcoded sizes:
-- ❌ Don't
opts = { width = 40 }
-- ✅ Do
local layout = require("lazyvimx.util.layout")
opts = { width = layout.get_size_create("left") }Check config exists before accessing:
local ok, config = pcall(function()
return require("lazyvimx").config
end)
if ok then
-- Use config
endCreate harmonious colors with blending:
local util = require("lazyvimx.util.general")
-- Create subtle variant
local subtle_bg = util.color_blend(base_bg, overlay, 15)
-- Create highlight variant
local highlight_fg = util.color_blend(base_fg, accent, 30)| Module | Functions | Purpose |
|---|---|---|
lazyvimx |
setup(), config |
Main configuration |
util.general |
color_blend(), theme_is_dark(), get_flavor(), has_extra(), warn_missing_extra() |
General utilities |
util.layout |
get_size(), get_size_create(), increase_create(), decrease_create() |
Layout management |
- CONFIGURATION.md - Configuration guide
- ARCHITECTURE.md - Technical architecture
- EXTRAS.md - Extras reference