emacs-lsp / lsp-metals

lsp-mode :heart: metals
https://emacs-lsp.github.io/lsp-metals
GNU General Public License v3.0
58 stars 33 forks source link

QuickPick Provider feature #7

Closed kpbochenek closed 2 years ago

kpbochenek commented 4 years ago

Specs for LSP for initialization message: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#initialize

When sending ClientCapabilities client can add experimental section that is custom for different client/server settings.

Metals supports parameter quickPickProvider that is boolean and can be set to true/false.

If this setting is set to true metals will assume this request can be handled by client:

  /**
   * Opens an menu to ask the user to pick one of the suggested options.
   *
   * @return the user provided pick.
   */
  @JsonRequest("metals/quickPick")
  def metalsQuickPick(
      params: MetalsQuickPickParams
  ): MetalsQuickPickResult

Method parameter(serialized to json):

case class MetalsQuickPickParams(
    items: java.util.List[MetalsQuickPickItem],
    @Nullable placeHolder: String = null
)
case class MetalsQuickPickItem(
    id: String,
    // A human readable string which is rendered prominent.
    label: String
)

And expected response:

case class MetalsQuickPickResult(
    // value=null when cancelled=true
    @Nullable itemId: String = null,
    @Nullable cancelled: java.lang.Boolean = null
)

I will try to add later a link to scala repository with description how it could be checked it works.

kurnevsky commented 2 years ago

Done in https://github.com/emacs-lsp/lsp-metals/pull/67