Skip to content

✨ Lua #56

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

Merged
merged 3 commits into from
Apr 6, 2025
Merged

✨ Lua #56

merged 3 commits into from
Apr 6, 2025

Conversation

NatoBoram
Copy link
Collaborator

@NatoBoram NatoBoram commented Apr 3, 2025

Summary by CodeRabbit

  • New Features
    • Introduced a new Lua language support package with clear documentation for installation and usage.
    • Added robust configuration and registration settings to enhance Lua parser integration.
    • Streamlined post-installation processes for a smoother setup experience.
    • Implemented testing support to ensure reliable and accurate Lua code parsing.
    • New README file detailing installation and usage instructions.
    • New type definitions and constants for improved language registration.
    • Added a new file for setting up a testing environment for Lua.
    • New package @ast-grep/lang-lua added with version 0.0.1.

Copy link

coderabbitai bot commented Apr 3, 2025

Walkthrough

This pull request introduces Lua language support to the ast-grep project. It includes a new README detailing installation and usage, along with TypeScript definitions and an implementation file that exports Lua parser properties. A testing environment is established with nursery.js to validate the parser, and a package.json file is created for configuration. Additionally, a postinstall.js file is added to manage post-installation tasks, providing a comprehensive setup for parsing and testing Lua code.

Changes

File(s) Change Summary
packages/lua/README.md Added a new README with installation instructions, usage examples, and code snippets for Lua NAPI language support.
packages/lua/index.d.ts, packages/lua/index.js Introduced a new LanguageRegistration type, declared a default export registration, and exported parser properties (e.g., libraryPath, extensions).
packages/lua/nursery.js Created a testing environment using @ast-grep/nursery that sets up and executes a basic Lua parsing test.
packages/lua/package.json Added a new package configuration for @ast-grep/lang-lua, defining scripts, dependencies, and publish settings.
packages/lua/postinstall.js Added a post-install script that invokes @ast-grep/setup-lang with the current directory to perform necessary post-installation tasks.

Possibly related PRs

  • feat: C# language #41: Related to C# language support, introducing a new LanguageRegistration type and a similar structure for their respective README and package files.
  • ✨ Swift #60: Related to Swift language support, introducing a new LanguageRegistration type and a registration constant in their respective type definition files.
  • ✨ Bash #46: Related to Bash language support, introducing a new LanguageRegistration type and a registration constant in their respective type definition files.

Suggested Reviewers

  • HerringtonDarkholme

Poem

I'm a little rabbit, leaping in delight,
Hoping over code fields both day and night,
New Lua support sprouts like a magic carrot,
Parsing code with rhythm—oh, how we cherish it!
With every bug hopped away, I dance with pure glee 🐇.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dc39243 and 4337111.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • .changeset/mighty-masks-give.md (1 hunks)
  • packages/lua/README.md (1 hunks)
  • packages/lua/index.d.ts (1 hunks)
  • packages/lua/index.js (1 hunks)
  • packages/lua/nursery.js (1 hunks)
  • packages/lua/package.json (1 hunks)
  • packages/lua/postinstall.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (7)
  • packages/lua/postinstall.js
  • .changeset/mighty-masks-give.md
  • packages/lua/index.d.ts
  • packages/lua/nursery.js
  • packages/lua/index.js
  • packages/lua/package.json
  • packages/lua/README.md

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
packages/lua/README.md (1)

1-24: Documentation covers essential information.

The README provides clear installation instructions and a practical usage example, which should help users get started quickly with the Lua language support.

Consider adding a brief introduction about what features this package provides and how it integrates with the broader ast-grep ecosystem.

packages/lua/nursery.js (1)

1-16: Test harness validates basic functionality.

The test setup correctly configures the nursery environment for Lua and includes a basic verification that the parser can identify a simple function call.

Consider adding more test cases to verify parsing of different Lua language constructs such as tables, functions, loops, and conditionals to ensure comprehensive coverage.

packages/lua/package.json (1)

1-47: Package configuration needs some improvements.

The package configuration is mostly complete, but there are several important fields missing:

  1. The description field is empty (line 4)
  2. The author field is empty (line 22)
  3. No repository field to link to the GitHub repository
  4. No bugs or homepage fields to provide support information

I suggest adding these missing fields to improve package metadata:

{
  "name": "@ast-grep/lang-lua",
  "version": "0.0.1",
-  "description": "",
+  "description": "Lua language support for ast-grep",
  "main": "index.js",
  "scripts": {
    "build": "tree-sitter build -o parser.so",
    "source": "node nursery.js source",
    "prepublishOnly": "node nursery.js source",
    "postinstall": "node postinstall.js",
    "test": "node nursery.js test"
  },
  "files": [
    "index.js",
    "index.d.ts",
    "type.d.ts",
    "postinstall.js",
    "src",
    "prebuilds"
  ],
  "keywords": ["ast-grep"],
-  "author": "",
+  "author": "NatoBoram",
  "license": "ISC",
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/ast-grep/ast-grep.git",
+    "directory": "packages/lua"
+  },
+  "homepage": "https://github.com/ast-grep/ast-grep/tree/main/packages/lua#readme",
+  "bugs": {
+    "url": "https://github.com/ast-grep/ast-grep/issues"
+  },
  "dependencies": {
    "@ast-grep/setup-lang": "0.0.3"
  },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 002639c and 2f710bb.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • packages/lua/README.md (1 hunks)
  • packages/lua/index.d.ts (1 hunks)
  • packages/lua/index.js (1 hunks)
  • packages/lua/nursery.js (1 hunks)
  • packages/lua/package.json (1 hunks)
  • packages/lua/postinstall.js (1 hunks)
🔇 Additional comments (3)
packages/lua/postinstall.js (1)

1-4: Implementation follows standard postinstall pattern.

The postinstall script follows the expected pattern for language support in ast-grep, properly invoking the setup function with the current directory.

packages/lua/index.d.ts (1)

1-10:

✅ Verification successful

Type definition is well-structured.

The LanguageRegistration type properly defines the interface for the Lua language support with appropriate optional fields. This aligns well with the ast-grep type system.


🏁 Script executed:

#!/bin/bash
# Check if there's a corresponding index.js file that implements this interface
if [ -f "packages/lua/index.js" ]; then
  echo "index.js exists, showing its contents:"
  cat "packages/lua/index.js"
else
  echo "index.js does not exist, which is unexpected since it's imported in nursery.js"
  exit 1
fi

Length of output: 359


Interface & Implementation Verification Passed
The LanguageRegistration type in packages/lua/index.d.ts is well-structured and accurately captures the interface expected for Lua language support. The corresponding implementation in packages/lua/index.js provides the required fields—libraryPath, extensions, languageSymbol, and expandoChar—which confirms consistency between the type definition and its usage. The exclusion of the optional metaVarChar field in the implementation is acceptable.

packages/lua/index.js (1)

1-9: LGTM! This implementation properly exports the Lua language configuration.

The code is clean and follows the expected pattern for language support in ast-grep. It correctly:

  1. Builds the path to the parser.so file
  2. Exports the necessary properties for Lua language integration
  3. Specifies the .lua extension and correct language symbol

@NatoBoram NatoBoram force-pushed the feature/lua branch 5 times, most recently from f35b313 to dc39243 Compare April 6, 2025 04:21
@HerringtonDarkholme HerringtonDarkholme merged commit 785e220 into ast-grep:main Apr 6, 2025
3 checks passed
@NatoBoram NatoBoram deleted the feature/lua branch April 6, 2025 05:18
This was referenced Apr 6, 2025
This was referenced Apr 22, 2025
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.

2 participants