Skip to content

Conversation

mityu
Copy link
Contributor

@mityu mityu commented Feb 22, 2025

Add utility functions, bindSourceArgs and bindCuratorArgs, to create a new source or curator which calls another source or curator respectively with fixing the head n number of command-line arguments.

For example, suppose if you have pickers defined like this,

definePickerFromSource(
  "runtime-files-1",
  bindSourceArgs(
    builtin.source.file,
    [Deno.env.get("VIMRUNTIME")],
  ),
  ...
)

definePickerFromSource(
  "runtime-files-2",
  bindSourceArgs(
    builtin.source.file,
    async (denops) => [await denops.eval("$VIMRUNTIME") as string],
  ),
  ...
)

then both :Fall runtime-files-1 and :Fall runtime-files-2 will be equivalent to :Fall file $VIMRUNTIME.
Plus, these utility functions does insert given arguments at the head of command-line arguments instead of replacing entire command-line arguments with given arguments, therefore :Fall runtime-files-1 additional-arg will be equivalent to :Fall file $VIMRUNTIME additional-arg (though file source does not accept two or more arguments and this is not actually a valid command).

Copy link

codecov bot commented Feb 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 51.48%. Comparing base (a21bd0a) to head (5cd98f9).
Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main       #5      +/-   ##
==========================================
+ Coverage   50.63%   51.48%   +0.85%     
==========================================
  Files          77       78       +1     
  Lines        2277     2317      +40     
  Branches       67       70       +3     
==========================================
+ Hits         1153     1193      +40     
  Misses       1124     1124              

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

@mityu mityu force-pushed the feat-bind-source-curator-args branch from 07362c1 to 9c11bc6 Compare February 22, 2025 15:31
@mityu
Copy link
Contributor Author

mityu commented Feb 22, 2025

Add missing export in deno.jsonc, and rebased the main branch.

Add utility functions to create a new source/curator which calls another
source/curator with some fixed args.
@mityu mityu force-pushed the feat-bind-source-curator-args branch from 9c11bc6 to f98e831 Compare February 22, 2025 17:25
return args instanceof Function ? await args(denops) : args;
}

export function bindSourceArgs<T extends Detail = Detail>(
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add documentation comment of the function.

@mityu
Copy link
Contributor Author

mityu commented Mar 2, 2025

Wrote documents. Also made the BoundArgsProvider type be exported.

@lambdalisue lambdalisue merged commit 04e8c64 into vim-fall:main Mar 4, 2025
7 checks passed
@mityu mityu deleted the feat-bind-source-curator-args branch March 4, 2025 01:01
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