mirror of
https://github.com/c-cube/linol.git
synced 2025-12-06 03:05:31 -05:00
Add filter_text_document
This commit is contained in:
parent
43839963e1
commit
d7dd8ecec0
1 changed files with 20 additions and 0 deletions
|
|
@ -627,6 +627,10 @@ module Make (IO : IO) = struct
|
||||||
IO.return ()
|
IO.return ()
|
||||||
(** Override to handle unprocessed notifications *)
|
(** Override to handle unprocessed notifications *)
|
||||||
|
|
||||||
|
method filter_text_document (_doc_uri: Lsp.Types.DocumentUri.t) : bool = true
|
||||||
|
(** Filter the document URI to check if we want to process it or not.
|
||||||
|
By default we accept all documents. *)
|
||||||
|
|
||||||
method on_notification ~notify_back ~server_request
|
method on_notification ~notify_back ~server_request
|
||||||
(n : Lsp.Client_notification.t) : unit IO.t =
|
(n : Lsp.Client_notification.t) : unit IO.t =
|
||||||
let@ _sp =
|
let@ _sp =
|
||||||
|
|
@ -651,6 +655,9 @@ module Make (IO : IO) = struct
|
||||||
match n with
|
match n with
|
||||||
| Lsp.Client_notification.TextDocumentDidOpen
|
| Lsp.Client_notification.TextDocumentDidOpen
|
||||||
{ DidOpenTextDocumentParams.textDocument = doc } ->
|
{ DidOpenTextDocumentParams.textDocument = doc } ->
|
||||||
|
if not (self#filter_text_document doc.uri) then
|
||||||
|
IO.return ()
|
||||||
|
else (
|
||||||
Log.debug (fun k ->
|
Log.debug (fun k ->
|
||||||
k "notif: did open '%s'" (DocumentUri.to_path doc.uri));
|
k "notif: did open '%s'" (DocumentUri.to_path doc.uri));
|
||||||
let notify_back =
|
let notify_back =
|
||||||
|
|
@ -672,7 +679,11 @@ module Make (IO : IO) = struct
|
||||||
self#on_notif_doc_did_open
|
self#on_notif_doc_did_open
|
||||||
~notify_back:(notify_back : notify_back)
|
~notify_back:(notify_back : notify_back)
|
||||||
doc ~content:st.content)
|
doc ~content:st.content)
|
||||||
|
)
|
||||||
| Lsp.Client_notification.TextDocumentDidClose { textDocument = doc } ->
|
| Lsp.Client_notification.TextDocumentDidClose { textDocument = doc } ->
|
||||||
|
if not (self#filter_text_document doc.uri) then
|
||||||
|
IO.return ()
|
||||||
|
else (
|
||||||
Log.debug (fun k ->
|
Log.debug (fun k ->
|
||||||
k "notif: did close '%s'" (DocumentUri.to_path doc.uri));
|
k "notif: did close '%s'" (DocumentUri.to_path doc.uri));
|
||||||
let notify_back =
|
let notify_back =
|
||||||
|
|
@ -685,8 +696,12 @@ module Make (IO : IO) = struct
|
||||||
self#on_notif_doc_did_close
|
self#on_notif_doc_did_close
|
||||||
~notify_back:(notify_back : notify_back)
|
~notify_back:(notify_back : notify_back)
|
||||||
doc)
|
doc)
|
||||||
|
)
|
||||||
| Lsp.Client_notification.TextDocumentDidChange
|
| Lsp.Client_notification.TextDocumentDidChange
|
||||||
{ textDocument = doc; contentChanges = c } ->
|
{ textDocument = doc; contentChanges = c } ->
|
||||||
|
if not (self#filter_text_document doc.uri) then
|
||||||
|
IO.return ()
|
||||||
|
else (
|
||||||
Log.debug (fun k ->
|
Log.debug (fun k ->
|
||||||
k "notif: did change '%s'" (DocumentUri.to_path doc.uri));
|
k "notif: did change '%s'" (DocumentUri.to_path doc.uri));
|
||||||
let notify_back =
|
let notify_back =
|
||||||
|
|
@ -739,7 +754,11 @@ module Make (IO : IO) = struct
|
||||||
doc c
|
doc c
|
||||||
~old_content:(Lsp.Text_document.text old_doc)
|
~old_content:(Lsp.Text_document.text old_doc)
|
||||||
~new_content:new_st.content)
|
~new_content:new_st.content)
|
||||||
|
)
|
||||||
| Lsp.Client_notification.DidSaveTextDocument params ->
|
| Lsp.Client_notification.DidSaveTextDocument params ->
|
||||||
|
if not (self#filter_text_document params.textDocument.uri) then
|
||||||
|
IO.return ()
|
||||||
|
else (
|
||||||
let notify_back =
|
let notify_back =
|
||||||
new notify_back
|
new notify_back
|
||||||
~workDoneToken:None ~partialResultToken:None
|
~workDoneToken:None ~partialResultToken:None
|
||||||
|
|
@ -750,6 +769,7 @@ module Make (IO : IO) = struct
|
||||||
self#on_notif_doc_did_save
|
self#on_notif_doc_did_save
|
||||||
~notify_back:(notify_back : notify_back)
|
~notify_back:(notify_back : notify_back)
|
||||||
params)
|
params)
|
||||||
|
)
|
||||||
| Lsp.Client_notification.Exit ->
|
| Lsp.Client_notification.Exit ->
|
||||||
status <- `ReceivedExit;
|
status <- `ReceivedExit;
|
||||||
IO.return ()
|
IO.return ()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue