-
Notifications
You must be signed in to change notification settings - Fork 406
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: server -> client requests (#3271)
This PR adds support for requests from the server to the client in the language server. It is based on #3014 and was developed during an experiment for #3247 that unfortunately did not go anywhere.
- Loading branch information
Showing
3 changed files
with
132 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/- | ||
Copyright (c) 2024 Lean FRO, LLC. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Marc Huisinga | ||
-/ | ||
prelude | ||
import Lean.Data.Json | ||
|
||
open Lean | ||
|
||
inductive MessageType where | ||
| error | ||
| warning | ||
| info | ||
| log | ||
|
||
instance : FromJson MessageType where | ||
fromJson? | ||
| (1 : Nat) => .ok .error | ||
| (2 : Nat) => .ok .warning | ||
| (3 : Nat) => .ok .info | ||
| (4 : Nat) => .ok .log | ||
| _ => .error "Unknown MessageType ID" | ||
|
||
instance : ToJson MessageType where | ||
toJson | ||
| .error => 1 | ||
| .warning => 2 | ||
| .info => 3 | ||
| .log => 4 | ||
|
||
structure ShowMessageParams where | ||
type : MessageType | ||
message : String | ||
deriving FromJson, ToJson | ||
|
||
structure MessageActionItem where | ||
title : String | ||
deriving FromJson, ToJson | ||
|
||
structure ShowMessageRequestParams where | ||
type : MessageType | ||
message : String | ||
actions? : Option (Array MessageActionItem) | ||
deriving FromJson, ToJson | ||
|
||
def ShowMessageResponse := Option MessageActionItem | ||
deriving FromJson, ToJson |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters