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

More plugin introspection information #3660

Open
michaelpj opened this issue Jun 14, 2023 · 6 comments
Open

More plugin introspection information #3660

michaelpj opened this issue Jun 14, 2023 · 6 comments
Labels
level: easy The issue is suited for beginners type: enhancement New feature or request

Comments

@michaelpj
Copy link
Collaborator

At the moment we know a little bit about plugins, but mostly their names. It would be nice if plugins could provide us with some extra information: a description, perhaps some optional version information about what key libraries it was built against (e.g. ormolu).

We could then at least log this information when we startup.

@michaelpj
Copy link
Collaborator Author

This would help the user in e.g. #3618 to know what's going on.

@michaelpj
Copy link
Collaborator Author

It would also be nice to know whether a plugin is enabled or not. We could imagine having something like:

#if stylish-haskell
   StylishHaskell.plugin
#else
   disabledPlugin "stylish-haskell" "Say something about why here?"
#endif

Then --list-plugins could also show that plugins are disabled.

@fendor fendor added level: easy The issue is suited for beginners and removed status: needs triage labels Jul 12, 2023
@michaelpj
Copy link
Collaborator Author

michaelpj commented Jul 12, 2023

I think that this could let us push much more conditional logic into the plugin packages, which might be nice.

For example, we could have something like this in hls-stylish-haskell-plugin.cabal:

flag hls-stylish-haskell-enabled

library
  ...
  if flag(hls-stylish-haskell-enabled)
     build-depends: stylish-haskell
     cpp-options: -Dhls_stylishHaskell
     exposed-modules: StylishHaskell4Real

and then in StylishHaskell.hs:

#if hls_stylishHaskell
import StylishHaskell4Real as Real
#endif 

descriptor :: PluginDescriptor
descriptor = PluginDescriptor {
  description = "Plugin that provides formatting with stylish-haskell"
#if hls_stylishHaskell
  , pluginHandlers = Real.pluginHandlers
  , status = Enabled
#else
  , pluginHandlers = mempty
  , status = Disabled "Plugin is disabled"
#endif
}

Then in the main HLS executable we can unconditionally depend on the stylish-haskell plugin, and we'll either get the real plugin or a placeholder "disabled" plugin, depending.

@July541
Copy link
Collaborator

July541 commented Jul 19, 2023

Thinking a bit, what information should have for a specific plugin?

Besides ormolu and fourmolu, every formatter is bundled with only one ghc version...

And other plugins seems don't have any words to say...

@michaelpj
Copy link
Collaborator Author

Brainstorming:

  • Human-readable description (could have a lot more detail)
  • Build information (versions of key libraries using VERSION_pkgname)
  • List of handlers that it provides (we could even annotate handlers with more information about what they're for)
  • CLI options it provides (do we even use this at the moment?)

Some of this we already know, but might need more annotation in order to let us show it to the user in a readable way.

@July541
Copy link
Collaborator

July541 commented Jul 22, 2023

Before making a decision here, should we add a log while formatters are activated to describe its version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
level: easy The issue is suited for beginners type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants