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

Make type lenses plugin configurable #1491

Merged
merged 13 commits into from
Mar 5, 2021
Merged

Conversation

berberman
Copy link
Collaborator

@berberman berberman commented Mar 4, 2021

This PR is rebased on #1471, so we could close #1471 in favour of this (if it looks good).

Closes #1477
Closes #1468
Closes #622

Demo

output.mp4

Previously, we set Opt_WarnMissingSignatures and Opt_WarnMissingPatternSynonymSignatures for each module to produce hidden diagnostics and generate code lenses. By contrast, types of global bindings are derived from results of typecheck, instead of parsing diagnostic messages.

There are four working modes introduced in generic plugin config:

  • Enabled Always -- always displays type lenses of global bindings, no matter what GHC flags are set by users
  • Exported -- similar to Enabled, but only shows for exported global bindings
  • Diagnostics -- follows error messages produced by GHC, users can control the display of code lenses by setting GHC flags in this mode
    * Disabled -- fully disabled

For local bindings, corrsponding type lenses show only when Opt_WarnMissingLocalSignatures is set and works in Always mode.

@jneira
Copy link
Member

jneira commented Mar 4, 2021

Wow, impressive work, many thanks

There would be a generic config option to enable or disable code lenses for the plugin, if ghcide plugins honour the generic configuration (and they should be imo, see #1321)

Add such a generic configuration maybe is out of the scope of this pr but maybe we should design the options taking in account the plugin will have enable/disable at some point.
You alway will be able to disable it setting diagnostics and disable all ghc warnings about missing type definitions in the meanwhile, no?

So the options could be

  • Always-- always displays type lenses of global bindings, no matter what GHC flags are set by users
  • Exported -- similar to Enabled, but only shows for exported global bindings
  • Diagnostics -- follows error messages produced by GHC, users can control the display of code lenses by setting GHC flags in this mode

@jneira
Copy link
Member

jneira commented Mar 4, 2021

You alway will be able to disable it setting diagnostics and disable all ghc warnings about missing type definitions in the meanwhile, no?

What about some test negating the ghc warnings, to check no type lens is emitted?

@berberman
Copy link
Collaborator Author

So the options could be

  • Always-- always displays type lenses of global bindings, no matter what GHC flags are set by users
  • Exported -- similar to Enabled, but only shows for exported global bindings
  • Diagnostics -- follows error messages produced by GHC, users can control the display of code lenses by setting GHC flags in this mode

Yeah, that makes sense.

What about some test negating the ghc warnings, to check no type lens is emitted?

Agree, we need update tests to run against each mode.

@isovector
Copy link
Collaborator

There appears to be a space in the config string in the video. Is that intentional? Necessary?

@berberman
Copy link
Collaborator Author

@isovector Ah, good catch. It's not intentional, but works coincidentally because of the Read instance.

Copy link
Member

@jneira jneira left a comment

Choose a reason for hiding this comment

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

great work, tests looks great too

@berberman berberman added the merge me Label to trigger pull request merge label Mar 5, 2021
@mergify mergify bot merged commit b805746 into haskell:master Mar 5, 2021
@berberman berberman deleted the typelens-config branch March 5, 2021 06:37
@jneira
Copy link
Member

jneira commented Mar 5, 2021

3 issues closed in a row, amazing 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Label to trigger pull request merge
Projects
None yet
3 participants