diff --git a/lua/lspconfig/server_configurations/tsserver.lua b/lua/lspconfig/server_configurations/tsserver.lua index 2a4cd1ab03..34fcc9eae8 100644 --- a/lua/lspconfig/server_configurations/tsserver.lua +++ b/lua/lspconfig/server_configurations/tsserver.lua @@ -17,6 +17,33 @@ return { or util.root_pattern('package.json', 'jsconfig.json', '.git')(fname) end, single_file_support = true, + handlers = { + ['_typescript.rename'] = function(_, result, ctx) + if not result then + return {} + end + + local client = vim.lsp.get_client_by_id(ctx.client_id) + + if client then + vim.lsp.util.jump_to_location({ + uri = result.textDocument.uri, + range = { + start = result.position, + ['end'] = result.position, + }, + }, client.offset_encoding, true) + + vim.lsp.buf.rename(nil, { + filter = function(c) + return c == client + end, + }) + end + + return {} + end, + }, }, docs = { description = [[