lite-xl / lite-xl-lsp

LSP Plugin for Lite XL editor
MIT License
158 stars 21 forks source link

Symbol Rename #131

Open Mandarancio opened 2 months ago

Mandarancio commented 2 months ago

Implementation of symbol renaming using the results from the lsp server:

I did not implement an automatic file save of the changes as it force the developer to open, (review), and save the changes manually (it could be a configuration).

There is still work to do as the LSP after the refactoring seems to be out of sync with the updated files, help with testing and debugging is needed

jgmdev commented 2 months ago

I have implemented this some time ago with support for previewing and approving the changes graphically https://github.com/pragtical/lsp/pull/3

Mandarancio commented 2 months ago

@jgmdev nice, there are any plans to merge it into lite-xl-lsp?

jgmdev commented 2 months ago

Can be picked by any one for merging.

Mandarancio commented 2 months ago

I just realized that different LSP have different responses, for example clangd will reply with something like this

{
  "results": {
    "changes": {
      "$FILE_URI_0": [ ... ],
      "$FILE_URI_1": [ ... ]
    }
  }
}

While pyright will answer like:

{
  "results": {
    "documentChanges": [
      {
        "textDocument": { "uri": "$FILE_URI_0" },
        "edits": [ ... ]
      }, {
        "textDocument": { "uri": "$FILE_URI_1" },
        "edits": [ ... ]
      }
    ]
  }
}

There is a way to uniform the responses?

Mandarancio commented 2 months ago

I just realized that different LSP have different responses, for example clangd will reply with something like this

{
  "results": {
    "changes": {
      "$FILE_URI_0": [ ... ],
      "$FILE_URI_1": [ ... ]
    }
  }
}

While pyright will answer like:

{
  "results": {
    "documentChanges": [
      {
        "textDocument": { "uri": "$FILE_URI_0" },
        "edits": [ ... ]
      }, {
        "textDocument": { "uri": "$FILE_URI_1" },
        "edits": [ ... ]
      }
    ]
  }
}

There is a way to uniform the responses?

Implemented workaround that convert the two types of answer to a same structure