aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorDamien Radtke <git@damienradtke.com>2021-03-30 19:32:55 +0000
committerDamien Radtke <git@damienradtke.com>2021-03-31 21:43:10 +0000
commit486f72a25ea2ee7f81648fdfd8999a155049e466 (patch)
tree0600d1039e0822c436bd53cdb3fd5265835be7ac /lua
parentmanual docgen (diff)
downloadnvim-lspconfig-486f72a25ea2ee7f81648fdfd8999a155049e466.tar
nvim-lspconfig-486f72a25ea2ee7f81648fdfd8999a155049e466.tar.gz
nvim-lspconfig-486f72a25ea2ee7f81648fdfd8999a155049e466.tar.bz2
nvim-lspconfig-486f72a25ea2ee7f81648fdfd8999a155049e466.tar.lz
nvim-lspconfig-486f72a25ea2ee7f81648fdfd8999a155049e466.tar.xz
nvim-lspconfig-486f72a25ea2ee7f81648fdfd8999a155049e466.tar.zst
nvim-lspconfig-486f72a25ea2ee7f81648fdfd8999a155049e466.zip
jdtls: Add workaround for textDocument version of 0
See https://github.com/eclipse/eclipse.jdt.ls/issues/1695
Diffstat (limited to 'lua')
-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)
};
};