aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Lingelbach <m.j.lbach@gmail.com>2021-03-31 16:16:50 -0700
committerGitHub <noreply@github.com>2021-03-31 16:16:50 -0700
commit9ff0152bd633be1a053bc55a416e7545f1282e69 (patch)
tree0600d1039e0822c436bd53cdb3fd5265835be7ac
parentmanual docgen (diff)
parentjdtls: Add workaround for textDocument version of 0 (diff)
downloadnvim-lspconfig-9ff0152bd633be1a053bc55a416e7545f1282e69.tar
nvim-lspconfig-9ff0152bd633be1a053bc55a416e7545f1282e69.tar.gz
nvim-lspconfig-9ff0152bd633be1a053bc55a416e7545f1282e69.tar.bz2
nvim-lspconfig-9ff0152bd633be1a053bc55a416e7545f1282e69.tar.lz
nvim-lspconfig-9ff0152bd633be1a053bc55a416e7545f1282e69.tar.xz
nvim-lspconfig-9ff0152bd633be1a053bc55a416e7545f1282e69.tar.zst
nvim-lspconfig-9ff0152bd633be1a053bc55a416e7545f1282e69.zip
Merge pull request #814 from dradtke/jdtls-document-version
jdtls: Add workaround for textDocument version of 0
-rw-r--r--lua/lspconfig/jdtls.lua28
1 files changed, 25 insertions, 3 deletions
diff --git a/lua/lspconfig/jdtls.lua b/lua/lspconfig/jdtls.lua
index 67b4de3d..4bb7e83c 100644
--- a/lua/lspconfig/jdtls.lua
+++ b/lua/lspconfig/jdtls.lua
@@ -56,6 +56,20 @@ local function on_language_status(_, _, result)
command('echohl None')
end
+-- If the text document version is 0, set it to nil instead so that Neovim
+-- won't refuse to update a buffer that it believes is newer than edits.
+-- See: https://github.com/eclipse/eclipse.jdt.ls/issues/1695
+local function fix_zero_version(workspace_edit)
+ if workspace_edit and workspace_edit.documentChanges then
+ for _, change in pairs(workspace_edit.documentChanges) do
+ local text_document = change.textDocument
+ if text_document and text_document.version and text_document.version == 0 then
+ text_document.version = nil
+ end
+ end
+ end
+ return workspace_edit
+end
configs[server_name] = {
default_config = {
@@ -91,16 +105,24 @@ configs[server_name] = {
-- if command is string, then 'ation' is Command in java format,
-- then we add 'edit' property to change to CodeAction in LSP and 'edit' will be executed first
if action.command == 'java.apply.workspaceEdit' then
- action.edit = action.edit or action.arguments[1]
+ action.edit = fix_zero_version(action.edit or action.arguments[1])
-- if command is table, then 'action' is CodeAction in java format
-- then we add 'edit' property to change to CodeAction in LSP and 'edit' will be executed first
elseif type(action.command) == 'table' and action.command.command == 'java.apply.workspaceEdit' then
- action.edit = action.edit or action.command.arguments[1]
+ action.edit = fix_zero_version(action.edit or action.command.arguments[1])
end
end
-
handlers['textDocument/codeAction'](a, b, actions)
end;
+
+ ['textDocument/rename'] = function(a, b, workspace_edit)
+ handlers['textDocument/rename'](a, b, fix_zero_version(workspace_edit))
+ end;
+
+ ['workspace/applyEdit'] = function(a, b, workspace_edit)
+ handlers['workspace/applyEdit'](a, b, fix_zero_version(workspace_edit))
+ end;
+
['language/status'] = vim.schedule_wrap(on_language_status)
};
};