lua-language-server
lua-language-server copied to clipboard
textDocument/formatting should return a edits instead of totall text for client
Describe the bug https://github.com/sumneko/lua-language-server/blob/f760dc359b389c20a0d48bef463d14800e67894c/script/core/formatting.lua#L5-L25
As a server, we should diff the document and the return result and generate the edits for the client. If the server returns totally text result, the context resource in the client may be invalid, like semantic token.
@CppCXY
Diff into a lot of edits may have a large consumption, and there is no consideration in this regard for the time being. maybe this will be considered in the future.
I used https://github.com/Koihik/LuaFormatter provider format for the text and https://github.com/mattn/efm-langserver provider diff before I migrate to the format in this server.
@CppCXY I am not sure whether the diff logic done by the backend provider is good or not, but IMO, it is the responsibility of a language server. A server may use other FOSS format providers only provider full text format and adapt them into the LSP. However, https://github.com/CppCXY/EmmyLuaCodeStyle have provided the rangeformatting, the diff logic looks not a big feature.
@sumneko How do you think about doing the diff logic on server side?
I agree to make diffs by the server. But I'm busy with other work, so the priority is relatively low.
Maybe I can help this weekend or next weekend. Is PR welcome?
Of course. Since you have made and passed a lot of PR, maybe my answer not welcome will be more dramatic🙃.