Loading...
Loading...
Guides idiomatic Lua 5.4 programming, module design, and project maintenance for Neovim plugin/config ecosystems (LazyVim, lazy.nvim) and macOS bar tools (SketchyBar/SbarLua). Covers style, tooling (StyLua, Selene, LuaLS), module patterns, and testing. Use when writing Lua code, configuring Neovim plugins, working with SketchyBar Lua configs, debugging Lua require/module errors, or when the user mentions Lua, .lua files, LazyVim, lazy.nvim, SbarLua, SketchyBar, luarocks, LuaLS, StyLua, or Selene.
npx skill4agent add kaynetik/skills lua-projectsScope: Lua 5.4 (with LuaJIT notes where relevant). Targets config-driven projects like Neovim distributions, SketchyBar setups, and general Lua modules.
snake_casePascalCaseUPPER_SNAKE_for _, v in ipairs(t){}()[]stylua.tomlcolumn_width = 100
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferDouble"indent_type = "Tabs"stylua .selene.tomlstd = "lua54"vimvimstd = "lua54+vim"selene ..luacheckrcstd = "lua54"
globals = { "vim" }LuaLS.luarc.json{
"runtime": { "version": "Lua 5.4" },
"diagnostics": { "globals": ["vim"] },
"workspace": {
"library": [],
"checkThirdParty": false
}
}workspace.librarysketchybar"workspace": {
"library": ["~/.local/share/sketchybar_lua"]
}---@param name string
---@param opts? { padding?: number, icon?: string }
---@return table item
local function add_item(name, opts)
-- ...
endreturnlocal M = {}
function M.greet(name)
return "hello " .. name
end
return Minit.luainit.luaitems/
init.lua -- require("items") loads this
apple.lua
calendar.lua-- items/init.lua
require("items.apple")
require("items.calendar")-- BAD: implicit global
sbar = require("sketchybar")
-- GOOD: local binding (use upvalues or pass explicitly)
local sbar = require("sketchybar")sbarinit.lua# selene.toml
[lints]
global_usage = "allow"~/.config/nvim/
init.lua -- minimal bootstrap: vim.loader.enable(), require("config.lazy")
lua/
config/
lazy.lua -- lazy.nvim bootstrap and setup
options.lua
keymaps.lua
autocmds.lua
plugins/
lsp.lua
treesitter.lua
ui.lua
editor.luainit.luavim.loader.enable()lua/plugins/lua/plugins/optsconfigreturn {
"author/plugin.nvim",
event = "VeryLazy",
dependencies = { "nvim-lua/plenary.nvim" },
opts = {
setting = true,
},
keys = {
{ "<leader>x", "<cmd>PluginAction<cr>", desc = "Do thing" },
},
}~/.config/sketchybar/
sketchybarrc -- shell entry: sketchybar --config init.lua (or similar)
init.lua -- requires sbar, wraps in begin_config/end_config, runs event_loop
bar.lua -- bar-level properties
default.lua -- default item properties
colors.lua -- color palette table
icons.lua -- icon constants (SF Symbols / Nerd Font)
settings.lua -- shared settings (paddings, fonts)
items/
init.lua -- requires each item module
spaces.lua
front_app.lua
media.lua
...
helpers/
init.lua
app_icons.lua
default_font.lua
event_providers/ -- native helpers (C compiled)sbar.begin_config()sbar.end_config()sbar.event_loop()init.luasbar.exec()os.execute()icon = { y_offset = 10 }icon.y_offset0xAARRGGBBlocal ok, mod = pcall(require, "optional_module")
if not ok then
return
endlocal Item = {}
Item.__index = Item
function Item.new(name)
return setmetatable({ name = name }, Item)
end
function Item:display()
return self.name
endlocal defaults = { padding = 4, color = 0xffffffff }
local function apply(user_opts)
local cfg = {}
for k, v in pairs(defaults) do cfg[k] = v end
for k, v in pairs(user_opts or {}) do cfg[k] = v end
return cfg
endvim.tbl_deep_extend("force", defaults, user_opts)luarocks install busted-- spec/greet_spec.lua
describe("greet", function()
local mod = require("mymod")
it("returns greeting", function()
assert.are.equal("hello world", mod.greet("world"))
end)
it("handles nil", function()
assert.has_error(function() mod.greet(nil) end)
end)
end)bustedbusted spec/plenary.nvimnvim --headless -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/init.lua'}"local_ENVlocal t = table.create and table.create(n) or {}table.concat()ipairspairstype(1)"number"math.type(1)"integer"&|~~<<>>bit32bitfor i = 1, ncollectgarbage("generational")<const><close>local path <const> = "/tmp/data"
local f <close> = io.open(path, "r")print(vim.inspect(t))print(require("inspect")(t))~/.local/share/sketchybar/| Tool | Purpose | Config File | Install |
|---|---|---|---|
| StyLua | Formatter | | |
| Selene | Linter | | |
| LuaLS | Language server | | via Mason or package manager |
| Busted | Test framework | | |
| Luarocks | Package manager | | system package manager |
| Project | URL | Focus |
|---|---|---|
| LazyVim | https://github.com/LazyVim/LazyVim | Neovim distribution, plugin orchestration |
| lazy.nvim | https://github.com/folke/lazy.nvim | Plugin manager, spec system |
| SbarLua | https://github.com/FelixKratz/SbarLua | SketchyBar Lua bindings |
| SketchyBar | https://github.com/FelixKratz/SketchyBar | macOS bar, config examples |
| nvim-lspconfig | https://github.com/neovim/nvim-lspconfig | LSP client configs |
| plenary.nvim | https://github.com/nvim-lua/plenary.nvim | Neovim Lua utilities and test harness |
| telescope.nvim | https://github.com/nvim-telescope/telescope.nvim | Fuzzy finder, well-structured plugin |