Skip to content
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

💪 Refactoring for denops v6 #292

Closed
wants to merge 21 commits into from
Closed

💪 Refactoring for denops v6 #292

wants to merge 21 commits into from

Conversation

lambdalisue
Copy link
Member

@lambdalisue lambdalisue commented Nov 26, 2023

Make it happen!

Summary by CodeRabbit

  • New Features

    • Introduced a denops#plugin#discover() function to automatically discover and register plugins.
  • Enhancements

    • Streamlined the denops#plugin#register() function by simplifying its signature.
    • Updated the denops#plugin#reload() function to improve performance and reliability.
  • Bug Fixes

    • Fixed issues with plugin registration and reloading processes.
  • Refactor

    • Removed deprecated configurations and functions to clean up the codebase.
    • Enhanced internal command handling for better efficiency and error management.
  • Documentation

    • Updated documentation to reflect the removal of the g:denops#trace variable and the addition of new plugin discovery functionality.
  • Chores

    • Updated dependencies to newer versions for improved stability and feature support.

Copy link

coderabbitai bot commented Nov 26, 2023

Walkthrough

The changes across the codebase reflect a significant refactoring effort, focusing on simplifying function signatures, updating dependencies, and enhancing type safety. Deprecated functionalities have been removed, and there's a shift towards using promises and type guards. The updates also include performance logging enhancements and a move towards stricter version control in imports.

Changes

File Path Change Summary
autoload/denops/plugin.vim Simplified function signatures for denops#plugin#... functions, removed s:options and s:trace.
denops/@denops-private/cli.ts Updated imports, replaced parse with parseArgs, added ensure and isMeta, and changed logging from console.log to console.warn.
denops/@denops-private/error.ts Updated is function import to a newer version.
denops/@denops-private/host/... Updated imports, modified method signatures and return types, added type guards, and removed deprecated functions.
denops/@denops-private/impl.ts Added ensure and is, introduced isBatchReturn, and modified functions to return promises or direct results.
denops/@denops-private/impl_test.ts Updated dependency versions and added new test step for denops.redraw().
denops/@denops-private/service.ts Updated dependencies, modified constructor and methods to remove deprecated parameters, and introduced disposePlugin.
denops/@denops-private/util.ts Added new module with isMeta predicate function and updated imports.
denops/@denops-private/version.ts Updated path and semver module versions.
denops/@denops-private/worker/script.ts Replaced imports, removed deprecated parameters, added emit function, and updated event listener validation.
doc/denops.txt Removed g:denops#trace, added denops#plugin#discover(), and updated function signatures.
autoload/denops/_internal/server/... Changed s:connect function behavior and added conditional '--quiet' flag in proc.vim.

Poem

🐇✨
In the code's burrow, deep and wide,
Refactoring flows like the tide.
Simplified calls, types aligned,
A rabbit's touch, modernized and refined. 🌟
🐇✨

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • You can tag CodeRabbit on specific lines of code or entire files in the PR by tagging @coderabbitai in a comment. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • You can tag @coderabbitai in a PR comment and ask questions about the PR and the codebase. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid.
    • @coderabbitai read the files in the src/scheduler package and generate README in the markdown format.

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.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

codecov bot commented Nov 26, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (886bfa0) 92.59% compared to head (7917a57) 96.42%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #292      +/-   ##
==========================================
+ Coverage   92.59%   96.42%   +3.83%     
==========================================
  Files           3        3              
  Lines          81       84       +3     
  Branches        6        5       -1     
==========================================
+ Hits           75       81       +6     
+ Misses          6        3       -3     

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

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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 6c7ebef and e563f05.
Files selected for processing (14)
  • autoload/denops/plugin.vim (2 hunks)
  • denops/@denops-private/cli.ts (2 hunks)
  • denops/@denops-private/error.ts (1 hunks)
  • denops/@denops-private/host/base.ts (2 hunks)
  • denops/@denops-private/host/invoker.ts (2 hunks)
  • denops/@denops-private/host/nvim.ts (3 hunks)
  • denops/@denops-private/host/vim.ts (3 hunks)
  • denops/@denops-private/impl.ts (3 hunks)
  • denops/@denops-private/impl_test.ts (1 hunks)
  • denops/@denops-private/service.ts (5 hunks)
  • denops/@denops-private/util.ts (1 hunks)
  • denops/@denops-private/version.ts (1 hunks)
  • denops/@denops-private/worker/script.ts (3 hunks)
  • doc/denops.txt (2 hunks)
Files skipped from review due to trivial changes (3)
  • denops/@denops-private/error.ts
  • denops/@denops-private/impl_test.ts
  • denops/@denops-private/version.ts
Additional comments: 38
autoload/denops/plugin.vim (4)
  • 59-81:
    The deprecation logic in denops#plugin#register is well-implemented, providing clear instructions for users to update their code.

  • 84-93:
    The deprecation logic in denops#plugin#reload is well-implemented, providing clear instructions for users to update their code.

  • 96-108:
    The deprecation logic in denops#plugin#discover is well-implemented, providing clear instructions for users to update their code.

  • 141-147:
    The s:register function correctly implements the simplified plugin registration process.

denops/@denops-private/cli.ts (2)
  • 1-6:
    The import statements have been updated to the newer versions as described in the summary. Ensure that these updates do not introduce breaking changes and that all dependent code has been updated accordingly.

  • 49-52:
    The parseArgs function is used correctly with the appropriate options for command line arguments. Ensure that all scripts and documentation that rely on the CLI have been updated to reflect any changes in the available options.

denops/@denops-private/host/base.ts (2)
  • 1-3:
    The change to import Invoker as a type is appropriate since it's only used for type annotations.

  • 18-23:
    The changes to the batch method's signature, using readonly tuples for both parameters and return types, enhance type safety and immutability.

denops/@denops-private/host/invoker.ts (2)
  • 1-2:
    The import statements have been updated correctly to reflect the changes in the summary.

  • 11-17:
    The register and reload methods in the Invoker class have been updated to accept fewer parameters and return promises, aligning with the summary's description of the changes.

denops/@denops-private/host/nvim.ts (2)
  • 74-90:
    The refactoring of the batch function to use ensure for result validation and to return a readonly tuple aligns with the summary and enhances type safety. The error handling within the function is also correctly implemented.

  • 111-113:
    The simplification of the waitClosed function to return a promise directly is consistent with the refactoring goals and aligns with the summary.

denops/@denops-private/host/vim.ts (4)
  • 1-8:
    The import statements are correctly updated to reflect the new dependencies and type imports.

  • 10-20:
    The introduction of type predicates isCallReturn and isBatchReturn enhances type safety for the call and batch methods.

  • 37-58:
    The refactoring of the call and batch methods to use promises and ensure for error handling aligns with the goal of enhancing type safety and error handling.

  • 100-102:
    The dispatch function correctly uses the new isInvokeMessage predicate to ensure the correct message format is being processed.

denops/@denops-private/impl.ts (8)
  • 1-4:
    The addition of ensure and is from the external module aligns with the refactoring goals of enhancing type safety and error handling.

  • 16-16:
    The introduction of isBatchReturn is a good practice for ensuring the type safety of batch operation results.

  • 42-43:
    The redraw function correctly returns a promise directly, aligning with the promise-oriented approach mentioned in the summary.

  • 46-47:
    The call function has been updated to return the result of the session call directly, which is consistent with the refactoring goals.

  • 50-62:
    The batch function's refactoring to use ensure for result validation and to throw a BatchError when needed is a good enhancement for error handling.

  • 65-66:
    The cmd function has been updated to return a promise directly, which is consistent with the changes described in the summary.

  • 69-70:
    The eval function has been updated to return the result of the session call directly, which is consistent with the refactoring goals.

  • 73-79:
    The dispatch function has been updated to return the result of the session call directly, aligning with the promise-oriented approach.

denops/@denops-private/service.ts (6)
  • 1-21:
    The imports have been updated to newer versions, and the ensure function has been added, which aligns with the summary.

  • 48-58:
    The register method has been correctly updated to be asynchronous and the meta and options parameters have been removed as per the summary.

  • 68-79:
    The use of performance.now() as a suffix for the script URL in worker.postMessage is a good practice to avoid caching issues when reloading scripts.

  • 83-98:
    The reload method has been correctly updated to be asynchronous and the meta and options parameters have been removed as per the summary.

  • 112-136:
    The dispose method has been updated to asynchronously dispose of all plugins, which is consistent with the summary.

  • 143-173:
    The dispatcher methods have been updated, and the trace parameter has been removed, which is consistent with the summary.

denops/@denops-private/util.ts (1)
  • 1-9:

The implementation of the isMeta predicate function correctly validates the Meta type according to the provided summary. The use of the is utility and TypeScript's type system is appropriate and follows best practices for type safety and validation.

denops/@denops-private/worker/script.ts (5)
  • 18-20:
    The new isMessageData validation object correctly checks for the structure of the incoming message data, ensuring type safety.

  • 23-26:
    The emit function is a good abstraction for event emission, and the error handling within it is appropriate for avoiding unhandled promise rejections.

  • 28-36:
    The removal of the trace parameter from the main function is consistent with the summary, and the function does not reference trace elsewhere.

  • 72-84:
    The try-catch block in the main function correctly handles the plugin lifecycle events and ensures that the worker is closed properly after execution or in case of an error.

  • 89-96:
    The event listener correctly uses the ensure function with isMessageData for data validation, which is a good practice for type safety and error prevention.

doc/denops.txt (2)
  • 84-90:
    The summary mentions the removal of g:denops#trace, but this hunk shows g:denops#debug. Please clarify if g:denops#debug should be removed or if the summary should be updated.

  • 262-289:
    The changes to the documentation of the plugin functions align with the summary provided, reflecting the simplified function signatures and removal of deprecated options.

denops/@denops-private/worker/script.ts Show resolved Hide resolved
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e563f05 and 4caf5d8.
Files selected for processing (1)
  • autoload/denops/plugin.vim (2 hunks)
Additional comments: 4
autoload/denops/plugin.vim (4)
  • 59-81:
    The refactoring of denops#plugin#register correctly handles the deprecation of the old call patterns and ensures that the function can only be called with the correct number of arguments post-deprecation.

  • 84-93:
    The refactoring of denops#plugin#reload correctly handles the deprecation of the options argument and ensures that no additional arguments are processed.

  • 96-108:
    The refactoring of denops#plugin#discover correctly handles the deprecation of the options argument and ensures that no additional arguments are processed.

  • 141-147:
    The refactoring of s:register correctly updates the function signature to accept only the plugin and script arguments and correctly implements the registration logic.

@lambdalisue lambdalisue force-pushed the ref branch 2 times, most recently from a52f086 to f677826 Compare November 26, 2023 18:07
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.

Review Status

Actionable comments generated: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 6c7ebef and f677826.
Files selected for processing (16)
  • autoload/denops/_internal/server/chan.vim (1 hunks)
  • autoload/denops/_internal/server/proc.vim (1 hunks)
  • autoload/denops/plugin.vim (2 hunks)
  • denops/@denops-private/cli.ts (3 hunks)
  • denops/@denops-private/error.ts (1 hunks)
  • denops/@denops-private/host/base.ts (2 hunks)
  • denops/@denops-private/host/invoker.ts (2 hunks)
  • denops/@denops-private/host/nvim.ts (4 hunks)
  • denops/@denops-private/host/vim.ts (3 hunks)
  • denops/@denops-private/impl.ts (3 hunks)
  • denops/@denops-private/impl_test.ts (1 hunks)
  • denops/@denops-private/service.ts (5 hunks)
  • denops/@denops-private/util.ts (1 hunks)
  • denops/@denops-private/version.ts (1 hunks)
  • denops/@denops-private/worker/script.ts (3 hunks)
  • doc/denops.txt (2 hunks)
Files skipped from review due to trivial changes (2)
  • denops/@denops-private/error.ts
  • denops/@denops-private/version.ts
Additional comments: 49
autoload/denops/_internal/server/chan.vim (1)
  • 93-97:
    The change from doautocmd User DenopsReady to call s:rpcnotify(s:chan, 'void', []) is a significant alteration in the event notification mechanism. Ensure that all dependent features and plugins are compatible with this new approach.
autoload/denops/_internal/server/proc.vim (1)
  • 67-77:
    The conditional logic for appending the --quiet flag based on the g:denops#debug variable is correctly implemented and aligns with the summary.
autoload/denops/plugin.vim (4)
  • 57-82:
    The refactoring of denops#plugin#register function correctly handles backward compatibility by providing deprecation warnings and fallbacks for the old function signatures.

  • 84-93:
    The refactoring of denops#plugin#reload function correctly includes a deprecation warning for the removed options argument.

  • 96-108:
    The refactoring of denops#plugin#discover function correctly includes a deprecation warning for the removed options argument and iterates over discovered plugins to register them.

  • 141-147:
    The s:register function has been updated to match the new plugin registration process, and it correctly notifies the denops server to invoke the 'register' command with the necessary arguments.

denops/@denops-private/cli.ts (3)
  • 1-8:
    The import changes align with the summary provided and reflect the updated dependencies and utilities.

  • 57-60:
    The usage of parseArgs for parsing command-line arguments is correct and the options are properly configured.

  • 69-75:
    The use of console.log for printing the identity is correct, and the use of console.warn for the listening address and port is consistent with the other uses of console.warn in the code.

denops/@denops-private/host/base.ts (2)
  • 1-3:
    The change to import Invoker as a type is appropriate since it's only used for type information.

  • 18-23:
    The changes to the batch function's parameter and return types enhance type safety and immutability, which are beneficial for the codebase.

denops/@denops-private/host/invoker.ts (2)
  • 1-2:
    The import statements have been correctly updated to the new versions and paths as per the summary.

  • 11-17:
    The register and reload methods have been correctly updated to accept fewer parameters, aligning with the refactoring goals.

denops/@denops-private/host/nvim.ts (7)
  • 1-5:
    The import from "unknownutil" has been updated to v3.11.0, which aligns with the pull request summary mentioning the use of the latest version of ensure and is utilities.

  • 15-23:
    The addition of isNvimCallFunctionReturn for type checking aligns with the pull request's focus on enhancing type safety.

  • 30-31:
    The constructor of the Neovim class has been modified, and the #invoker property has been added to the class, as per the summary.

  • 34-58:
    The #session setup and dispatcher methods have been refactored to use ensurePromise for handling invoker methods, which is consistent with the pull request's focus on error handling and validation.

  • 94-109:
    The batch method signature has been updated to enhance type safety by using readonly tuples, which is in line with the pull request's focus on type safety enhancements.

  • 112-114:
    The register method has been updated to assign the invoker to the #invoker property, which is consistent with the summary.

  • 129-131:
    The addition of the ensurePromise function to handle both synchronous and asynchronous values aligns with the pull request's focus on error handling and validation.

denops/@denops-private/host/vim.ts (7)
  • 10-26:
    The introduction of new type guards isCallReturn, isBatchReturn, isVoidMessage, and isInvokeMessage enhances type safety and ensures that the data conforms to expected types before processing.

  • 57-57:
    The change to return a resolved Promise from the redraw method aligns with the asynchronous nature of the method and ensures consistency with other methods that return a Promise.

  • 60-70:
    The refactoring of the call method to return a Promise and use the ensure function for runtime type checking is a good practice, as it improves error handling and ensures that the returned value is of the expected type.

  • 72-78:
    The update to the batch method to return a Promise with a readonly array as the result is a good practice, as it enforces immutability of the returned data and enhances type safety.

  • 80-82:
    The update to the register method to assign the invoker to a class property is a straightforward change that simplifies the method's implementation.

  • 84-102:
    The introduction of the private method #dispatch centralizes message processing, which can improve maintainability and make the class easier to understand.

  • 113-114:
    The dispose method's handling of the session shutdown with a try-catch block that ignores errors is a common pattern for cleanup functions, ensuring that any errors during shutdown do not impact the disposal process.

denops/@denops-private/impl.ts (5)
  • 16-16:
    The definition of isBatchReturn correctly uses the is utility to ensure the structure of the batch return value.

  • 46-47:
    The call function correctly returns the result of the session call directly.

  • 50-62:
    The batch function correctly handles the session call result, using ensure for validation and throwing a BatchError when appropriate.

  • 69-70:
    The eval function correctly returns the result of the session call directly.

  • 73-79:
    The dispatch function correctly returns the result of the session call directly.

denops/@denops-private/impl_test.ts (2)
  • 1-7:
    The import paths have been updated to the newer version of the Deno standard library, which is consistent with the summary.

  • 14-30:
    The new test step "denops.redraw() does nothing" correctly asserts that denops.redraw() returns undefined for different arguments, aligning with the intended behavior.

denops/@denops-private/service.ts (8)
  • 60-63:
    The implementation of a cache-busting mechanism using a timestamp as a URL fragment is a good practice to ensure that the latest version of the script is loaded, especially when reloading plugins.

  • 78-90:
    The simplification of the reload method by removing unused parameters and relying on the stored script path is a good refactor for maintainability and clarity.

  • 107-109:
    Using Promise.all to dispose of plugins concurrently is a good practice for performance, as it allows for parallel cleanup operations.

  • 137-140:
    The reload dispatcher method correctly asserts the type of the trace parameter and handles the reload operation without using the deprecated trace parameter.

  • 143-145:
    The redraw dispatcher method correctly asserts the type of the force parameter and delegates the redraw operation to the host, which is a clean and type-safe implementation.

  • 148-151:
    The call dispatcher method correctly asserts the types of the fn and args parameters and delegates the call operation to the host, ensuring type safety and proper delegation.

  • 154-156:
    The batch dispatcher method correctly asserts the type of the calls parameter and delegates the batch operation to the host, which is a good practice for type safety and code clarity.

  • 159-163:
    The dispatch dispatcher method correctly asserts the types of the name, fn, and args parameters and handles the dispatch operation within the service, ensuring type safety and proper internal delegation.

denops/@denops-private/util.ts (1)
  • 4-9:
    The isMeta predicate function correctly validates the Meta type properties using the is utility. The use of as const for literal types is appropriate, and the code is modular and maintainable.
denops/@denops-private/worker/script.ts (4)
  • 1-14:
    The import of isMeta is still present, which is correct as it is being used in the isMessageData object definition. No action is needed here.

  • 18-20:
    The isMessageData object definition correctly uses isMeta to validate the meta property, ensuring the data structure is as expected.

  • 72-84:
    The main function has been updated to include proper error handling and event emission, which aligns with the summary of changes.

  • 89-96:
    The event listener for the worker correctly uses ensure and isMessageData to validate the incoming message data, which is in line with the summary of changes.

doc/denops.txt (2)
  • 84-90:
    The hunk correctly reflects the removal of g:denops#trace and the presence of g:denops#debug.

  • 262-288:
    The hunk correctly reflects the updated function signatures for denops#plugin#discover, denops#plugin#register, and denops#plugin#reload functions, aligning with the summary.

denops/@denops-private/cli.ts Show resolved Hide resolved
denops/@denops-private/impl.ts Show resolved Hide resolved
denops/@denops-private/impl.ts Show resolved Hide resolved
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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 6c7ebef and 21c675f.
Files selected for processing (17)
  • autoload/denops.vim (1 hunks)
  • autoload/denops/_internal/server/chan.vim (1 hunks)
  • autoload/denops/_internal/server/proc.vim (1 hunks)
  • autoload/denops/plugin.vim (2 hunks)
  • denops/@denops-private/cli.ts (3 hunks)
  • denops/@denops-private/error.ts (1 hunks)
  • denops/@denops-private/host/base.ts (2 hunks)
  • denops/@denops-private/host/invoker.ts (2 hunks)
  • denops/@denops-private/host/nvim.ts (4 hunks)
  • denops/@denops-private/host/vim.ts (3 hunks)
  • denops/@denops-private/impl.ts (3 hunks)
  • denops/@denops-private/impl_test.ts (1 hunks)
  • denops/@denops-private/service.ts (5 hunks)
  • denops/@denops-private/util.ts (1 hunks)
  • denops/@denops-private/version.ts (1 hunks)
  • denops/@denops-private/worker/script.ts (3 hunks)
  • doc/denops.txt (2 hunks)
Files skipped from review due to trivial changes (3)
  • autoload/denops.vim
  • denops/@denops-private/error.ts
  • denops/@denops-private/version.ts
Additional comments: 52
autoload/denops/_internal/server/chan.vim (1)
  • 95-96: The change from triggering an autocmd event to invoking an RPC notification may affect plugins or parts of the codebase that rely on the DenopsReady event. Ensure that all dependent code has been updated to handle this new notification mechanism.
autoload/denops/_internal/server/proc.vim (1)
  • 67-78: The conditional addition of the '--quiet' flag based on the g:denops#debug variable is a good approach to control the verbosity of the output. Ensure that g:denops#debug is defined before this code is executed to avoid any runtime errors.
autoload/denops/plugin.vim (4)
  • 59-81: The deprecation warnings and conditional logic for handling different argument combinations in denops#plugin#register are correctly implemented.

  • 84-93: The deprecation warning and the updated call to denops#server#notify in denops#plugin#reload are correctly implemented.

  • 96-108: The deprecation warning in denops#plugin#discover and the loop that registers discovered plugins are correctly implemented.

  • 141-147: The s:register function has been correctly updated to match the new function signature that accepts only two arguments.

denops/@denops-private/cli.ts (4)
  • 1-8: The imports have been updated to use newer versions of dependencies and additional utilities like ensure and isMeta. Ensure that these new utilities are used correctly throughout the codebase.

  • 26-60: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [26-75]

The use of console.warn for logging connection information and performance measurements is unconventional but may be intentional to highlight these messages. Ensure that this aligns with the intended logging strategy.

  • 57-60: The parseArgs function is used to parse command-line arguments, and the parsed arguments are used to set up the listener and control logging verbosity. Ensure that the arguments are handled correctly in all relevant parts of the codebase.

  • 69-74: The console.log statement is used to output the local address when the identity flag is set, and console.warn is used to log the listening address. Ensure that this is consistent with the intended output and logging strategy.

denops/@denops-private/host/base.ts (3)
  • 1-2: The change to import Invoker as a type is appropriate since it seems to be used only for type annotations within this file.

  • 21-23: The use of readonly tuples for the calls parameter in the batch function is a good practice as it enforces immutability, ensuring that the input cannot be modified.

  • 23-23: The update to the return type of the batch function to use readonly tuples is consistent with the immutability enforced on the calls parameter, ensuring that the returned array elements cannot be modified.

denops/@denops-private/host/invoker.ts (2)
  • 1-1: The import statement for the is module has been updated to version 3.11.0. Ensure that this version is compatible with the rest of the codebase and that all uses of the is module have been tested with the new version.

  • 11-17: The register and reload methods have been simplified to accept fewer parameters. Ensure that all calls to these methods have been updated accordingly and that the removed parameters (meta, options, and trace) are no longer required or have been handled differently in the codebase.

denops/@denops-private/host/nvim.ts (7)
  • 3-3: The addition of the ensure import is appropriate as it is used within the batch method to validate the return type.

  • 28-28: The #invoker property is correctly declared as optional since it is assigned later in the register method.

  • 97-108: The batch method has been updated to return a tuple containing the results array and an error string. Ensure that all usages of this method handle the new return type correctly.

  • 112-113: The register method correctly assigns the passed invoker to the #invoker property. Ensure that the Invoker is registered before any invocation occurs.

  • 116-117: The waitClosed method now returns a promise from the Session's wait method, which is the expected behavior for an asynchronous operation.

  • 94-120: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [120-125]

The dispose method correctly handles the session shutdown within a try-catch block, ignoring any errors that occur during shutdown.

  • 129-131: The ensurePromise utility function is correctly implemented to wrap non-promise values in a promise, which is useful for ensuring consistent asynchronous behavior.
denops/@denops-private/host/vim.ts (5)
  • 1-1: The import of ensure and is from an external module is appropriate for the new type checks introduced in the call and batch methods.

  • 60-70: The call method has been correctly updated to return a Promise and includes proper error handling.

  • 72-78: The batch method has been correctly updated to return a Promise with a readonly array as the result, which aligns with the new API contract.

  • 80-82: The register method has been updated to assign the invoker to a class property, which is a straightforward and correct change.

  • 113-114: The dispose method is correctly implemented to handle exceptions silently, which is appropriate for a cleanup function.

denops/@denops-private/impl.ts (6)
  • 1-4: The addition of the import statement for ensure and is is appropriate for the new functionality introduced in the batch function.

  • 16-16: The introduction of the isBatchReturn constant is a good practice for type validation in the batch function.

  • 42-43: The use of .then() without a callback in the redraw function is redundant and can be removed for clarity.

-    return this.#session.call("redraw", force).then();
+    return this.#session.call("redraw", force);
  • 65-66: The use of .then() without a callback in the cmd function is redundant and can be removed for clarity.
-    return this.#session.call("call", "denops#api#cmd", cmd, ctx).then();
+    return this.#session.call("call", "denops#api#cmd", cmd, ctx);
  • 50-62: The changes to the batch function, including the use of ensure for type validation and throwing a BatchError, are correctly implemented.

  • 69-79: The modifications to the eval and dispatch functions to return the result of the session call directly are consistent with the refactoring pattern applied to other functions in this file.

denops/@denops-private/impl_test.ts (3)
  • 1-6: The version numbers for the dependencies have been updated correctly.

  • 13-30: The new test cases for denops.redraw() are well-structured and check for the expected undefined return value for different parameter scenarios.

  • 33-35: No changes detected in the remaining parts of the test file outside the hunk.

denops/@denops-private/service.ts (7)
  • 1-10: The dependencies have been updated to newer versions. Ensure that the updated versions are backward compatible and do not introduce breaking changes.

  • 34-38: The Service class constructor now requires a meta parameter. Verify that all instantiations of the Service class have been updated accordingly.

  • 41-50: The register method has been simplified to only require name and script parameters. Ensure that all calls to this method have been updated to match the new signature.

  • 78-90: The reload method has been simplified to only accept the name parameter. Verify that all calls to this method have been updated to match the new signature.

  • 107-109: The dispose method now uses disposePlugin for disposing of plugins. Ensure that disposePlugin handles all necessary cleanup tasks.

  • 136-140: The reload dispatcher method has been updated to no longer accept a trace parameter. Ensure that all dispatch calls to reload have been updated to match the new signature.

  • 60-63: The resolveScriptUrl function has been updated. Verify that the new implementation correctly resolves script URLs in all scenarios where it is used.

denops/@denops-private/util.ts (1)
  • 1-9: The implementation of isMeta and the import statements are correct and follow best practices for type safety and maintainability.
denops/@denops-private/worker/script.ts (5)
  • 1-14: The imports have been updated to the latest version, and unused imports have been removed, which is good for maintaining up-to-date dependencies and clean code.

  • 23-26: The new emit function is implemented correctly with proper error handling.

  • 28-36: The main function signature has been updated by removing the trace parameter, and the function has been updated accordingly.

  • 74-77: The main function now includes calls to the new emit function, which seems to be used correctly to emit events before and after the plugin's main function is called.

  • 91-96: The event listener has been updated to use the ensure function with isMessageData for validation, which is a good practice for type safety and ensures that the event data matches the expected schema.

doc/denops.txt (3)
  • 265-272: The addition of denops#plugin#discover() function is consistent with the summary and provides a way to automatically discover and register denops plugins. This should improve the usability and maintainability of the plugin system.

  • 273-282: The simplification of the denops#plugin#register() function signature by removing the optional script and options parameters is consistent with the summary and should make the plugin registration process more straightforward.

  • 284-287: The removal of the options parameter from the denops#plugin#reload() function is consistent with the summary and simplifies the reloading process.

denops/@denops-private/host/vim.ts Show resolved Hide resolved
Eliminated because the disadvantages of this feature are greater than
the advantages it brings, and its presence is an obstacle to refactoring.
This is a minor but a breaking change. This change affects the
`g:denops#debug` variable. After this commit, the variable must
be configured prior to the denops initialization.
Now denops always skip registration or reload on invalid plugins.
We must use `console.warn()` instead of `console.log()` because stdout
is used to tell proper address to the host.
Otherwise denops may not be ready on `DenopsReady`.
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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 886bfa0 and d4f0211.
Files selected for processing (17)
  • autoload/denops.vim (1 hunks)
  • autoload/denops/_internal/server/chan.vim (1 hunks)
  • autoload/denops/_internal/server/proc.vim (1 hunks)
  • autoload/denops/plugin.vim (2 hunks)
  • denops/@denops-private/cli.ts (3 hunks)
  • denops/@denops-private/error.ts (1 hunks)
  • denops/@denops-private/host/base.ts (2 hunks)
  • denops/@denops-private/host/invoker.ts (2 hunks)
  • denops/@denops-private/host/nvim.ts (4 hunks)
  • denops/@denops-private/host/vim.ts (3 hunks)
  • denops/@denops-private/impl.ts (3 hunks)
  • denops/@denops-private/impl_test.ts (1 hunks)
  • denops/@denops-private/service.ts (5 hunks)
  • denops/@denops-private/util.ts (1 hunks)
  • denops/@denops-private/version.ts (1 hunks)
  • denops/@denops-private/worker/script.ts (3 hunks)
  • doc/denops.txt (2 hunks)
Additional comments: 39
denops/@denops-private/util.ts (2)
  • 1-2: The update to the import statements, including the new version of unknownutil, is correct.

  • 4-9: The isMeta definition correctly uses is.ObjectOf to validate the Meta type with specific properties.

denops/@denops-private/error.ts (1)
  • 1-1: The update to the import statement for the is function with the new version of unknownutil is correct.
denops/@denops-private/host/base.ts (2)
  • 1-2: The update to the import statements for Disposable and Invoker with type declarations and new versions is correct.

  • 21-23: The batch method's signature has been correctly updated to use readonly for its parameters and return type, which is a good practice for immutability.

denops/@denops-private/version.ts (1)
  • 4-5: The update to the import statements for the path and semver modules with the new versions is correct.
autoload/denops.vim (1)
  • 21-26: The removal of the denops#trace configuration definition is consistent with the PR objectives and streamlines the configuration.
denops/@denops-private/host/invoker.ts (3)
  • 1-2: The update to the import statements for unknownutil and the type import for Service with the new version is correct.

  • 11-12: The simplification of the register method by removing unnecessary parameters aligns with the PR objectives to streamline the API.

  • 15-16: The simplification of the reload method by removing unnecessary parameters aligns with the PR objectives to streamline the API.

denops/@denops-private/impl.ts (7)
  • 1-1: The addition of the import statement for ensure and is from the updated version of unknownutil is correct.

  • 42-43: The redraw method has been updated to return a promise directly, which is a more modern and concise approach.

  • 46-47: The call method has been updated to return a promise directly, which is a more modern and concise approach.

  • 50-62: The batch method has been updated to return a promise directly, which is a more modern and concise approach.

  • 65-66: The cmd method has been updated to return a promise directly, which is a more modern and concise approach.

  • 69-70: The eval method has been updated to return a promise directly, which is a more modern and concise approach.

  • 73-78: The dispatch method has been updated to return a promise directly, which is a more modern and concise approach.

denops/@denops-private/cli.ts (2)
  • 1-8: The update to the import statements with new versions and additional imports is correct.

  • 26-60: The handleConn function has been updated to include additional logic for detecting hosts and handling services, which aligns with the PR objectives to enhance performance logging.

denops/@denops-private/worker/script.ts (2)
  • 1-14: The update to the import statements with new versions and the removal of unused imports is correct.

  • 18-27: The refactoring of the main function to use isMessageData and the emit function for emitting events aligns with the PR objectives to streamline event handling.

denops/@denops-private/host/vim.ts (1)
  • 1-26: The addition of type checks using is from unknownutil and the new #dispatch method enhance type safety and encapsulation of message handling.
denops/@denops-private/host/nvim.ts (2)
  • 1-27: The addition of type checks using is from unknownutil and the new #invoker property enhance type safety and encapsulation of invoker handling.

  • 129-131: The ensurePromise function is a good addition to ensure that a value is always treated as a promise, improving code robustness.

autoload/denops/_internal/server/chan.vim (1)
  • 96-96: Verify that the change from doautocmd to s:rpcnotify does not affect any plugins or event listeners that rely on the DenopsReady event.
autoload/denops/_internal/server/proc.vim (1)
  • 73-74: The conditional addition of the --quiet flag based on the g:denops#debug variable is a good practice to control verbosity based on the debug setting.
denops/@denops-private/service.ts (4)
  • 30-38: The addition of the meta property to the Service class constructor is a good practice for passing metadata, enhancing the class's functionality.

  • 41-50: The simplification of the register method by removing the meta and trace parameters aligns with the removal of the g:denops#trace configuration and streamlines the plugin registration process.

  • 78-90: The changes to the reload method, which now accepts only the name parameter, simplify the code and align with the refactoring objectives.

  • 136-166: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [121-166]

The simplification of the buildServiceSession function by removing conditional trace logic aligns with the removal of the g:denops#trace configuration and improves code maintainability.

denops/@denops-private/impl_test.ts (1)
  • 13-31: The new test case for denops.redraw() is well-structured and follows best practices by checking the function's behavior with different arguments. It's good to see multiple assertions covering different scenarios.
autoload/denops/plugin.vim (4)
  • 59-81: The deprecation warnings and argument handling in denops#plugin#register are correctly implemented. The function now guides users to the new expected usage, which is a good practice for backward compatibility.

  • 84-93: The deprecation warnings in denops#plugin#reload are correctly implemented, and the function now ignores any additional arguments, aligning with the updated function signature.

  • 96-107: The denops#plugin#discover function has been updated to remove the handling of options, and it now automatically discovers and registers plugins. This change simplifies the plugin discovery process.

  • 141-147: The s:register function has been updated to match the new plugin registration process, ensuring consistency across the codebase.

doc/denops.txt (4)
  • 90-95: The documentation update for g:denops#debug correctly reflects the changes in the codebase and provides clear information to the users about the debug mode.

  • 271-277: The documentation for the new denops#plugin#discover function is clear and accurately describes its purpose and behavior.

  • 279-283: The updates to the documentation for denops#plugin#register correctly reflect the changes to the function's behavior and signature, providing clarity on its usage.

  • 290-293: The documentation for denops#plugin#reload has been simplified to match the updated behavior of the function, which is now more efficient in handling plugin reloading.

this.#invoker = invoker;
}

async #dispatch(expr: unknown): Promise<unknown> {
Copy link

Choose a reason for hiding this comment

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

The #dispatch method is marked as async but does not contain any await expressions, which could be removed for simplification.

- async #dispatch(expr: unknown): Promise<unknown> {
+ #dispatch(expr: unknown): Promise<unknown> {

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
async #dispatch(expr: unknown): Promise<unknown> {
#dispatch(expr: unknown): Promise<unknown> {

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between d4f0211 and 7917a57.
Files selected for processing (7)
  • autoload/denops/_internal/job.vim (1 hunks)
  • autoload/denops/_internal/path.vim (2 hunks)
  • autoload/denops/_internal/server/chan.vim (3 hunks)
  • autoload/denops/_internal/server/proc.vim (2 hunks)
  • autoload/denops/_internal/wait.vim (1 hunks)
  • autoload/denops/server.vim (1 hunks)
  • autoload/health/denops.vim (5 hunks)
Files skipped from review due to trivial changes (2)
  • autoload/denops/_internal/job.vim
  • autoload/denops/server.vim
Files skipped from review as they are similar to previous changes (2)
  • autoload/denops/_internal/server/chan.vim
  • autoload/denops/_internal/server/proc.vim
Additional comments: 12
autoload/denops/_internal/path.vim (4)
  • 1-2: The change from mutable variables to immutable constants for path separators and root directory is a good practice for values that should not change during runtime.

  • 5-5: The update to use s:SEP in the denops#_internal#path#join function correctly reflects the refactoring to constants.

  • 22-22: The use of s:ROOT and s:SEP in the s:script function for Windows maintains consistency with the refactoring to constants.

  • 30-30: The use of s:ROOT in the s:script function for non-Windows systems is consistent with the refactoring to constants.

autoload/denops/_internal/wait.vim (1)
  • 23-41: The refactoring of the s:wait function to use getcharstr(0) and manage consumed input with feedkeys is a significant improvement for handling user input during the waiting process. Ensure that this change has been tested thoroughly, especially the behavior of feedkeys with different modes.
autoload/health/denops.vim (7)
  • 1-3: Changing version declarations to constants is a good practice to prevent accidental modification and to indicate that these values are fixed.

  • 49-49: The use of s:DENO_VERSION in the s:check_deno_version function correctly reflects the refactoring to constants.

  • 58-61: The comparison logic in s:check_deno_version using s:DENO_VERSION is correct and aligns with the refactoring to constants.

  • 71-71: The use of s:VIM_VERSION in the s:check_vim_version function correctly reflects the refactoring to constants.

  • 77-80: The comparison logic in s:check_vim_version using s:VIM_VERSION is correct and aligns with the refactoring to constants.

  • 90-90: The use of s:NEOVIM_VERSION in the s:check_neovim_version function correctly reflects the refactoring to constants.

  • 96-99: The comparison logic in s:check_neovim_version using s:NEOVIM_VERSION is correct and aligns with the refactoring to constants.

@lambdalisue lambdalisue marked this pull request as draft December 30, 2023 11:34
@lambdalisue lambdalisue closed this Jan 2, 2024
@lambdalisue lambdalisue deleted the ref branch February 3, 2024 10:38
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