Welcome to debugprint.nvim! This document provides essential information for AI coding agents to work efficiently with this repository.
debugprint.nvim is a NeoVim plugin that simplifies debugging by automatically inserting language-specific debug print statements. See the README.md for more information on features.
Technology Stack:
- Language: Lua (NeoVim plugin)
- Target: NeoVim (maintains compatibility with stable, stable - 1, and nightly)
- Dependencies: plenary.nvim (testing), mini.nvim (optional highlighting), nvim-treesitter (optional variable detection)
lua/debugprint/ # Main plugin source code
tests/ # Test suite
doc/ # Generated Vim help documentation
.github/workflows/ # CI/CD workflows
CRITICAL: Before considering any change complete, run:
pre-commit run --all-files # Runs stylua, markdownlint, luacheck, and lua-language-server typecheck
make test # Runs the full test suiteThese must both pass with no errors or warnings. There are no exceptions.
-
Use type annotations - Add
---@type,---@param,---@returnannotations for better type safety and documentation---@param opts debugprint.FunctionOptionsInternal ---@param fileconfig debugprint.FileTypeConfig ---@return string local get_debugline_textcontent = function(opts, fileconfig) -- ... end
-
Module pattern - Use the standard Lua module pattern:
local M = {} M.some_function = function() -- ... end return M
-
Local variables - Prefer
localvariables and functions to minimize global scope pollution -
Vim globals - The
vimglobal is allowed and expected (configured in.luacheckrc) -
String formatting - Use
string.format()for complex strings or Lua string concatenation for simple cases -
Error handling - Use
pcall()for operations that might fail and provide meaningful error messages viavim.notify()
MANDATORY: All commits MUST follow the Conventional Commits specification. This is strictly enforced and non-negotiable.
- The project uses
release-pleasefor automated releases - Conventional commits are parsed to determine version bumps (semver)
feat:→ minor version bumpfix:→ patch version bumpfeat!:orBREAKING CHANGE:→ major version bump- Other types don't trigger releases
make test
# or
nvim --headless --clean -u tests/run.lua- Tests use a custom test framework (not busted)
- Test files are in
tests/specs/with descriptive names - Tests are loaded automatically by
tests/run.lua tests/support.luaprovides test utilities
Example test structure:
local debugprint = require("debugprint")
local support = require("tests.support")
describe("feature name", function()
before_each(function()
debugprint.setup()
end)
after_each(support.teardown)
it("should do something", function()
local filename = support.init_file({
"line1",
"line2",
}, "lua", 1, 0)
support.feedkeys("g?p")
support.check_lines({
"line1",
"print('DEBUGPRINT[1]: " .. filename .. ":1 (after line1)')",
"line2",
})
assert.equals(support.get_notify_message(), nil)
end)
end)Tests run against multiple NeoVim versions and OS:
- NeoVim: all versions supported by the plugin
- OS: Ubuntu, macOS
The .github/workflows/tests.yaml runs these checks:
- actionlint - Validates GitHub Actions workflow files
- stylua - Enforces code formatting
- luacheck - Lua static analysis
- selene - Modern Lua linting
- typecheck - Type checking for Lua code
- unit_test - Runs test suite across matrix of NeoVim versions and OS
- Written in
doc/debugprint.txt - Auto-generated via
panvimdocGitHub Action - Uses special comment markers for generation
- Generated on every push to main branch
README.md- User-facing documentation, installation, featuresSHOWCASE.md- Advanced usage examples and customization patternsCHANGELOG.md- Generated by release-please (don't edit manually)
Markdown Linting:
- Uses markdownlint (
.markdownlintrc) CHANGELOG.mdis excluded from linting
Error: One or more pre-commit hooks fail when running pre-commit run --all-files
Solution:
- stylua: Run
stylua lua/ tests/to auto-format, then re-run pre-commit - luacheck: Fix undefined/unused variables; prefix intentionally unused vars with
_ - llscheck (lua-language-server): Add or correct
---@type,---@param,---@returnannotations; checklua/debugprint/types.luafor type definitions - markdownlint: Fix markdown formatting issues flagged in the output
Error: Selene finds code quality issues
Solution:
- Review selene documentation for the specific diagnostic
- Fix the underlying issue (prefer this)
- Use
--[[ allow(<diagnostic>) ]]sparingly for false positives