Skip to content

Latest commit

 

History

History
195 lines (131 loc) · 5.48 KB

AGENTS.md

File metadata and controls

195 lines (131 loc) · 5.48 KB

Agent Instructions for debugprint.nvim

Welcome to debugprint.nvim! This document provides essential information for AI coding agents to work efficiently with this repository.

Project Overview

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)

Repository Structure

lua/debugprint/         # Main plugin source code
tests/                  # Test suite
doc/                    # Generated Vim help documentation
.github/workflows/      # CI/CD workflows

Lua Best Practices

Code Quality

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 suite

These must both pass with no errors or warnings. There are no exceptions.

Lua Coding Standards

  1. Use type annotations - Add ---@type, ---@param, ---@return annotations for better type safety and documentation

    ---@param opts debugprint.FunctionOptionsInternal
    ---@param fileconfig debugprint.FileTypeConfig
    ---@return string
    local get_debugline_textcontent = function(opts, fileconfig)
        -- ...
    end
  2. Module pattern - Use the standard Lua module pattern:

    local M = {}
    
    M.some_function = function()
        -- ...
    end
    
    return M
  3. Local variables - Prefer local variables and functions to minimize global scope pollution

  4. Vim globals - The vim global is allowed and expected (configured in .luacheckrc)

  5. String formatting - Use string.format() for complex strings or Lua string concatenation for simple cases

  6. Error handling - Use pcall() for operations that might fail and provide meaningful error messages via vim.notify()

Commit Message Convention

MANDATORY: All commits MUST follow the Conventional Commits specification. This is strictly enforced and non-negotiable.

Release Process

  • The project uses release-please for automated releases
  • Conventional commits are parsed to determine version bumps (semver)
  • feat: → minor version bump
  • fix: → patch version bump
  • feat!: or BREAKING CHANGE: → major version bump
  • Other types don't trigger releases

Testing

Running Tests

make test
# or
nvim --headless --clean -u tests/run.lua

Test Structure

  • 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.lua provides test utilities

Writing Tests

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)

CI Test Matrix

Tests run against multiple NeoVim versions and OS:

  • NeoVim: all versions supported by the plugin
  • OS: Ubuntu, macOS

CI/CD Pipeline

Workflow Jobs

The .github/workflows/tests.yaml runs these checks:

  1. actionlint - Validates GitHub Actions workflow files
  2. stylua - Enforces code formatting
  3. luacheck - Lua static analysis
  4. selene - Modern Lua linting
  5. typecheck - Type checking for Lua code
  6. unit_test - Runs test suite across matrix of NeoVim versions and OS

Documentation

Vim Help Documentation

  • Written in doc/debugprint.txt
  • Auto-generated via panvimdoc GitHub Action
  • Uses special comment markers for generation
  • Generated on every push to main branch

Other documentation

  • README.md - User-facing documentation, installation, features
  • SHOWCASE.md - Advanced usage examples and customization patterns
  • CHANGELOG.md - Generated by release-please (don't edit manually)

Markdown Linting:

  • Uses markdownlint (.markdownlintrc)
  • CHANGELOG.md is excluded from linting

Troubleshooting Common Issues

Issue: pre-commit checks fail

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, ---@return annotations; check lua/debugprint/types.lua for type definitions
  • markdownlint: Fix markdown formatting issues flagged in the output

Issue: selene errors

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