diff options
author | Mathias Fußenegger <mfussenegger@users.noreply.github.com> | 2022-12-08 10:55:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-08 10:55:01 +0100 |
commit | 54305443b9cd5ac2c2220f12e01a653e8064c3a4 (patch) | |
tree | faaa47fcfbed98713337ef7861466a017cc5112e /runtime/lua/vim/lsp/protocol.lua | |
parent | a505c1acc37b0f9d4f7d93bfe899a59514bd0027 (diff) | |
download | rneovim-54305443b9cd5ac2c2220f12e01a653e8064c3a4.tar.gz rneovim-54305443b9cd5ac2c2220f12e01a653e8064c3a4.tar.bz2 rneovim-54305443b9cd5ac2c2220f12e01a653e8064c3a4.zip |
feat(lsp): support willSave & willSaveWaitUntil capability (#21315)
`willSaveWaitUntil` allows servers to respond with text edits before
saving a document. That is used by some language servers to format a
document or apply quick fixes like removing unused imports.
Diffstat (limited to 'runtime/lua/vim/lsp/protocol.lua')
-rw-r--r-- | runtime/lua/vim/lsp/protocol.lua | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/runtime/lua/vim/lsp/protocol.lua b/runtime/lua/vim/lsp/protocol.lua index 8dc93b3b67..925115d056 100644 --- a/runtime/lua/vim/lsp/protocol.lua +++ b/runtime/lua/vim/lsp/protocol.lua @@ -151,6 +151,7 @@ local constants = { }, -- Represents reasons why a text document is saved. + ---@enum lsp.TextDocumentSaveReason TextDocumentSaveReason = { -- Manually triggered, e.g. by the user pressing save, by starting debugging, -- or by an API call. @@ -631,11 +632,8 @@ function protocol.make_client_capabilities() synchronization = { dynamicRegistration = false, - -- TODO(ashkan) Send textDocument/willSave before saving (BufWritePre) - willSave = false, - - -- TODO(ashkan) Implement textDocument/willSaveWaitUntil - willSaveWaitUntil = false, + willSave = true, + willSaveWaitUntil = true, -- Send textDocument/didSave after saving (BufWritePost) didSave = true, @@ -870,8 +868,8 @@ function protocol._resolve_capabilities_compat(server_capabilities) text_document_sync_properties = { text_document_open_close = if_nil(textDocumentSync.openClose, false), text_document_did_change = if_nil(textDocumentSync.change, TextDocumentSyncKind.None), - text_document_will_save = if_nil(textDocumentSync.willSave, false), - text_document_will_save_wait_until = if_nil(textDocumentSync.willSaveWaitUntil, false), + text_document_will_save = if_nil(textDocumentSync.willSave, true), + text_document_will_save_wait_until = if_nil(textDocumentSync.willSaveWaitUntil, true), text_document_save = if_nil(textDocumentSync.save, false), text_document_save_include_text = if_nil( type(textDocumentSync.save) == 'table' and textDocumentSync.save.includeText, |