Skip to content

Conversation

@assagman
Copy link
Owner

Summary

Adds code quality tooling with automatic enforcement for the ghost.nvim codebase.

  • Formatter: StyLua - 2-space indent, double quotes, 120 col width
  • Linter: luacheck - LuaJIT std, strict warnings
  • Enforcement: Pre-commit hooks + GitHub Actions CI

Closes #3

Changes

File Description
.stylua.toml StyLua configuration
.luacheckrc Luacheck configuration
Makefile Dev task targets (format, lint, check, precommit)
.pre-commit-config.yaml Pre-commit hooks for stylua + luacheck
.github/workflows/lint.yml CI workflow for PRs/pushes
README.md Development setup documentation
lua/ghost/*.lua Formatting fixes + lint warning fixes

Workflow

Developer
  │
  │  git commit
  ▼
pre-commit
  ├── stylua  (auto-fix; stops if files modified)
  ├── luacheck (blocks on any diagnostics)
  ▼
Commit succeeds

CI (GitHub Actions)
  ├── stylua --check
  ├── luacheck
  ▼
Checks green

Testing

  • make format-check passes
  • make lint passes (0 warnings / 0 errors)
  • pre-commit run --all-files passes

Copilot AI review requested due to automatic review settings January 16, 2026 21:10
@gemini-code-assist
Copy link

Summary of Changes

Hello @assagman, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the project's code quality infrastructure by integrating a Lua formatter (StyLua) and a linter (Luacheck). These tools are enforced both locally via pre-commit hooks and in the CI pipeline, ensuring a consistent and high standard for the codebase. The changes aim to improve maintainability, reduce potential bugs, and provide a clearer development experience for contributors.

Highlights

  • Code Quality Tooling: Introduced StyLua for Lua code formatting and Luacheck for Lua linting to ensure consistent code style and identify potential issues.
  • Automated Enforcement: Integrated StyLua and Luacheck into pre-commit hooks for local enforcement and added a new GitHub Actions CI workflow for continuous integration checks.
  • Development Workflow Enhancements: Added new Makefile targets for formatting, linting, and pre-commit operations, streamlining the developer workflow.
  • Documentation Update: Updated the README.md with a dedicated 'Development' section, detailing prerequisites, setup instructions, and available Makefile targets.
  • Codebase Refinements: Applied formatting fixes and addressed linting warnings across various Lua files to comply with the new code quality standards.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/lint.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request does a great job of introducing code quality tools like stylua and luacheck into the project, complete with pre-commit hooks. The configuration files are well-structured, and the automatic formatting and linting fixes improve code consistency. I have one suggestion regarding the .luacheckrc configuration to ensure it correctly reflects the intended linting rules.

Comment on lines +37 to +38
-- Allow self as unused (common in OOP patterns)
self = false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The comment on line 37 indicates the intention to allow unused self arguments, which is a common pattern in object-oriented Lua. However, setting self = false on line 38 has the opposite effect: it enables warnings for unused self arguments.

According to the luacheck documentation, self = true is the setting to suppress these warnings. To align the configuration with the comment's intent, this value should be changed to true.

-- Allow self as unused (common in OOP patterns)
self = true

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive code quality tooling to the ghost.nvim project, implementing automated formatting with StyLua and linting with luacheck, along with pre-commit hooks and GitHub Actions CI for enforcement.

Changes:

  • Added StyLua formatter configuration with 2-space indents, double quotes, and 120-column width
  • Added luacheck linter configuration targeting LuaJIT standard with strict warnings
  • Configured pre-commit hooks for automatic enforcement on commits
  • Set up GitHub Actions CI workflow to validate code quality on PRs and pushes
  • Applied formatting and lint fixes across all Lua files in the codebase

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated no comments.

Show a summary per file
File Description
.stylua.toml StyLua formatter configuration
.luacheckrc Luacheck linter configuration with Neovim globals
.pre-commit-config.yaml Pre-commit hooks for stylua and luacheck
.github/workflows/lint.yml CI workflow for automated lint checks
Makefile Development targets for formatting, linting, and pre-commit
README.md Added development section with setup instructions
lua/ghost/*.lua Applied auto-formatting fixes and resolved lint warnings

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Add .stylua.toml with formatting rules:
- 2-space indentation (spaces, not tabs)
- 120 column width
- Unix line endings
- Prefer double quotes

Part of #3

Signed-off-by: assagman <[email protected]>
Add .luacheckrc with settings for Neovim plugin development:
- std=luajit for Neovim runtime
- vim global defined
- Exclude .opencode and node_modules
- Max line length 120 (matches stylua)
- Max cyclomatic complexity 15

Part of #3

Signed-off-by: assagman <[email protected]>
Add Makefile with targets:
- format: Run stylua on all Lua files
- format-check: Check formatting without changes
- lint: Run luacheck linter
- check: Run format-check + lint
- precommit-install: Install pre-commit hooks
- precommit: Run pre-commit on all files

Part of #3

Signed-off-by: assagman <[email protected]>
Add .pre-commit-config.yaml with local hooks:
- stylua: Auto-format Lua files on commit
- luacheck: Lint Lua files and block on errors

Uses system-installed binaries for speed.
Contributors must install stylua, luacheck, and pre-commit.

Part of #3

Signed-off-by: assagman <[email protected]>
Apply consistent formatting across all Lua files:
- 2-space indentation
- Double quotes for strings
- Consistent line wrapping at 120 columns

Files modified:
- lua/ghost/config.lua
- lua/ghost/list.lua
- lua/ghost/persist.lua
- lua/ghost/transcript.lua

Part of #3

Signed-off-by: assagman <[email protected]>
Fix unused arguments (prefix with _):
- acp.lua: on_stderr data, set_on_data callback
- receiver.lua: process_completion result
- session.lua: on_error error_msg
- status.lua: loop variable request_id
- test.lua: initialize capabilities

Fix line too long:
- config.lua: wrap long @field annotation

Add inline ignores for cyclomatic complexity (561):
- context.lua: M.capture
- health.lua: M.check
- receiver.lua: process_session_update
- response.lua: M.handle_update
- status.lua: M.build_status_content
- test.lua: on_update callback

All 16 Lua files now pass luacheck with 0 warnings/errors.

Part of #3

Signed-off-by: assagman <[email protected]>
Add .github/workflows/lint.yml that runs on push/PR to main:
- stylua: Check Lua formatting
- luacheck: Lint Lua files with LuaJIT environment

Uses official actions for reproducible CI:
- JohnnyMorganz/stylua-action@v4
- leafo/gh-actions-lua@v10 (LuaJIT 2.1)
- leafo/gh-actions-luarocks@v4

Part of #3

Signed-off-by: assagman <[email protected]>
Add Development section with:
- Prerequisites (stylua, luacheck, pre-commit)
- Setup instructions (pre-commit install)
- Makefile targets reference table
- Code style summary

Closes #3

Signed-off-by: assagman <[email protected]>
- Add luacheck ignore for flush_pending cyclomatic complexity
- Remove unused assignment to processed variable

Signed-off-by: assagman <[email protected]>
@assagman assagman force-pushed the fix/issue-3-stylua-luacheck-precommit branch from d312121 to 9f88d21 Compare January 16, 2026 21:17
Copilot AI review requested due to automatic review settings January 16, 2026 21:29
@assagman assagman force-pushed the fix/issue-3-stylua-luacheck-precommit branch from de9723f to 9f09a84 Compare January 16, 2026 21:31
Change luaVersion from 'luajit-2.1' to 'luajit' (latest).
The previous value caused a 404 error during Lua installation.

Signed-off-by: assagman <[email protected]>
@assagman assagman force-pushed the fix/issue-3-stylua-luacheck-precommit branch from 9f09a84 to ab0a161 Compare January 16, 2026 21:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

--- @field keybind string Keybind to open the prompt buffer
--- @field backend "opencode"|"codex" Which ACP backend to use
--- @field acp_command string|table Command to run for ACP (default: "opencode").
--- Table format bypasses "acp" argument for custom scripts.
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The multi-line comment continuation uses improper indentation alignment. LuaDoc comments should align the continuation with the start of the description text, not indent arbitrarily.

Suggested change
--- Table format bypasses "acp" argument for custom scripts.
--- Table format bypasses "acp" argument for custom scripts.

Copilot uses AI. Check for mistakes.
max_line_length = 120

-- Maximum cyclomatic complexity
max_cyclomatic_complexity = 15
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cyclomatic complexity threshold is set to 15, but several functions are being suppressed with 'luacheck: ignore 561'. This suggests either the threshold should be raised or those functions should be refactored. Consider reviewing whether 15 is the appropriate threshold or if complex functions warrant refactoring.

Suggested change
max_cyclomatic_complexity = 15
max_cyclomatic_complexity = 25

Copilot uses AI. Check for mistakes.

acp.send_prompt(prompt_text, nil, {
on_update = function(update)
on_update = function(update) -- luacheck: ignore 561
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment 'luacheck: ignore 561' suppresses cyclomatic complexity warnings, but the function body appears to use the 'update' parameter extensively. If the warning is about cyclomatic complexity rather than unused variables, the comment is misleading. Consider refactoring complex functions or using more specific warning codes.

Suggested change
on_update = function(update) -- luacheck: ignore 561
on_update = function(update)

Copilot uses AI. Check for mistakes.
if #state.pending_chunks == 0 and not state.is_streaming then
stop_render_timer()
end
flush_pending = function() -- luacheck: ignore 561
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function appears to be assigned to a local variable for forward declaration purposes, but suppressing warning 561 (cyclomatic complexity) suggests it may be overly complex. Consider refactoring this function into smaller, more focused functions to reduce complexity.

Copilot uses AI. Check for mistakes.
--- Build the content lines for the status window
--- @return string[] Lines to display in the status window
function M.build_status_content()
function M.build_status_content() -- luacheck: ignore 561
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suppressing cyclomatic complexity warning (561) indicates this function exceeds the configured threshold of 15. Consider refactoring this function by extracting logical sections into helper functions.

Copilot uses AI. Check for mistakes.
--- @param update table The update notification params
--- @param request_id string|nil The request ID
local function process_session_update(update, request_id)
local function process_session_update(update, request_id) -- luacheck: ignore 561
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suppressing cyclomatic complexity warning suggests this function is too complex. Consider breaking it down into smaller functions that handle specific update types.

Copilot uses AI. Check for mistakes.
--- @param include_selection boolean|nil Whether to capture visual selection (default false)
--- @return GhostContext Captured context
function M.capture(bufnr, include_selection)
function M.capture(bufnr, include_selection) -- luacheck: ignore 561
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suppressing cyclomatic complexity warning indicates this function exceeds the threshold. Consider extracting sub-sections into helper functions for better maintainability.

Copilot uses AI. Check for mistakes.
end

function M.check()
function M.check() -- luacheck: ignore 561
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suppressing cyclomatic complexity warning for a health check function. Consider breaking down the checks into separate helper functions grouped by category (dependencies, configuration, etc.).

Copilot uses AI. Check for mistakes.
@assagman assagman merged commit 10f10bb into main Jan 16, 2026
1 check passed
@assagman assagman deleted the fix/issue-3-stylua-luacheck-precommit branch January 16, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add stylua & luacheck with pre-commit hooks for code quality

2 participants