Skip to content

discussion : plugin architecture #946

Closed
@alanz

Description

@alanz

Now that haskell-language-server exists, and we have given some thought and effort to using ghcide as the building block for maintaining project artifacts, it might be useful to have a discussion about the role of plugins.

The underlying haskell-lsp library exposes a Handlers data structure which represents every message the language server can receive, and can provide a specific handler for it. Unused handlers can be set to Nothing, and so ignored.

ghcide interposes a PartialHandlers structure, which can be populated with individual message handlers without reference to the underlying haskell-lsp Handlers. These can be combined monoidally, with the one drawback that if more than one partial handler attempts to process a given message in the haskell-lsp Handlers structure, the last one defined in the monoidal chain will "win" and mask the others.

In some cases this is fine, but when we want to freely combine plugins from different sources, each providing some useful information to the end user, this model breaks down.

A case in point is hover information. The haskell-language-server approach mirrors that in haskell-ide-engine, where there can be multiple hover providers, andthere is a top level handler which runs the provider from each plugin to get get potential hover information, and then combines the results into a single hover result message.

Similarly for exposing commands for the workspace/executeCommand handler, which routes the incoming command to the appropriate plugin handler for processing.

Right now, with #58 and haskell/ghcide#490 we are able to work around this architecture in haskell-language-server.

But perhaps we should consider changing the way it is represented in ghcide, to simplify it there. I do not have any firm preconceptions about what should go there, but to me the simplest case would be to be able to provide a haskell-lsp Handlers structure populated appropriately, together with whatever rules need to be made active.

This is a discussion issue, please share your thoughts.

cc @cocreature @ndmitchell @mpickering @pepeiborra @jneira @fendor and anyone else with an opinion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions