Hi again,
one of the lsp extensions I’m working on has document formatting capabilities, but it seems that Nova doesn’t respect the range in the response TextEdit struct and fully inserts the result to the existing document at 0,0 - essentially duplicating the text in the editor.
here is a log the rpc exchange in that case:
Lua Language Server[14:57:39.949000] Sending JSON-RPC request: number(129) textDocument/formatting
{
"method" : "textDocument\/formatting",
"id" : 129,
"jsonrpc" : "2.0",
"params" : {
"textDocument" : {
"uri" : "file:\/\/\/Users\/olifink\/Courses\/pickaxe\/others\/hello.lua"
},
"options" : {
"trimTrailingWhitespace" : false,
"tabSize" : 4,
"insertFinalNewline" : false,
"insertSpaces" : false
}
}
}
Lua Language Server[14:57:39.950000] Received JSON-RPC response: number(129) textDocument/formatting
{
"jsonrpc" : "2.0",
"result" : [
{
"newText" : "local function hello(name)\n\tprint(\"Hello \", name)\nend\n\nlocal function again(what)\n\tprint(\"Nobody here \", what)\nend\nfor i, v in ipairs(arg) do\n\tprint(i, v)\nend\n\nprint(\"pwd\", os.getenv(\"PWD\"))\nprint(table.concat(arg, ','))\nhello(\"Lua\")\n",
"range" : {
"end" : {
"line" : 14,
"character" : 0
},
"start" : {
"character" : 0,
"line" : 0
}
}
}
],
"id" : 129
}
Lua Language Server[14:57:39.950000] Sending JSON-RPC notification: textDocument/didChange
{
"jsonrpc" : "2.0",
"method" : "textDocument\/didChange",
"params" : {
"textDocument" : {
"uri" : "file:\/\/\/Users\/olifink\/Courses\/pickaxe\/others\/hello.lua",
"version" : 15
},
"contentChanges" : [
{
"text" : "local function hello(name)\n\tprint(\"Hello \", name)\nend\n\nlocal function again(what)\n\tprint(\"Nobody here \", what)\nend\nfor i, v in ipairs(arg) do\n\tprint(i, v)\nend\n\nprint(\"pwd\", os.getenv(\"PWD\"))\nprint(table.concat(arg, ','))\nhello(\"Lua\")\n",
"range" : {
"end" : {
"character" : 0,
"line" : 0
},
"start" : {
"line" : 0,
"character" : 0
}
}
}
]
}
}
can you perhaps look into that? is there any reason the ranges don’t match for these requests/responses?
O