Skip to content

Global per-project configuration of autocomplete #7330

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

zth
Copy link
Collaborator

@zth zth commented Mar 11, 2025

cc @fhammerschmidt

This hard codes a setup that works for doing global configuration of autocomplete. What's needed here is to connect the dots:

  • Make this an actual config in rescript.json, and read from that in the analysis tooling
  • Add the config to the JSON schema for rescript.json
  • Think about edge cases etc
  • Backport to the extension repo code so it works for <12 as well

EDIT: I think this is ready to go now @fhammerschmidt ? I made some final edits.

@@ -415,6 +415,7 @@ ContextPath Value[String, split](Nolabel, Nolabel)
ContextPath Value[String, split]
Path String.split
Path Stdlib.Array.ma
Path ArrayUtils.ma
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This change in output is fine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Notice how both "configured" global completions work in this file.

@@ -1135,6 +1135,32 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~pos ~env ~exact
| _ -> false
else true)
in

(* TODO(config-complete-builtins) This config and config resolution should come from `package` instead. *)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

package here is under full.package I believe, and is a concept used throughout the analysis. It represents the information needed from rescript.json.

(* TODO(config-complete-builtins) This config and config resolution should come from `package` instead. *)
let pretendPackageBuiltinsConfig =
Misc.StringMap.of_list
[("array", ["ArrayUtils"]); ("Fastify.t", ["FastifyExt"])]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is an array of identifiers because you could configure several modules to complete from.

The format should be Path.To.Module. These examples are all single module paths, but could've just as easily been for example Utils.Array instead of ArrayUtils. Might be good adding test cases for that as well.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Syntax Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.05.

Benchmark suite Current: 0051096 Previous: 3f06468 Ratio
Print HeroGraphic.res - time/run 26.637155366666665 ms 7.840572506666666 ms 3.40
Print HeroGraphic.res - allocs/run 10571467 words 1396448 words 7.57

This comment was automatically generated by workflow using github-action-benchmark.

@zth zth force-pushed the global-completion-config branch from 0051096 to 389c4cc Compare April 23, 2025 19:19
@zth zth changed the title [WIP] Global per-project configuration of autocomplete Global per-project configuration of autocomplete Apr 23, 2025
@zth zth marked this pull request as ready for review April 23, 2025 19:37
@zth zth requested review from cknitt and cristianoc April 23, 2025 19:37
Copy link
Collaborator

@cristianoc cristianoc left a comment

Choose a reason for hiding this comment

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

sweet -- the implementation looks good
don't know if there's more discussion to be had about ergonomics by other reviewers

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.

3 participants