helix icon indicating copy to clipboard operation
helix copied to clipboard

Missing Code actions and code lenses (Haskell)

Open 0rphee opened this issue 3 years ago • 7 comments

Summary

Many code actions, and code lenses are not available compared to other text editors. In this gist two functions with multiple code actions available in Kakoune and VS Code can't be done in Helix.

This issue might refer to the same problem as #2994

In the videos below I show the behavior in helix compared to 1. Kakoune, 2. VS Code.

HLS Code actions (apply hlint fixes) Helix (left) - Kakoune (right)

https://user-images.githubusercontent.com/79347623/177895723-6012c895-f881-471c-a4d0-834ccbb23d2d.mov

HLS Code lens (add type signature) Helix (left) - Kakoune (right)

https://user-images.githubusercontent.com/79347623/177896246-060107dc-0c9c-49be-b8ea-38644ba376c0.mov

HLS Code lens and Code actions in VS Code

https://user-images.githubusercontent.com/79347623/177896346-0b893164-54b4-4287-98d1-093d049ef9db.mov

Reproduction Steps

  1. Download the gist
  2. Select the whole line of the first function, type <space> + a. Only some actions will be available but not all. Try with each token there.
  3. Try the same with the other function.

Helix log

~/.cache/helix/helix.log
2022-07-07T19:48:23.132 helix_lsp::transport [ERROR] err <- "No 'hie.yaml' found. Try to discover the project type!\n"
2022-07-07T19:48:23.137 helix_lsp::transport [ERROR] err <- "Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.7.0.0 aarch64 ghc-9.2.2\n"
2022-07-07T19:48:23.137 helix_lsp::transport [ERROR] err <- "Current directory: /Users/roger/Documents/Dev/Haskell-Projects/Haskell-Programming-From-First-Principles/ch22\n"
2022-07-07T19:48:23.137 helix_lsp::transport [ERROR] err <- "Operating system: darwin\n"
2022-07-07T19:48:23.137 helix_lsp::transport [ERROR] err <- "Arguments: [\"--lsp\"]\n"
2022-07-07T19:48:23.137 helix_lsp::transport [ERROR] err <- "Cradle directory: /Users/roger/Documents/Dev/Haskell-Projects/Haskell-Programming-From-First-Principles/ch22\n"
2022-07-07T19:48:23.138 helix_lsp::transport [ERROR] err <- "Cradle type: Default\n"
2022-07-07T19:48:23.294 helix_lsp::transport [ERROR] err <- "\n"
2022-07-07T19:48:23.294 helix_lsp::transport [ERROR] err <- "Tool versions found on the $PATH\n"
2022-07-07T19:48:23.295 helix_lsp::transport [ERROR] err <- "cabal:\t\t3.6.2.0\n"
2022-07-07T19:48:23.296 helix_lsp::transport [ERROR] err <- "stack:\t\t2.7.5\n"
2022-07-07T19:48:23.296 helix_lsp::transport [ERROR] err <- "ghc:\t\t8.10.7\n"
2022-07-07T19:48:23.296 helix_lsp::transport [ERROR] err <- "\n"
2022-07-07T19:48:23.296 helix_lsp::transport [ERROR] err <- "\n"
2022-07-07T19:48:23.296 helix_lsp::transport [ERROR] err <- "Consulting the cradle to get project GHC version...\n"
2022-07-07T19:48:23.337 helix_lsp::transport [ERROR] err <- "Project GHC version: 8.10.7\n"
2022-07-07T19:48:23.337 helix_lsp::transport [ERROR] err <- "haskell-language-server exe candidates: [\"haskell-language-server-8.10.7\",\"haskell-language-server\"]\n"
2022-07-07T19:48:23.338 helix_lsp::transport [ERROR] err <- "Launching haskell-language-server exe at:/Users/roger/.ghcup/bin/haskell-language-server-8.10.7\n"
2022-07-07T19:48:25.301 helix_lsp::transport [ERROR] err <- "2022-07-08T00:48:25.301493Z | Info | No log file specified; using stderr.\n"
2022-07-07T19:48:25.302 helix_lsp::transport [ERROR] err <- "2022-07-08T00:48:25.301745Z | Info | haskell-language-server version: 1.7.0.0 (GHC: 8.10.7) (PATH: /Users/roger/.ghcup/hls/1.7.0.0/lib/haskell-language-server-1.7.0.0/bin/haskell-language-server-8.10.7)\n"
2022-07-07T19:48:25.302 helix_lsp::transport [ERROR] err <- "2022-07-08T00:48:25.302120Z | Info | Directory: /Users/roger/Documents/Dev/Haskell-Projects/Haskell-Programming-From-First-Principles/ch22\n"
2022-07-07T19:48:25.302 helix_lsp::transport [ERROR] err <- "2022-07-08T00:48:25.302325Z | Info | Starting (haskell-language-server) LSP server...\n"
2022-07-07T19:48:25.302 helix_lsp::transport [ERROR] err <- "  GhcideArguments {argsCommand = LSP, argsCwd = Nothing, argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = False, argsLogFile = Nothing, argsThreads = 0, argsProjectGhcVersion = False}\n"
2022-07-07T19:48:25.302 helix_lsp::transport [ERROR] err <- "  PluginIds: [ pragmas\n"
2022-07-07T19:48:25.302 helix_lsp::transport [ERROR] err <- "             , floskell\n"
2022-07-07T19:48:25.302 helix_lsp::transport [ERROR] err <- "             , fourmolu\n"
2022-07-07T19:48:25.302 helix_lsp::transport [ERROR] err <- "             , tactics\n"
2022-07-07T19:48:25.302 helix_lsp::transport [ERROR] err <- "             , ormolu\n"
2022-07-07T19:48:25.302 helix_lsp::transport [ERROR] err <- "             , stylish-haskell\n"
2022-07-07T19:48:25.303 helix_lsp::transport [ERROR] err <- "             , rename\n"
2022-07-07T19:48:25.303 helix_lsp::transport [ERROR] err <- "             , retrie\n"
2022-07-07T19:48:25.303 helix_lsp::transport [ERROR] err <- "             , brittany\n"
2022-07-07T19:48:25.303 helix_lsp::transport [ERROR] err <- "             , callHierarchy\n"
2022-07-07T19:48:25.303 helix_lsp::transport [ERROR] err <- "             , class\n"
2022-07-07T19:48:25.303 helix_lsp::transport [ERROR] err <- "             , haddockComments\n"
2022-07-07T19:48:25.303 helix_lsp::transport [ERROR] err <- "             , eval\n"
2022-07-07T19:48:25.303 helix_lsp::transport [ERROR] err <- "             , importLens\n"
2022-07-07T19:48:25.303 helix_lsp::transport [ERROR] err <- "             , qualifyImportedNames\n"
2022-07-07T19:48:25.303 helix_lsp::transport [ERROR] err <- "             , refineImports\n"
2022-07-07T19:48:25.303 helix_lsp::transport [ERROR] err <- "             , moduleName\n"
2022-07-07T19:48:25.303 helix_lsp::transport [ERROR] err <- "             , hlint\n"
2022-07-07T19:48:25.303 helix_lsp::transport [ERROR] err <- "             , splice\n"
2022-07-07T19:48:25.303 helix_lsp::transport [ERROR] err <- "             , alternateNumberFormat\n"
2022-07-07T19:48:25.303 helix_lsp::transport [ERROR] err <- "             , selectionRange\n"
2022-07-07T19:48:25.303 helix_lsp::transport [ERROR] err <- "             , changeTypeSignature\n"
2022-07-07T19:48:25.303 helix_lsp::transport [ERROR] err <- "             , ghcide-hover-and-symbols\n"
2022-07-07T19:48:25.303 helix_lsp::transport [ERROR] err <- "             , ghcide-code-actions-imports-exports\n"
2022-07-07T19:48:25.303 helix_lsp::transport [ERROR] err <- "             , ghcide-code-actions-type-signatures\n"
2022-07-07T19:48:25.303 helix_lsp::transport [ERROR] err <- "             , ghcide-code-actions-bindings\n"
2022-07-07T19:48:25.303 helix_lsp::transport [ERROR] err <- "             , ghcide-code-actions-fill-holes\n"
2022-07-07T19:48:25.303 helix_lsp::transport [ERROR] err <- "             , ghcide-completions\n"
2022-07-07T19:48:25.303 helix_lsp::transport [ERROR] err <- "             , ghcide-type-lenses\n"
2022-07-07T19:48:25.303 helix_lsp::transport [ERROR] err <- "             , ghcide-core\n"
2022-07-07T19:48:25.304 helix_lsp::transport [ERROR] err <- "             , LSPRecorderCallback ]\n"
2022-07-07T19:48:25.304 helix_lsp::transport [ERROR] err <- "2022-07-08T00:48:25.304040Z | Info | Logging heap statistics every 60.00s\n"
2022-07-07T19:48:25.348 helix_lsp::transport [ERROR] err <- " 2022-07-08T00:48:25.348748Z | Info | Staring LSP server...\n"
2022-07-07T19:48:25.349 helix_lsp::transport [ERROR] err <- "If you are seeing this in a terminal, you probably should have run WITHOUT the --lsp option!\n"
2022-07-07T19:48:25.349 helix_lsp::transport [ERROR] err <- "2022-07-08T00:48:25.349686Z | Info | Started LSP server in 0.00s\n"
2022-07-07T19:48:25.403 helix_lsp::transport [ERROR] err <- "2022-07-08T00:48:25.401452Z | Info | Registering IDE configuration: IdeConfiguration {workspaceFolders = fromList [NormalizedUri 6042087041491829206 \"file:///Users/roger/Documents/Dev/Haskell-Projects/Haskell-Programming-From-First-Principles\"], clientSettings = hashed Nothing}\n"
2022-07-07T19:48:25.405 helix_lsp::transport [ERROR] err <- "2022-07-08T00:48:25.405412Z | Info | Cradle path: ch22/ch22.hs\n"
2022-07-07T19:48:25.405 helix_lsp::transport [ERROR] err <- "2022-07-08T00:48:25.405499Z | Warning | No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for ch22/ch22.hs.\n"
2022-07-07T19:48:25.405 helix_lsp::transport [ERROR] err <- "Proceeding with [implicit cradle](https://hackage.haskell.org/package/implicit-hie).\n"
2022-07-07T19:48:25.405 helix_lsp::transport [ERROR] err <- "You should ignore this message, unless you see a 'Multi Cradle: No prefixes matched' error.\n"
2022-07-07T19:48:25.523 helix_lsp::transport [ERROR] err <- "2022-07-08T00:48:25.518586Z | Info | Interface files cache directory: /Users/roger/.cache/ghcide/main-1a596a151463f2c53ee4feb14ecd276a1ccebfda\n"
2022-07-07T19:48:25.523 helix_lsp::transport [ERROR] err <- "2022-07-08T00:48:25.523667Z | Info | Making new HscEnv. In-place unit ids: [main]\n"
2022-07-07T19:49:03.128 helix_lsp::transport [ERROR] err <- "2022-07-08T00:49:03.127787Z | Info | Reactor thread stopped\n"

Platform

macOS

Terminal Emulator

iTerm2 Build 3.4.16

Helix Version

helix 22.05 (27609f50)

0rphee avatar Jul 08 '22 01:07 0rphee

Can you check again now that https://github.com/helix-editor/helix/pull/3012 is merged?

archseer avatar Jul 08 '22 22:07 archseer

I have to build helix locally right? Or is there any other place I can get the new commits?

0rphee avatar Jul 09 '22 00:07 0rphee

Yeah you would have to checkout master and build locally. We don't have nightly releases yet.

sudormrfbin avatar Jul 09 '22 02:07 sudormrfbin

After building it, #3012 doesn't seem to have solved the issue. The problem persists:

https://user-images.githubusercontent.com/79347623/178110529-589e6459-4e7d-4d6c-9730-89cb8731e390.mov

0rphee avatar Jul 09 '22 14:07 0rphee

take pull #3096, I checked in typescript that it works ok。

erasin avatar Jul 19 '22 01:07 erasin

I have this same issue. Testing with helix 22.08.1 (5ea78559) and I can still reproduce this issue. Anything I can provide to help debugging?

lcycon avatar Sep 19 '22 03:09 lcycon

I've managed to track down the issue, PR #3898 is my very quick pass at resolving the issue

lcycon avatar Sep 19 '22 05:09 lcycon

It seems PR https://github.com/helix-editor/helix/pull/3898 has solved most of the issues. Nevertheless, some actions (at least adding type signatures, https://github.com/helix-editor/helix/issues/3005#issue-1298339875) aren't yet available in helix...

0rphee avatar Nov 08 '22 04:11 0rphee

Even after helix 23 I still have this problem, this is solved problem or not?

Esnos33 avatar Apr 26 '23 08:04 Esnos33

Even after helix 23 I still have this problem, this is solved problem or not?

@Esnos33 what do you mean you still have this problem but you ask if it is solved or it isn't?

I'm pretty sure this is solved, but I had forgot about this issue. Will test later though.

0rphee avatar Apr 26 '23 13:04 0rphee

I mean it doesn't work for me, when I select a function and press space + a, then only meaningless actions shows up.

Esnos33 avatar Apr 26 '23 15:04 Esnos33

I mean it doesn't work for me, when I select a function and press space + a, then only meaningless actions shows up.

@Esnos33 maybe it has to do with what helix version are you using? because, at least for the type signature, it works on helix 23.03 (4cdba7cc).

https://user-images.githubusercontent.com/79347623/234752543-3507bdab-843e-4e9c-9207-581a9835192a.mov

In the case of other code actions maybe not working correctly ("outdated workspace edit ..."), check this issues: #6543 & https://github.com/haskell/haskell-language-server/issues/3547#issue-1650688564

0rphee avatar Apr 27 '23 03:04 0rphee

@0rphee For starters, thanks for response. I still have problem, as you can see on recording. If that matters, I installed helix from apt package on Pop_OS!

EDIT: Uninstalled whole helix and installed it again from source, still having same issue. Other features, like code completion and going to definition still works, hx --health haskell still gives me same message.

https://user-images.githubusercontent.com/56300699/234767040-660830af-6ef2-43f9-a423-84993b5f8005.mov

Esnos33 avatar Apr 27 '23 05:04 Esnos33

@Esnos33 hmm that's unfortunate....

What do you mean you installed it again from source? did you uninstall and install it again with the package manager?

have you tried building helix from source yourself?

also, this maaaaaybe has to do with the version of hls and ghc you are using (i doubt it though), could you check their versions? if possible, i will try to reproduce the problem on my machine

0rphee avatar Apr 27 '23 13:04 0rphee

@0rphee I installed helix from source as in link. I also checked and I have softwrap, which is feature of latest build, so I think I have good one version of helix. Here are screenshots of softwrap and ghcup tui. image image

Esnos33 avatar Apr 27 '23 14:04 Esnos33

@Esnos33 I think I know what's happening. It seems that hls doesn't give as many code actions when it doesn't find a specific project's configuration file (package.yaml or *.cabal).

I just tested it, and when I edit a standalone .hs file, it isn't possible to add type signatures, but when I edit a file inside a stack project this problem doesn't appear.

https://user-images.githubusercontent.com/79347623/235314764-a1022f49-76a3-4ff3-9fe0-211688d08b1e.mov

I think you should file a separate issue in the hls repo, as it seems that this is an issue with the language server, not helix itself.

0rphee avatar Apr 29 '23 17:04 0rphee

@0rphee I just checked and you are right, it works for me on stack! I will later write issue in hls git, thanks for help, helix is best.

Esnos33 avatar Apr 29 '23 17:04 Esnos33

I will close this, as the main issue has been resolved, code lenses are not being added into core https://github.com/helix-editor/helix/issues/7957#issuecomment-1680266499, and the issue with hls not working showing more code actions/diagnostics on files outside of a project seems to be an issue with hls itself

0rphee avatar Oct 24 '23 19:10 0rphee