diff --git a/AGENTS.md b/AGENTS.md index 43637fb6..f27bf36b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,6 +1,6 @@ # AGENTS.md - Development Guide for AI Coding Agents -This file provides essential information for AI coding agents working in this Neovim configuration repository. It covers build/lint/test commands, code style guidelines, and project conventions to ensure consistent development. +This file provides essential information for AI coding agents working in this Neovim configuration repository. It covers build/lint/test commands, code style guidelines, and project conventions. ## Build/Lint/Test Commands @@ -9,68 +9,39 @@ This file provides essential information for AI coding agents working in this Ne - **Description**: Run linting on current buffer using nvim-lint plugin - **File types**: Currently configured for markdown files with `markdownlint` - **Manual command**: `markdownlint-cli file.md` (if available globally) +- **CI**: GitHub Actions runs stylua formatting checks ### Formatting - **Command**: `:lua require('conform').format({ async = true, lsp_format = 'fallback' })` - **Keybinding**: `f` (normal/visual mode) -- **Description**: Format current buffer using conform.nvim -- **Formatters by filetype**: - - Lua: `stylua` - - Python: `isort`, `black` - - JavaScript: `prettierd`, `prettier` - - Go: `gofmt` - - Rust: `rustfmt` - - YAML: `yamlfix` - - TOML: `taplo` - - Terraform: `terraform_fmt` - - Markdown: `markdownlint` +- **Formatters by filetype**: Lua: `stylua`, Python: `isort`/`black`, JavaScript: `prettier`, Go: `gofmt`, Rust: `rustfmt`, YAML: `yamlfix`, TOML: `taplo`, Terraform: `terraform_fmt`, Markdown: `markdownlint` ### Testing - **Status**: No automated testing framework configured -- **Reason**: This is a Neovim configuration repository, not an application with unit tests - **Manual testing**: `:checkhealth` for Neovim health checks, `:Lazy` for plugin status - -### Single Test Execution -- **N/A**: No test suite exists for this configuration repository - -### Health Checks -- **Command**: `:checkhealth` -- **Description**: Comprehensive Neovim health check including plugins and configuration +- **Single test execution**: N/A - use `:checkhealth` for comprehensive checks ## Code Style Guidelines ### Formatting (.stylua.toml) -- **Column width**: 160 characters -- **Indent type**: Spaces -- **Indent width**: 2 spaces -- **Quote style**: Auto-prefer single quotes -- **Call parentheses**: None (omit when possible) -- **Simple statements**: Always collapse +- Column width: 160 characters, indent: 2 spaces, quote style: auto-prefer single quotes +- Call parentheses: omit when possible, simple statements: always collapse -### Imports +### Imports & Naming ```lua -- Standard require pattern local module = require('module.name') --- For plugins and external libraries -local telescope = require('telescope') -local conform = require('conform') - -- Conditional requires with error handling local ok, plugin = pcall(require, 'optional.plugin') -if not ok then - -- Handle missing plugin gracefully -end +if not ok then vim.notify('Plugin failed: ' .. result, vim.log.levels.WARN) end ``` - -### Naming Conventions -- **Variables**: `camelCase` (e.g., `local bufferNumber = 1`) -- **Functions**: `camelCase` (e.g., `function setupLsp() end`) +- **Variables/Functions**: `camelCase` (e.g., `local bufferNumber = 1`, `function setupLsp() end`) - **Constants**: `UPPER_SNAKE_CASE` (e.g., `local MAX_RETRIES = 3`) -- **Modules**: `snake_case` for file names (e.g., `lsp_config.lua`) -- **Descriptive names**: Prefer clarity over brevity (e.g., `diagnosticConfig` over `diagCfg`) +- **Modules**: `snake_case` for file names +- **Descriptive names**: Prefer clarity over brevity -### Error Handling +### Error Handling & Comments ```lua -- Safe plugin loading local ok, result = pcall(require, 'plugin.name') @@ -78,100 +49,44 @@ if not ok then vim.notify('Plugin failed to load: ' .. result, vim.log.levels.WARN) return end - --- Safe function calls -local success, err = pcall(function() - -- Potentially failing operation -end) -if not success then - vim.notify('Operation failed: ' .. err, vim.log.levels.ERROR) -end ``` - -### Comments ```lua --- Single line comments for explanations --- Use for Neovim-specific behavior or complex logic - --- TODO: Future improvements --- FIXME: Known issues --- NOTE: Important information for maintainers - --- EmmyLua type annotations (when used) +-- Single line comments, TODO/FIXME/NOTE +-- EmmyLua annotations: ---@param name type: description ---@param buffer number: The buffer number ---@return boolean: Success status -function processBuffer(buffer) - -- Implementation -end ``` -### Function Organization +### Function & Table Style ```lua -- Anonymous functions for keymaps -vim.keymap.set('n', 'key', function() - -- Implementation -end, { desc = 'Description of what this does' }) +vim.keymap.set('n', 'key', function() end, { desc = 'Description' }) -- Named functions for complex logic -local function setupPlugin() - -- Setup code here -end +local function setupPlugin() end --- Call setup functions -setupPlugin() -``` - -### Table/Configuration Style -```lua --- Consistent indentation and alignment +-- Consistent table formatting local config = { option1 = true, - option2 = 'value', - nested = { - setting = 42, - enabled = false, - }, - -- Align values when it improves readability - timeout_ms = 500, - max_retries = 3, -} - --- Plugin configurations follow this pattern -return { - 'plugin/name', - opts = { - -- Options here - }, - config = function() - -- Setup code - end, + nested = { setting = 42 }, + timeout_ms = 500, -- Align when readable } ``` -### Autocommands +### Autocommands & Keymaps ```lua -- Use descriptive augroup names local augroup = vim.api.nvim_create_augroup('plugin-name-feature', { clear = true }) - vim.api.nvim_create_autocmd('FileType', { group = augroup, pattern = 'lua', - callback = function() - -- Callback implementation - end, + callback = function() end, }) ``` - -### Keymaps ```lua --- Always include descriptions for discoverability -vim.keymap.set('n', 'sh', builtin.help_tags, { - desc = '[S]earch [H]elp' -}) - --- Use leader key consistently () --- Group related mappings under leader prefixes --- Follow existing patterns: s=search, t=toggle, h=git hunk, etc. +-- Always include descriptions +vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) +-- Use leader key (), group related mappings under prefixes ``` ## Project Conventions @@ -184,24 +99,16 @@ lua/ ├── autocommands.lua # Autocommands ├── lazy-config.lua # Lazy plugin manager setup ├── plugins_config/ # Plugin-specific configurations -│ ├── lsp.lua # LSP setup -│ ├── conform.lua # Formatting setup -│ ├── telescope.lua # Fuzzy finder setup -│ └── ... └── custom/ # User customizations ``` ### Plugin Management - **Manager**: lazy.nvim -- **Check status**: `:Lazy` -- **Update**: `:Lazy update` -- **Clean**: `:Lazy clean` -- **Profile**: `:Lazy profile` +- **Commands**: `:Lazy` (status), `:Lazy update`, `:Lazy clean`, `:Lazy profile` ### Commit Messages -- Follow conventional commit format when possible -- Be descriptive about Neovim-specific changes -- Reference plugin names and features clearly +- Follow conventional commit format +- Be descriptive about Neovim-specific changes and plugin references ### Plugin Configuration Pattern ```lua @@ -209,16 +116,12 @@ return { 'author/plugin-name', event = 'VimEnter', -- Lazy loading trigger dependencies = { 'dep1', 'dep2' }, - opts = { -- Simple options - setting = value, - }, - config = function() -- Complex setup + opts = { setting = value }, -- Simple options + config = function() -- Complex setup local plugin = require('plugin') - plugin.setup({ - -- Configuration - }) + plugin.setup({ config }) end, - keys = { -- Keybindings + keys = { -- Keybindings { 'key', function() end, desc = 'Description' }, }, } @@ -227,18 +130,18 @@ return { ## Development Workflow 1. **Setup**: Clone repository and start Neovim -2. **Plugin management**: Use `:Lazy` commands for plugin operations -3. **Testing changes**: `:checkhealth`, `:Lazy`, manual testing -4. **Formatting**: Use `f` or conform commands +2. **Plugin management**: Use `:Lazy` commands +3. **Testing**: `:checkhealth`, `:Lazy`, manual testing +4. **Formatting**: `f` or conform commands 5. **Linting**: Use lint commands for supported file types 6. **Git workflow**: Standard branching, commit, and PR process ## Neovim-Specific Considerations -- **API usage**: Prefer `vim.api.nvim_*` functions over deprecated `vim.*` +- **API usage**: Prefer `vim.api.nvim_*` over deprecated `vim.*` - **Version compatibility**: Target latest stable Neovim - **Plugin compatibility**: Check lazy-lock.json for pinned versions -- **Performance**: Be mindful of startup time and memory usage -- **User experience**: Consider both mouse and keyboard workflows +- **Performance**: Mindful of startup time and memory usage +- **User experience**: Consider mouse and keyboard workflows -This guide ensures AI agents can contribute effectively to this Neovim configuration while maintaining consistency with existing patterns and conventions. \ No newline at end of file +This guide ensures AI agents can contribute effectively while maintaining consistency with existing patterns and conventions. \ No newline at end of file