summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Simon Van Casteren <simonvancasteren@localhost.localdomain>2019-12-13 08:56:39 +0100
committerGravatar Simon Van Casteren <simonvancasteren@localhost.localdomain>2019-12-13 11:46:57 +0100
commit171ba38b23b6acfdb28a0b591d26d3e4bb87458b (patch)
tree2028f0d6ac4dd4bed1a2fdc716126e5069a415ca
parenta16c342d75f96a530da30e85465328306f5412ef (diff)
Added textDocument_didClose
-rw-r--r--src/lsp.sml17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/lsp.sml b/src/lsp.sml
index 50eea923..2c9aab56 100644
--- a/src/lsp.sml
+++ b/src/lsp.sml
@@ -226,6 +226,10 @@ structure LspSpec (* :> LSPSPEC *) = struct
{ textDocument = parseTextDocumentIdentifier (FromJson.get "textDocument" params)
(* , text = ... *)
}
+ type didCloseParams = { textDocument: textDocumentIdentifier }
+ fun parseDidCloseParams (params: Json.json): didCloseParams =
+ { textDocument = parseTextDocumentIdentifier (FromJson.get "textDocument" params)
+ }
type initializeParams =
{ rootUri: documentUri option }
fun parseInitializeParams (j: Json.json) =
@@ -457,6 +461,7 @@ structure LspSpec (* :> LSPSPEC *) = struct
, textDocument_didOpen: toclient -> didOpenParams -> unit
, textDocument_didChange: toclient -> didChangeParams -> unit
, textDocument_didSave: toclient -> didSaveParams -> unit
+ , textDocument_didClose: toclient -> didCloseParams -> unit
}
fun handleNotification
(notification: {method: string, params: Json.json})
@@ -467,6 +472,7 @@ structure LspSpec (* :> LSPSPEC *) = struct
| "textDocument/didOpen" => (#textDocument_didOpen handlers) toclient (parseDidOpenParams (#params notification))
| "textDocument/didChange" => (#textDocument_didChange handlers) toclient (parseDidChangeParams (#params notification))
| "textDocument/didSave" => (#textDocument_didSave handlers) toclient (parseDidSaveParams (#params notification))
+ | "textDocument/didClose" => (#textDocument_didClose handlers) toclient (parseDidCloseParams (#params notification))
| m => debug ("Notification method not supported: " ^ m)
end
@@ -982,6 +988,16 @@ fun handleDocumentDidChange (state: state) (toclient: LspSpec.toclient) (p: LspS
end
end
+fun handleDocumentDidClose (state: state) (toclient: LspSpec.toclient) (p: LspSpec.didCloseParams): unit =
+ let
+ val fileName = #path (#uri (#textDocument p))
+ val s = SM.find (#fileStates state, fileName)
+ in
+ stateRef := SOME { urpPath = #urpPath state
+ , fileStates = (#1 (SM.remove (#fileStates state, fileName))) handle ex => #fileStates state
+ }
+ end
+
fun serverLoop () =
let
val requestMessage =
@@ -1024,6 +1040,7 @@ fun serverLoop () =
, textDocument_didOpen = fn toclient => fn p => handleDocumentSavedOrOpened state toclient (#uri (#textDocument p)) (SOME (#text (#textDocument p)))
, textDocument_didChange = handleDocumentDidChange state
, textDocument_didSave = fn toclient => fn p => handleDocumentSavedOrOpened state toclient (#uri (#textDocument p)) NONE
+ , textDocument_didClose = fn toclient => fn p => handleDocumentDidClose state toclient p
})
handle LspError e => handleLspErrorInNotification e
| ex => handleLspErrorInNotification (InternalError (General.exnMessage ex)))