Skip to content

Code actions not working at all in Helix and unreliably in Neovim #645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
David-Else opened this issue Dec 30, 2022 · 7 comments · Fixed by #700
Closed

Code actions not working at all in Helix and unreliably in Neovim #645

David-Else opened this issue Dec 30, 2022 · 7 comments · Fixed by #700
Labels
question Further information is requested

Comments

@David-Else
Copy link
Contributor

helix 22.12 (96ff64a8)
Neovim 0.8 using latest [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig)
[email protected]
ShellCheck version: 0.8.0

Code actions are sometimes (seems random) working in Neovim, but not in Helix.

Neovim seems to have no special default settings making it different from default Helix:

https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#bashls
https://github.com/helix-editor/helix/blob/63dcaae1b9083396fb3faaef9eaa2421f7e48fb9/languages.toml#L537

The following code (sometimes) generates code actions in Neovim 0.8 using the built-in LSP and the ShellCheck binary in the system path:

#!/bin/bash

echo $1               # Unquoted variables
[ $n && $m ]          # && in [ .. ]
[ x ] & [ y ] | [ z ] # Accidental backgrounding and piping

But in Helix is just says no code actions available when going to the diagnostic error.

The code action lightbulb https://github.com/kosayoda/nvim-lightbulb only comes on sometimes in Neovim indicating there is something buggy going on in bash-language server. Also I see another issue with code actions that is probably related here: #490 (comment)

Thanks for this great language server!

@Shane-XB-Qian
Copy link
Contributor

you may miss-readed the original description of #490 about the case in neovim.

@David-Else
Copy link
Contributor Author

@Shane-XB-Qian I did see #490 was talking about using null-ls in Neovim, but that issue was started before code action support was added to bash-language-server. Now it should work out of the box with Helix and Neovim.

@Shane-XB-Qian
Copy link
Contributor

The following code (sometimes) generates code actions in Neovim 0.8 using the built-in LSP

i meant your those statement perhaps was not from this bashls, but null-ls.
// and not sure if it was the real code action, i do not use these, and never see it actually..

@skovhus skovhus added the priority ⭐️ Triaged and deemed a priority label Jan 7, 2023
@skovhus
Copy link
Collaborator

skovhus commented Jan 7, 2023

I believe this is an issue with Helix. Here I'm demoing a very stable code actions feature using the script in #490 (comment) to show case code actions and some diagnostics that has code actions, but where the severity is low so it doesn't show up in the "problems" view (i.e. SC2006).

code-actions

As for the example you provide, here is the output from vscode:

Screenshot 2023-01-07 at 11 26 16

Let me know if you find more hunches that this is caused by bash-language-server.

@skovhus skovhus added question Further information is requested and removed priority ⭐️ Triaged and deemed a priority labels Jan 7, 2023
@David-Else
Copy link
Contributor Author

It is definitely caused by bash language server as:

I don't think Helix is at fault, it works with every other language server I have used out of the box. In Helix the logs say 2023-01-25T19:35:18.707 helix_term::application [ERROR] Language Server: Method not found client/registerCapability. Could that be a clue?

Neovim after pressing the button for code actions:

Screenshot from 2023-01-25 19-42-33

Helix after pressing the button for code actions:
Screenshot from 2023-01-25 19-43-30

Here are the full Helix logs in case it helps:

2023-01-25T19:47:32.770 helix_loader [DEBUG] Located configuration folders: []
2023-01-25T19:47:32.782 helix_view::clipboard [INFO] Using xclip to interact with the system and selection (primary) clipboard
2023-01-25T19:47:32.795 helix_view::editor [DEBUG] editor status: Loaded 1 file.
2023-01-25T19:47:32.795 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"completion":{"completionItem":{"insertReplaceSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"snippetSupport":false},"completionItemKind":{}},"hover":{"contentFormat":["markdown"]},"publishDiagnostics":{},"rename":{"dynamicRegistration":false,"honorsChangeAnnotations":false,"prepareSupport":false},"signatureHelp":{"signatureInformation":{"activeParameterSupport":true,"documentationFormat":["markdown"],"parameterInformation":{"labelOffsetSupport":true}}}},"window":{"workDoneProgress":true},"workspace":{"applyEdit":true,"configuration":true,"didChangeConfiguration":{"dynamicRegistration":false},"executeCommand":{"dynamicRegistration":false},"symbol":{"dynamicRegistration":false},"workspaceFolders":true}},"clientInfo":{"name":"helix","version":"22.12 (71a544b5)"},"processId":2676914,"rootPath":"/home/david/Downloads","rootUri":"file:///home/david/Downloads","workspaceFolders":[{"name":"Downloads","uri":"file:///home/david/Downloads"}]},"id":0}
2023-01-25T19:47:32.795 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-01-25T19:47:33.182 helix_term::application [DEBUG] received editor event: IdleTimer
2023-01-25T19:47:33.370 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":0,"result":{"capabilities":{"textDocumentSync":1,"completionProvider":{"resolveProvider":true,"triggerCharacters":["$","{"]},"hoverProvider":true,"documentHighlightProvider":true,"definitionProvider":true,"documentSymbolProvider":true,"workspaceSymbolProvider":true,"referencesProvider":true,"codeActionProvider":{"codeActionKinds":["quickfix"],"resolveProvider":false,"workDoneProgress":false}}}}
2023-01-25T19:47:33.370 helix_lsp::transport [INFO] <- {"capabilities":{"codeActionProvider":{"codeActionKinds":["quickfix"],"resolveProvider":false,"workDoneProgress":false},"completionProvider":{"resolveProvider":true,"triggerCharacters":["$","{"]},"definitionProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"hoverProvider":true,"referencesProvider":true,"textDocumentSync":1,"workspaceSymbolProvider":true}}
2023-01-25T19:47:33.370 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"initialized","params":{}}
2023-01-25T19:47:33.370 helix_term::application [DEBUG] received editor event: LanguageServerMessage((0, Notification(Notification { jsonrpc: None, method: "initialized", params: None })))
2023-01-25T19:47:33.370 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"bash","text":"#!/bin/bash\n\necho $1      # Unquoted variables\n[ $n && $m ] # && in [ .. ]\n[ x ] &\n[ y ] | [ z ] # Accidental backgrounding and piping\n","uri":"file:///home/david/Downloads/testlsp.sh","version":0}}}
2023-01-25T19:47:33.371 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-01-25T19:47:33.374 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":0,"method":"client/registerCapability","params":{"registrations":[{"id":"9d96d6e6-f0a2-476b-9b9b-2d2f16f63e6f","method":"workspace/didChangeConfiguration","registerOptions":{"section":"bashIde"}}]}}
2023-01-25T19:47:33.374 helix_term::application [DEBUG] received editor event: LanguageServerMessage((0, MethodCall(MethodCall { jsonrpc: Some(V2), method: "client/registerCapability", params: Map({"registrations": Array [Object {"id": String("9d96d6e6-f0a2-476b-9b9b-2d2f16f63e6f"), "method": String("workspace/didChangeConfiguration"), "registerOptions": Object {"section": String("bashIde")}}]}), id: Num(0) })))
2023-01-25T19:47:33.374 helix_term::application [ERROR] Language Server: Method not found client/registerCapability
2023-01-25T19:47:33.374 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":1,"method":"workspace/configuration","params":{"items":[{"section":"bashIde"}]}}
2023-01-25T19:47:33.375 helix_term::application [DEBUG] received editor event: LanguageServerMessage((0, MethodCall(MethodCall { jsonrpc: Some(V2), method: "workspace/configuration", params: Map({"items": Array [Object {"section": String("bashIde")}]}), id: Num(1) })))
2023-01-25T19:47:33.375 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","result":[null],"id":1}
2023-01-25T19:47:33.393 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"19:47:33.380 INFO BackgroundAnalysis: resolving glob \"**/*@(.sh|.inc|.bash|.command)\" inside \"file:///home/david/Downloads\"..."}}
2023-01-25T19:47:33.393 helix_term::application [DEBUG] received editor event: LanguageServerMessage((0, Notification(Notification { jsonrpc: Some(V2), method: "window/logMessage", params: Map({"message": String("19:47:33.380 INFO BackgroundAnalysis: resolving glob \"**/*@(.sh|.inc|.bash|.command)\" inside \"file:///home/david/Downloads\"..."), "type": Number(3)}) })))
2023-01-25T19:47:33.393 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Info, message: "19:47:33.380 INFO BackgroundAnalysis: resolving glob \"**/*@(.sh|.inc|.bash|.command)\" inside \"file:///home/david/Downloads\"..." }
2023-01-25T19:47:33.393 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-01-25T19:47:33.460 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"19:47:33.459 INFO BackgroundAnalysis: Glob resolved with 5 files after 0.078 seconds"}}
2023-01-25T19:47:33.460 helix_term::application [DEBUG] received editor event: LanguageServerMessage((0, Notification(Notification { jsonrpc: Some(V2), method: "window/logMessage", params: Map({"message": String("19:47:33.459 INFO BackgroundAnalysis: Glob resolved with 5 files after 0.078 seconds"), "type": Number(3)}) })))
2023-01-25T19:47:33.460 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Info, message: "19:47:33.459 INFO BackgroundAnalysis: Glob resolved with 5 files after 0.078 seconds" }
2023-01-25T19:47:33.460 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-01-25T19:47:33.478 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":2,"message":"19:47:33.477 WARNING ⛔️ Error while parsing file:///home/david/Downloads/Repro_112_12092_Linux/Repro-1-12092/install.sh: syntax error"}}
2023-01-25T19:47:33.478 helix_term::application [DEBUG] received editor event: LanguageServerMessage((0, Notification(Notification { jsonrpc: Some(V2), method: "window/logMessage", params: Map({"message": String("19:47:33.477 WARNING ⛔\u{fe0f} Error while parsing file:///home/david/Downloads/Repro_112_12092_Linux/Repro-1-12092/install.sh: syntax error"), "type": Number(2)}) })))
2023-01-25T19:47:33.478 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Warning, message: "19:47:33.477 WARNING ⛔\u{fe0f} Error while parsing file:///home/david/Downloads/Repro_112_12092_Linux/Repro-1-12092/install.sh: syntax error" }
2023-01-25T19:47:33.478 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-01-25T19:47:33.481 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"19:47:33.481 INFO BackgroundAnalysis: Completed after 0.1 seconds."}}
2023-01-25T19:47:33.481 helix_term::application [DEBUG] received editor event: LanguageServerMessage((0, Notification(Notification { jsonrpc: Some(V2), method: "window/logMessage", params: Map({"message": String("19:47:33.481 INFO BackgroundAnalysis: Completed after 0.1 seconds."), "type": Number(3)}) })))
2023-01-25T19:47:33.481 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Info, message: "19:47:33.481 INFO BackgroundAnalysis: Completed after 0.1 seconds." }
2023-01-25T19:47:33.900 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/david/Downloads/testlsp.sh","version":0,"diagnostics":[{"message":"Double quote to prevent globbing and word splitting.","severity":3,"code":"SC2086","source":"shellcheck","range":{"start":{"line":2,"character":5},"end":{"line":2,"character":7}},"codeDescription":{"href":"https://www.shellcheck.net/wiki/SC2086"}},{"message":"Double quote to prevent globbing and word splitting.","severity":3,"code":"SC2086","source":"shellcheck","range":{"start":{"line":3,"character":2},"end":{"line":3,"character":4}},"codeDescription":{"href":"https://www.shellcheck.net/wiki/SC2086"}},{"message":"Instead of [ a && b ], use [ a ] && [ b ].","severity":1,"code":"SC2107","source":"shellcheck","range":{"start":{"line":3,"character":5},"end":{"line":3,"character":7}},"codeDescription":{"href":"https://www.shellcheck.net/wiki/SC2107"}},{"message":"Double quote to prevent globbing and word splitting.","severity":3,"code":"SC2086","source":"shellcheck","range":{"start":{"line":3,"character":8},"end":{"line":3,"character":10}},"codeDescription":{"href":"https://www.shellcheck.net/wiki/SC2086"}},{"message":"This expression is constant. Did you forget a $ somewhere?","severity":1,"code":"SC2078","source":"shellcheck","range":{"start":{"line":4,"character":2},"end":{"line":4,"character":3}},"codeDescription":{"href":"https://www.shellcheck.net/wiki/SC2078"}},{"message":"Use && for logical AND. Single & will background and return true.","severity":1,"code":"SC2265","source":"shellcheck","range":{"start":{"line":4,"character":6},"end":{"line":4,"character":7}},"codeDescription":{"href":"https://www.shellcheck.net/wiki/SC2265"}},{"message":"This expression is constant. Did you forget a $ somewhere?","severity":1,"code":"SC2078","source":"shellcheck","range":{"start":{"line":5,"character":2},"end":{"line":5,"character":3}},"codeDescription":{"href":"https://www.shellcheck.net/wiki/SC2078"}},{"message":"Use || for logical OR. Single | will pipe.","severity":2,"code":"SC2266","source":"shellcheck","range":{"start":{"line":5,"character":6},"end":{"line":5,"character":7}},"codeDescription":{"href":"https://www.shellcheck.net/wiki/SC2266"}},{"message":"This expression is constant. Did you forget a $ somewhere?","severity":1,"code":"SC2078","source":"shellcheck","range":{"start":{"line":5,"character":10},"end":{"line":5,"character":11}},"codeDescription":{"href":"https://www.shellcheck.net/wiki/SC2078"}}]}}
2023-01-25T19:47:33.900 helix_term::application [DEBUG] received editor event: LanguageServerMessage((0, Notification(Notification { jsonrpc: Some(V2), method: "textDocument/publishDiagnostics", params: Map({"diagnostics": Array [Object {"code": String("SC2086"), "codeDescription": Object {"href": String("https://www.shellcheck.net/wiki/SC2086")}, "message": String("Double quote to prevent globbing and word splitting."), "range": Object {"end": Object {"character": Number(7), "line": Number(2)}, "start": Object {"character": Number(5), "line": Number(2)}}, "severity": Number(3), "source": String("shellcheck")}, Object {"code": String("SC2086"), "codeDescription": Object {"href": String("https://www.shellcheck.net/wiki/SC2086")}, "message": String("Double quote to prevent globbing and word splitting."), "range": Object {"end": Object {"character": Number(4), "line": Number(3)}, "start": Object {"character": Number(2), "line": Number(3)}}, "severity": Number(3), "source": String("shellcheck")}, Object {"code": String("SC2107"), "codeDescription": Object {"href": String("https://www.shellcheck.net/wiki/SC2107")}, "message": String("Instead of [ a && b ], use [ a ] && [ b ]."), "range": Object {"end": Object {"character": Number(7), "line": Number(3)}, "start": Object {"character": Number(5), "line": Number(3)}}, "severity": Number(1), "source": String("shellcheck")}, Object {"code": String("SC2086"), "codeDescription": Object {"href": String("https://www.shellcheck.net/wiki/SC2086")}, "message": String("Double quote to prevent globbing and word splitting."), "range": Object {"end": Object {"character": Number(10), "line": Number(3)}, "start": Object {"character": Number(8), "line": Number(3)}}, "severity": Number(3), "source": String("shellcheck")}, Object {"code": String("SC2078"), "codeDescription": Object {"href": String("https://www.shellcheck.net/wiki/SC2078")}, "message": String("This expression is constant. Did you forget a $ somewhere?"), "range": Object {"end": Object {"character": Number(3), "line": Number(4)}, "start": Object {"character": Number(2), "line": Number(4)}}, "severity": Number(1), "source": String("shellcheck")}, Object {"code": String("SC2265"), "codeDescription": Object {"href": String("https://www.shellcheck.net/wiki/SC2265")}, "message": String("Use && for logical AND. Single & will background and return true."), "range": Object {"end": Object {"character": Number(7), "line": Number(4)}, "start": Object {"character": Number(6), "line": Number(4)}}, "severity": Number(1), "source": String("shellcheck")}, Object {"code": String("SC2078"), "codeDescription": Object {"href": String("https://www.shellcheck.net/wiki/SC2078")}, "message": String("This expression is constant. Did you forget a $ somewhere?"), "range": Object {"end": Object {"character": Number(3), "line": Number(5)}, "start": Object {"character": Number(2), "line": Number(5)}}, "severity": Number(1), "source": String("shellcheck")}, Object {"code": String("SC2266"), "codeDescription": Object {"href": String("https://www.shellcheck.net/wiki/SC2266")}, "message": String("Use || for logical OR. Single | will pipe."), "range": Object {"end": Object {"character": Number(7), "line": Number(5)}, "start": Object {"character": Number(6), "line": Number(5)}}, "severity": Number(2), "source": String("shellcheck")}, Object {"code": String("SC2078"), "codeDescription": Object {"href": String("https://www.shellcheck.net/wiki/SC2078")}, "message": String("This expression is constant. Did you forget a $ somewhere?"), "range": Object {"end": Object {"character": Number(11), "line": Number(5)}, "start": Object {"character": Number(10), "line": Number(5)}}, "severity": Number(1), "source": String("shellcheck")}], "uri": String("file:///home/david/Downloads/testlsp.sh"), "version": Number(0)}) })))
2023-01-25T19:47:33.900 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-01-25T19:47:35.848 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-01-25T19:47:36.249 helix_term::application [DEBUG] received editor event: IdleTimer
2023-01-25T19:47:37.248 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-01-25T19:47:37.649 helix_term::application [DEBUG] received editor event: IdleTimer
2023-01-25T19:47:38.936 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-01-25T19:47:39.337 helix_term::application [DEBUG] received editor event: IdleTimer
2023-01-25T19:47:39.368 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-01-25T19:47:39.368 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/codeAction","params":{"context":{"diagnostics":[{"code":"SC2086","message":"Double quote to prevent globbing and word splitting.","range":{"end":{"character":7,"line":2},"start":{"character":5,"line":2}},"severity":3,"source":"shellcheck"}]},"range":{"end":{"character":7,"line":2},"start":{"character":5,"line":2}},"textDocument":{"uri":"file:///home/david/Downloads/testlsp.sh"}},"id":1}
2023-01-25T19:47:39.370 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":1,"result":[]}
2023-01-25T19:47:39.370 helix_lsp::transport [INFO] <- []
2023-01-25T19:47:39.370 helix_view::editor [DEBUG] editor status: No code actions available
2023-01-25T19:47:39.370 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2023-01-25T19:47:39.768 helix_term::application [DEBUG] received editor event: IdleTimer
2023-01-25T19:47:42.000 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0

I really hope you can get it working! :)

@skovhus
Copy link
Collaborator

skovhus commented Jan 27, 2023

@David-Else I finally found time to spin up helix and debug what was going on. It seems like a great editor! And I found a fix and released it as version 4.6.1.

Let me know if it works for you and other feature suggestion is more than welcome as new GitHub issues.

@David-Else
Copy link
Contributor Author

@skovhus Brilliant, it works! Thanks :) Yes, Helix is fantastic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants