-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add stylua & luacheck with pre-commit hooks #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Summary of ChangesHello @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
Ignored Files
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this 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.
| -- Allow self as unused (common in OOP patterns) | ||
| self = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this 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]>
d312121 to
9f88d21
Compare
de9723f to
9f09a84
Compare
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]>
9f09a84 to
ab0a161
Compare
There was a problem hiding this 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. |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
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.
| --- Table format bypasses "acp" argument for custom scripts. | |
| --- Table format bypasses "acp" argument for custom scripts. |
| max_line_length = 120 | ||
|
|
||
| -- Maximum cyclomatic complexity | ||
| max_cyclomatic_complexity = 15 |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
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.
| max_cyclomatic_complexity = 15 | |
| max_cyclomatic_complexity = 25 |
|
|
||
| acp.send_prompt(prompt_text, nil, { | ||
| on_update = function(update) | ||
| on_update = function(update) -- luacheck: ignore 561 |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
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.
| on_update = function(update) -- luacheck: ignore 561 | |
| on_update = function(update) |
| if #state.pending_chunks == 0 and not state.is_streaming then | ||
| stop_render_timer() | ||
| end | ||
| flush_pending = function() -- luacheck: ignore 561 |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
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.
| --- 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 |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
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.
| --- @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 |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
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.
| --- @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 |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
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.
| end | ||
|
|
||
| function M.check() | ||
| function M.check() -- luacheck: ignore 561 |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
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.).
Summary
Adds code quality tooling with automatic enforcement for the ghost.nvim codebase.
Closes #3
Changes
.stylua.toml.luacheckrcMakefile.pre-commit-config.yaml.github/workflows/lint.ymlREADME.mdlua/ghost/*.luaWorkflow
Testing
make format-checkpassesmake lintpasses (0 warnings / 0 errors)pre-commit run --all-filespasses