haskell / haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Apache License 2.0
2.72k stars 368 forks source link

More plugin introspection information #3660

Open michaelpj opened 1 year ago

michaelpj commented 1 year ago

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 commented 1 year ago

This would help the user in e.g. https://github.com/haskell/haskell-language-server/issues/3618 to know what's going on.

michaelpj commented 1 year ago

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.

michaelpj commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

Brainstorming:

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 commented 1 year ago

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