Skip to content

Conversation

lambdalisue
Copy link
Member

@lambdalisue lambdalisue commented Jul 13, 2025

Summary

  • Add support for deno.json and deno.jsonc files in denops plugin directories (with workspace feature of Deno)
  • Add support for import_map.json and import_map.jsonc files in denops plugin directories
  • Extract Plugin class into separate module for better organization
  • Add comprehensive tests for the new functionality

Test plan

  • Unit tests added for Plugin class
  • Test fixtures created with import map examples
  • Manual testing with actual denops plugins using import maps

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Introduced a robust plugin management system with lifecycle controls, dynamic loading, unloading, and API invocation for plugins.
    • Added support for plugins utilizing import maps, enabling flexible module aliasing.
  • Bug Fixes
    • Improved error handling and event emission during plugin load/unload processes.
  • Tests
    • Comprehensive test suite added for plugin lifecycle, error handling, event emission, and import map support.
  • Chores
    • Refactored internal code to modularize plugin logic and maintain cleaner service integration.
    • Added new test data and import map files to support plugin import map scenarios.

Copy link

coderabbitai bot commented Jul 13, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

A new Plugin class is introduced in its own module to manage Denops plugin lifecycles, including loading, unloading, and API calls, with support for import maps and robust event/error handling. The original implementation is removed from service.ts. Comprehensive tests and import map-based test plugins are added to verify this functionality.

Changes

File(s) Change Summary
denops/@denops-private/plugin.ts New file: Implements the Plugin class for plugin lifecycle management, dynamic imports, events, and errors.
denops/@denops-private/plugin_test.ts New file: Adds comprehensive unit tests for the Plugin class, covering all major behaviors and edge cases.
denops/@denops-private/service.ts Refactored: Removes internal Plugin logic, imports Plugin from new module, cleans up related helpers.
tests/denops/testdata/with_import_map/helper.ts New file: Exports a greeting constant and a message function for import map plugin tests.
tests/denops/testdata/with_import_map/import_map.json, import_map.jsonc New files: Provide import maps mapping module aliases for plugin test scenarios, including JSON and JSONC.
tests/denops/testdata/with_import_map/plugin_with_import_map.ts New file: Denops plugin using import map aliases, dispatcher, and Vim command execution for testing.
deno.jsonc Modified: Added tests/denops/testdata/with_import_map/ to the exclude paths.

Sequence Diagram(s)

sequenceDiagram
    participant Denops
    participant Plugin
    participant PluginModule

    Denops->>Plugin: new Plugin(denops, name, script)
    Plugin->>Plugin: load()
    Plugin->>PluginModule: dynamic import (with import map support)
    PluginModule-->>Plugin: exports main()
    Plugin->>PluginModule: main(denops)
    PluginModule-->>Plugin: AsyncDisposable resource
    Plugin-->>Denops: emit lifecycle events

    Denops->>Plugin: call(fn, ...args)
    Plugin->>PluginModule: dispatcher[fn](...args)
    PluginModule-->>Plugin: result

    Denops->>Plugin: unload()
    Plugin->>PluginModule: dispose AsyncDisposable
    Plugin-->>Denops: emit unload events
Loading

Possibly related PRs

Suggested labels

enhancement

Poem

A plugin hops in, so lively and new,
With import maps guiding where modules accrue.
It loads and unloads with a whisk of its tail,
Dispatching commands without ever fail.
Tested and tidy, with helpers in tow—
This rabbit approves, let the plugins now grow!
🐇✨


📜 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 ac096b5 and 955a3fe.

📒 Files selected for processing (8)
  • deno.jsonc (1 hunks)
  • denops/@denops-private/plugin.ts (1 hunks)
  • denops/@denops-private/plugin_test.ts (1 hunks)
  • denops/@denops-private/service.ts (1 hunks)
  • tests/denops/testdata/with_import_map/helper.ts (1 hunks)
  • tests/denops/testdata/with_import_map/import_map.json (1 hunks)
  • tests/denops/testdata/with_import_map/import_map.jsonc (1 hunks)
  • tests/denops/testdata/with_import_map/plugin_with_import_map.ts (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

@lambdalisue lambdalisue marked this pull request as draft July 13, 2025 11:13
@lambdalisue lambdalisue force-pushed the support-import-map branch 2 times, most recently from 9e5e49e to fb3732e Compare July 13, 2025 11:16
@lambdalisue lambdalisue changed the title Support import_map.json[c] in denops plugin directory Support import_map.json[c] in denops plugin directory Jul 13, 2025
Copy link

codecov bot commented Jul 13, 2025

Codecov Report

Attention: Patch coverage is 97.45223% with 4 lines in your changes missing coverage. Please review.

Project coverage is 96.99%. Comparing base (2c1717f) to head (955a3fe).

Files with missing lines Patch % Lines
denops/@denops-private/plugin.ts 97.43% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #446      +/-   ##
==========================================
+ Coverage   95.83%   96.99%   +1.16%     
==========================================
  Files          25       27       +2     
  Lines        1415     1462      +47     
  Branches      181      189       +8     
==========================================
+ Hits         1356     1418      +62     
+ Misses         56       40      -16     
- Partials        3        4       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Now if the plugin has `import_map.json` or `import_map.jsonc` in the
same directory with `main.ts`, it will be loaded automatically and used
to resolve imports.
@lambdalisue lambdalisue marked this pull request as ready for review July 19, 2025 09:59
@lambdalisue lambdalisue merged commit 8ee1fcc into main Jul 19, 2025
34 of 36 checks passed
@lambdalisue lambdalisue deleted the support-import-map branch July 19, 2025 09:59
@lambdalisue lambdalisue restored the support-import-map branch July 20, 2025 04:19
@lambdalisue lambdalisue deleted the support-import-map branch August 2, 2025 14:15
@coderabbitai coderabbitai bot mentioned this pull request Aug 4, 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.

1 participant