Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tsserver): add _typescript.rename handler #2808

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions lua/lspconfig/server_configurations/tsserver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [[
Expand Down
Loading