Documentation

Lean.Meta.Hint

A widget for a clickable link (or icon) that inserts text into the document at a given position.

The props to this widget are of the following form:

{
  "range": {
    "start": {"line": 100, "character": 0},
    "end":   {"line": 100, "character": 5}
  },
  "suggestion": "hi",
  "acceptSuggestionProps": {
    "kind": "text",
    "hoverText": "Displayed on hover",
    "linkText": "Displayed as the text of the link"
  }
}

... or the following form, where codiconName is one of the icons at https://microsoft.github.io/vscode-codicons/dist/codicon.html and gaps determines whether there are clickable spaces surrounding the icon:

{
  "range": {
    "start": {"line": 100, "character": 0},
    "end":   {"line": 100, "character": 5}
  },
  "suggestion": "hi",
  "acceptSuggestionProps": {
    "kind": "icon",
    "hoverText": "Displayed on hover",
    "codiconName": "search",
    "gaps": true
  }
}

Note: we cannot add the builtin_widget_module attribute here because that would require importing Lean.Widget.UserWidget, which in turn imports much of Lean.Elab -- the module where we want to be able to use this widget. Instead, we register the attribute post-hoc when we declare the regular "Try This" widget in Lean.Meta.Tactic.TryThis.

Equations
    Instances For

      A widget for rendering code action suggestions in error messages. Generally, this widget should not be used directly; instead, use MessageData.hint. Note that this widget is intended only for use within message data; it may not display line breaks properly if rendered as a panel widget.

      The props to this widget are of the following form:

      {
        "diff": [
          {"type": "unchanged", "text": "h"},
          {"type": "deletion", "text": "ello"},
          {"type": "insertion", "text": "i"}
        ],
        "suggestion": "hi",
        "range": {
          "start": {"line": 100, "character": 0},
          "end":   {"line": 100, "character": 5}
        }
      }
      

      Note: we cannot add the builtin_widget_module attribute here because that would require importing Lean.Widget.UserWidget, which in turn imports much of Lean.Elab -- the module where we want to be able to use this widget. Instead, we register the attribute post-hoc when we declare the regular "Try This" widget in Lean.Meta.Tactic.TryThis.

      Equations
        Instances For

          The granularity at which to display an inline diff for a suggested edit.

          • auto : DiffGranularity

            Automatically select diff granularity based on edit distance.

          • char : DiffGranularity

            Character-level diff.

          • word : DiffGranularity

            Diff using whitespace-separated tokens.

          • all : DiffGranularity

            "Monolithic" diff: shows a deletion of the entire existing source, followed by an insertion of the entire suggestion.

          • none : DiffGranularity

            No diff: Shows no deletion of the existing source, only an insertion of the suggestion.

          Instances For

            A code action suggestion associated with a hint in a message.

            Refer to TryThis.Suggestion. This extends that structure with several fields specific to inline hints.

            Instances For

              Produces a diff that splits either on characters, tokens, or not at all, depending on the selected diffMode.

              Guarantees that all actions in the output will be maximally grouped; that is, instead of returning #[(.insert, "a"), (.insert, "b")], it will return #[(.insert, "ab")].

              Equations
                Instances For
                  def Lean.Meta.Hint.mkSuggestionsMessage (suggestions : Array Suggestion) (ref : Syntax) (codeActionPrefix? : Option String) (forceList : Bool) :

                  Creates message data corresponding to a HintSuggestions collection and adds the corresponding info leaf.

                  Equations
                    Instances For
                      def Lean.MessageData.hint (hint : MessageData) (suggestions : Array Meta.Hint.Suggestion) (ref? : Option Syntax := none) (codeActionPrefix? : Option String := none) (forceList : Bool := false) :

                      Creates a hint message with associated code action suggestions.

                      To provide a hint without an associated code action, use MessageData.hint'.

                      The arguments are as follows:

                      • hint: the main message of the hint, which precedes its code action suggestions.
                      • suggestions: the suggestions to display.
                      • ref?: if specified, the syntax location for the code action suggestions; otherwise, default to the syntax reference in the monadic state. Will be overridden by the span? field on any suggestions that specify it.
                      • codeActionPrefix?: if specified, text to display in place of "Try this: " in the code action label
                      • forceList: if true, suggestions will be displayed as a bulleted list even if there is only one.
                      Equations
                        Instances For