scalameta / nvim-metals

A Metals plugin for Neovim
https://scalameta.org/metals/
Apache License 2.0
455 stars 74 forks source link

`FindInDependencyJars` doesn't work #637

Open Z1kkurat opened 6 months ago

Z1kkurat commented 6 months ago

Describe the bug

MetalsFindInDependencyJars command doesn't seem to work. After showing the input for file mask and text, nothing happens. I found no errors in metals' log file. The same use case works fine in vscode, so it doesn't seem the issue is in metals itself.

Can be reproduced by adding "com.typesafe.akka" %% "akka-actor" % "2.6.13" to the project's dependencies, file mask should be .conf, query should be akka. out

I use lazyvim if that makes any difference.

Expected behavior

A window/popup with the search results

Operating system

macOS

Version of Metals

1.2.0

Commit of nvim-metals

1e269f1f01e6b970603d51e9e044824d9d8114e7

antosha417 commented 6 months ago

Hey @Z1kkurat! Thank you for opening this issue

I just checked it work as expected for me. I'm still using packer. I ran Update Metals command just to be sure that I'm on the latest version.

Screenshot 2024-01-03 at 23 43 23

Do you by any chance have this line in your config? Maybe it is interfering with the search

        excludedPackages = { "akka.actor.typed.javadsl", "com.github.swagger.akka.javadsl" },

We can also try to reproduce with minimal neovim config.

antosha417 commented 6 months ago

I just tested with this example config nvim -u minimal_config.lua And indeed results of the search are added to quick fix list after removing said line

        excludedPackages = { "akka.actor.typed.javadsl", "com.github.swagger.akka.javadsl" },
Z1kkurat commented 6 months ago

Hi @antosha417, thanks for taking a look! Indeed, I had excludedPackages in my config, but removing it doesn't change anything for me, and the quickfix list stays empty. Is there anything else I can take a look at? Maybe some debug logs?

antosha417 commented 6 months ago

I'm not sure about debug logs, sorry.

I would start with the example config. Make sure it does work for you. Just copy it to minimal_config.lua. Than you can run nvim with following command nvim -u minimal_config.lua After that, you can change example config bit by bit to resemble your original config. And see what breaks it.

Z1kkurat commented 6 months ago

I found what was causing the issue for me. Somehow it doesn't work if neovim is started by calling nvim from the project's directory. However, if I start it like this nvim . (note the dot), then the functionality works as expected with the quickfix list. Both commands were executed while being in the project's directory, everything else was the same.

ckipp01 commented 6 months ago

I found what was causing the issue for me. Somehow it doesn't work if neovim is started by calling nvim from the project's directory. However, if I start it like this nvim . (note the dot), then the functionality works as expected with the quickfix list. Both commands were executed while being in the project's directory, everything else was the same.

Can you include the exact commands of what you mean. I just tried with opening a project just with nvim first and it worked the same as doing nvim .. Do you mean that you just do nvim and then the command? If so, then Metals won't actually be started at as as the autocommand to start it was never triggered. Is that what you mean or do you mean something else?

Z1kkurat commented 6 months ago

@ckipp01 exact sequence of commands:

  1. cd into project directory
  2. run nvim
  3. open build.sbt to start metals
  4. execute MetalsFindInDependencyJars

This results in...nothing, just like in the GIF I've attached to the issue. Text inputs are shown, but nothing happens afterwards.
However, if step 2 is "run nvim .", then it works as expected, and a quickfix window is opened with results.

ckipp01 commented 5 months ago

Hey @Z1kkurat sorry this has sat here for a while. Just getting back to it and testing exactly you have listed, I still can't reproduce with a minimal config. So I honestly have no idea how to move forward without being able to reproduce. Once the build is imported you should totally see this working.