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

[WIP] Global per-project configuration of autocomplete #7330

Draft
wants to merge 2 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

@@ -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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changes here seems related to changes in master that just hasn't been synced. So we can ignore this for now.

@@ -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.

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