typescript-tools.nvim icon indicating copy to clipboard operation
typescript-tools.nvim copied to clipboard

Add support for `textDocument/linkedEditingRange`

Open KostkaBrukowa opened this issue 2 years ago • 4 comments

Typescript 5.1 has new feature called linked cursors. I don't know if nvim (or any plugin) supports such thing but maybe in the future it will so we could implement handling of this method in this plugin, but I think this is low priority

KostkaBrukowa avatar May 17 '23 09:05 KostkaBrukowa

It depends if tsserver return events with edits to do such as

{line: 1, offset: 1, newText: "d"},
{line: 1, offset: 2, newText: "i"},
{line: 1, offset: 3, newText: "v"},

It will be easy to do IMO, I pretty sure feature isn't LSP complainant so I don't think any plugin will support that separately, it is more like sorting imports

pmizio avatar May 17 '23 09:05 pmizio

I think it was made to be complainant with this https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_linkedEditingRange lsp specification (it even has same names)

Edit: I haven't found any plugin that implements this but tsserver returns something like this:

export interface LinkedEditingRangesBody {
    ranges: TextSpan[];
    wordPattern?: string;
}

so if we would have entered characters we would have information on how to change it in any other place

KostkaBrukowa avatar May 17 '23 09:05 KostkaBrukowa

Oh nice I don't know that request. I think it's doable but with custom handler or contribution to neovim core. Because nvim don't have multi cursor it need some gluecode involving probably some custom state and autocommand to generate edits in linked ranges

pmizio avatar May 17 '23 09:05 pmizio