You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following on from #6506, I can see that the language server itself works: I get diagnostics, for example. However, formatting doesn't seem to work. From the log file (attached) I can see that the LS is being sent a formatting request and responding with something that seems valid. It also works as expected in Neovim.
Reproduction Steps
I tried this:
Configure Helix to use standardrb as an LSP
Edit a ruby file
:format or autoformat
I expected this to happen:
File is modified
Instead, this happened:
File is not modified
Helix log
~/.cache/helix/helix.log
2023-04-12T18:30:06.796 helix_view::clipboard [DEBUG] Using pbcopy+pbpaste to interact with the system clipboard
2023-04-12T18:30:06.987 helix_vcs [ERROR] file is untracked
2023-04-12T18:30:06.987 helix_vcs [ERROR] failed to open diff base for /Users/ben/bin/test.rb
2023-04-12T18:30:06.989 helix_view::editor [DEBUG] editor status: Loaded 1 file.
2023-04-12T18:30:06.989 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"positionEncodings":["utf-8","utf-32","utf-16"]},"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"completion":{"completionItem":{"deprecatedSupport":true,"insertReplaceSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"snippetSupport":true,"tagSupport":{"valueSet":[1]}},"completionItemKind":{}},"hover":{"contentFormat":["markdown"]},"inlayHint":{"dynamicRegistration":false},"publishDiagnostics":{"versionSupport":true},"rename":{"dynamicRegistration":false,"honorsChangeAnnotations":false,"prepareSupport":true},"signatureHelp":{"signatureInformation":{"activeParameterSupport":true,"documentationFormat":["markdown"],"parameterInformation":{"labelOffsetSupport":true}}}},"window":{"workDoneProgress":true},"workspace":{"applyEdit":true,"configuration":true,"didChangeConfiguration":{"dynamicRegistration":false},"executeCommand":{"dynamicRegistration":false},"inlayHint":{"refreshSupport":false},"symbol":{"dynamicRegistration":false},"workspaceEdit":{"documentChanges":true,"failureHandling":"abort","normalizesLineEndings":false,"resourceOperations":["create","rename","delete"]},"workspaceFolders":true}},"clientInfo":{"name":"helix","version":"23.03 (3cf03723)"},"processId":34301,"rootPath":"/Users/ben/bin","rootUri":"file:///Users/ben/bin","workspaceFolders":[{"name":"bin","uri":"file:///Users/ben/bin"}]},"id":0}
2023-04-12T18:30:06.993 helix_tui::backend::crossterm [DEBUG] The keyboard enhancement protocol is not supported in this terminal (checked in 4.301167ms)
2023-04-12T18:30:06.994 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-04-12T18:30:07.198 helix_term::application [DEBUG] received editor event: IdleTimer
2023-04-12T18:30:08.033 helix_lsp::transport [INFO] <- {"id":0,"result":{"capabilities":{"textDocumentSync":{"openClose":true,"change":1},"documentFormattingProvider":true,"diagnosticProvider":true}},"jsonrpc":"2.0"}
2023-04-12T18:30:08.036 helix_lsp::transport [INFO] <- {"capabilities":{"diagnosticProvider":true,"documentFormattingProvider":true,"textDocumentSync":{"change":1,"openClose":true}}}
2023-04-12T18:30:08.036 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"initialized","params":{}}
2023-04-12T18:30:08.036 helix_term::application [DEBUG] received editor event: LanguageServerMessage((0, Notification(Notification { jsonrpc: None, method: "initialized", params: None })))
2023-04-12T18:30:08.036 helix_lsp::transport [ERROR] err <- "[server] Standard Ruby v1.26.0 LSP server initialized, pid 34302\n"
2023-04-12T18:30:08.036 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"ruby","text":"def foo\n [ \n 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]\nend\n","uri":"file:///Users/ben/bin/test.rb","version":0}}}
2023-04-12T18:30:08.036 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-04-12T18:30:08.094 helix_lsp::transport [INFO] <- {"method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/ben/bin/test.rb","diagnostics":[{"code":"Layout/SpaceInsideArrayLiteralBrackets","message":"Do not use space inside array brackets.","range":{"start":{"character":3,"line":1},"end":{"character":3,"line":1}},"severity":3,"source":"standard"},{"code":"Layout/TrailingWhitespace","message":"Trailing whitespace detected.","range":{"start":{"character":3,"line":1},"end":{"character":3,"line":1}},"severity":3,"source":"standard"},{"code":"Layout/MultilineArrayBraceLayout","message":"The closing array brace must be on the line after the last array element when the opening brace is on a separate line from the first array element.","range":{"start":{"character":125,"line":2},"end":{"character":125,"line":2}},"severity":3,"source":"standard"}]},"jsonrpc":"2.0"}
2023-04-12T18:30:08.094 helix_term::application [DEBUG] received editor event: LanguageServerMessage((0, Notification(Notification { jsonrpc: Some(V2), method: "textDocument/publishDiagnostics", params: Map({"diagnostics": Array [Object {"code": String("Layout/SpaceInsideArrayLiteralBrackets"), "message": String("Do not use space inside array brackets."), "range": Object {"end": Object {"character": Number(3), "line": Number(1)}, "start": Object {"character": Number(3), "line": Number(1)}}, "severity": Number(3), "source": String("standard")}, Object {"code": String("Layout/TrailingWhitespace"), "message": String("Trailing whitespace detected."), "range": Object {"end": Object {"character": Number(3), "line": Number(1)}, "start": Object {"character": Number(3), "line": Number(1)}}, "severity": Number(3), "source": String("standard")}, Object {"code": String("Layout/MultilineArrayBraceLayout"), "message": String("The closing array brace must be on the line after the last array element when the opening brace is on a separate line from the first array element."), "range": Object {"end": Object {"character": Number(125), "line": Number(2)}, "start": Object {"character": Number(125), "line": Number(2)}}, "severity": Number(3), "source": String("standard")}], "uri": String("file:///Users/ben/bin/test.rb")}) })))
2023-04-12T18:30:08.095 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-04-12T18:30:10.113 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-04-12T18:30:10.512 helix_term::application [DEBUG] received editor event: IdleTimer
2023-04-12T18:30:10.550 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-04-12T18:30:10.665 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-04-12T18:30:10.814 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-04-12T18:30:11.009 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-04-12T18:30:11.010 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/formatting","params":{"options":{"insertSpaces":true,"tabSize":2},"textDocument":{"uri":"file:///Users/ben/bin/test.rb"}},"id":1}
2023-04-12T18:30:11.042 helix_lsp::transport [INFO] <- {"id":1,"result":[{"newText":"def foo\n [\n 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0\n ]\nend\n","range":{"start":{"line":0,"character":0},"end":{"line":5,"character":0}}}],"jsonrpc":"2.0"}
2023-04-12T18:30:11.042 helix_lsp::transport [INFO] <- [{"newText":"def foo\n [\n 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0\n ]\nend\n","range":{"end":{"character":0,"line":5},"start":{"character":0,"line":0}}}]
2023-04-12T18:30:11.042 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-04-12T18:30:11.615 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-04-12T18:30:11.783 helix_term::commands::typed [DEBUG] quitting...
2023-04-12T18:30:11.784 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-04-12T18:30:11.896 helix_term::commands::typed [DEBUG] quitting...
2023-04-12T18:30:11.897 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-04-12T18:30:11.897 helix_term::job [DEBUG] waiting on jobs...
2023-04-12T18:30:11.897 helix_term::job [DEBUG] waiting on jobs...
2023-04-12T18:30:11.897 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"shutdown","id":2}
2023-04-12T18:30:11.897 helix_lsp::transport [ERROR] err <- "[server] Client asked to shutdown Standard LSP server.\n"
2023-04-12T18:30:11.898 helix_lsp::transport [INFO] <- {"id":2,"result":null,"jsonrpc":"2.0"}
2023-04-12T18:30:11.898 helix_lsp::transport [INFO] <- null
2023-04-12T18:30:11.898 helix_lsp::transport [ERROR] err <- "[server] Exiting...\n"
2023-04-12T18:30:11.898 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"exit"}
The formatting response gives an end range past the end of the document: line 5 column 0. That PR defaults out-of-bound positions to the end of the document.
Formatting this example works for me on the latest master of Helix and standard
Summary
I have configured standardrb as a language server for ruby:
Following on from #6506, I can see that the language server itself works: I get diagnostics, for example. However, formatting doesn't seem to work. From the log file (attached) I can see that the LS is being sent a formatting request and responding with something that seems valid. It also works as expected in Neovim.
Reproduction Steps
I tried this:
:format
or autoformatI expected this to happen:
Instead, this happened:
Helix log
~/.cache/helix/helix.log
Platform
macOS
Terminal Emulator
wezterm 20230408-112425-69ae8472
Helix Version
helix 23.03 (3cf0372)
The text was updated successfully, but these errors were encountered: