Skip to content

feat: Autocompletions for Config Block #66

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
HampB opened this issue Nov 19, 2024 · 6 comments
Open

feat: Autocompletions for Config Block #66

HampB opened this issue Nov 19, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@HampB
Copy link
Collaborator

HampB commented Nov 19, 2024

Description
It would be helpful to implement autocompletions when working inside the config block. This would enhance the developer experience by providing suggestions and reducing potential errors while writing configurations.

Proposed Solution

  1. Add a method to check if the user is currently inside the config block.
  2. Use a JSON schema of the config block for the Language Server Protocol (LSP) to enable autocompletions.

Considerations

  • The JSON schema for the config block would need to be maintained to reflect changes in Dataform updates.

To build dependencies to dataform version, we should probably not enforce validation at this point, just add autocompletions based of the latest release.


What's the thoughts on this, something we should look into?

@ashish10alex ashish10alex added the enhancement New feature or request label Nov 19, 2024
@ashish10alex
Copy link
Owner

ashish10alex commented Nov 19, 2024

Hi @HampB , I had a brief exploration of the idea including implementing an MVP. My thoughts so far

  • I like the idea
  • The fact that we need to check are we in the config block on each character we type does not sit right. Although it can be an operation that runs in low 2 digits milliseconds
  • Out of most people I have seen using the extension most people copy paste the config. I personally have been using the config block snippets for table / view / operation depending on what I need. That said, I usually need to check what are the different types of assertions / bigquery options available by going to the docs. This could be streamlined
  • Would something like snippets be better. e.g. prefix the snippet with config-assert.. it gives you a template with all assertion options and same for others. Using snippets will mean hopefully less code to maintain and minimal performance impact
  • From a user experience perspective I want it to be as non-laggy as possible. I personally, use an M2 Mac so extension works very fast on my laptop. But on the other hand some of my colleagues use windows where I can see noticeable lag in loading web views among others.

Happy to discuss further

@HampB
Copy link
Collaborator Author

HampB commented Nov 19, 2024

Hey @ashish10alex ,
Thanks for testing and your thorough explanations.
I agree with you on more or less all points.
I as-well most often copy an existing config or use the snippets.
But often need to look up a syntax in the docs or by looking at another model.

I also agree that speed is important, if it appears laggy even if just a little it's most likely not worth the win.

I believe the feature would need to support ctrl + space or similar command to get a list of possible values.

Snippets would be messy if you're editing an already existing config block I believe?

For example:

  • I would like to add a updatePartitionFilter to an already existing bigquery config

Could we possibly only activate the autocomplete inside config on ctrl + space rather than on each typed letter?

Or maybe a workaround could be some kind of hover that displays the schema?


I know to little about vscodes lsp, I'll do some research tomorrow 🙂

@ashish10alex
Copy link
Owner

You point regarding snippets makes sense. ctrl + space trigger seems like a good direction to go. I'd say build an MVP of what you have in mind and we can always evaluate user experience / speed etc. But this is something that will be great to have.

@HampB
Copy link
Collaborator Author

HampB commented Nov 21, 2024

Hey @ashish10alex
I've done some testing aswell now and reached the same conclusion as you mentioned:

  • The fact that we need to check whether we are in the config block on each character we type does not sit right. Although it can be an operation that runs in low 2 digits milliseconds.

Unfortunately, it doesn't seem possible to activate the registerCompletionItemProvider only on hotkey press.

To move forward, I see two potential options:

  1. Add a setting to toggle config-autocomplete:

    • This would allow users to turn off the config block lookup if it causes noticeable lag.
  2. Introduce hover functionality for the config block:

    • We could start by adding hover-based documentation, similar to this example (but with more details):
      Example Image

Let me know your thoughts or if there's another direction you'd like to explore

@ashish10alex
Copy link
Owner

Hi @HampB , thanks for looking into it. I'd lean on starting with option 2. as it's easy to remember the top level keywords but harder to recall the nested keys. Also, this is something we could build with minimal performance impact.

Option (1), we can have but it will be a very hidden feature + has to false by default. Also, once it's turned on there is high probability that user forgets to turn it off and starts thinking that their editor is clunky/slow when using the plugin / vscode. Also, lets use option (1) for at least a month and see our own personal experience using it.

@ashish10alex
Copy link
Owner

feat(snippets): assertions and bigquery options in config block should significantly improve the experience of working with config blocks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants