]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
fix: send buffer text on textDocument/didSave
authorMitchell Hanberg <mitch@mitchellhanberg.com>
Thu, 5 Oct 2023 21:29:09 +0000 (17:29 -0400)
committerMitchell Hanberg <mitch@mitchellhanberg.com>
Thu, 5 Oct 2023 21:29:09 +0000 (17:29 -0400)
This sends the full buffer text on the textDocument/didSave notification
if the server's sync options specify it.

autoload/lsp/lspserver.vim

index 3bfe4439ce848ebf8ef8e3b4992576edf0c6c411..236aabd5da1b3cdca2be0def96ab36ca850e4d0e 100644 (file)
@@ -907,8 +907,11 @@ def DidSaveFile(lspserver: dict<any>, bnr: number): void
   # Notification: 'textDocument/didSave'
   # Params: DidSaveTextDocumentParams
   var params = {textDocument: {uri: util.LspBufnrToUri(bnr)}}
-  # FIXME: Need to set "params.text" when
-  # 'lspserver.caps.textDocumentSync.save.includeText' is set to true.
+
+  if lspserver.caps.textDocumentSync.save.includeText
+    params.textDocument.text = bnr->getbufline(1, '$')->join("\n") .. "\n"
+  endif
+
   lspserver.sendNotification('textDocument/didSave', params)
 enddef