Skip to content
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

issues with CompletionItemResolve #4451

Open
bwkam opened this issue Nov 17, 2024 · 24 comments · May be fixed by #4463
Open

issues with CompletionItemResolve #4451

bwkam opened this issue Nov 17, 2024 · 24 comments · May be fixed by #4463
Labels
component: ghcide type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@bwkam
Copy link

bwkam commented Nov 17, 2024

Your environment

Which OS do you use?
NixOS

Which version of GHC do you use and how did you install it?
9.6.6, with nix

How is your project built (alternative: link to the project)?

Which LSP client (editor/plugin) do you use?
emacs+lsp-mode
Which version of HLS do you use and how did you install it?
2.9.0.0, using nix
Have you configured HLS in any way (especially: a hie.yaml file)?
No

What's wrong?

some error about SMethod_CompletionItemResolve keeps popping up as I type anything in the buffer
the error is not an emacs problem too, same behavior occurs on vscode (I just tested)
(see below)

Debug information

Error processing message (error "No plugins are available to handle this SMethod_CompletionItemResolve request.
 Plugins installed for this method, but not available to handle this request are:
ghcide-completions does not handle resolve requests for (unable to determine resolve owner)).").
@bwkam bwkam added status: needs triage type: support User support tickets, questions, help with setup etc. labels Nov 17, 2024
@fendor
Copy link
Collaborator

fendor commented Nov 18, 2024

Thank you for the bug report!

I can not reproduce on arch linux with HLS 2.9.0.1 installed via ghcup.
However, I can reproduce the issue with a nixpkgs installed HLS binary.

I am able to reproduce the issue using a nixpkgs installed HLS binary as well as on arch linux with HLS 2.9.0.1 ghc 9.6.6.

@fendor fendor added os: nixos component: ghcide type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. and removed status: needs triage type: support User support tickets, questions, help with setup etc. os: nixos labels Nov 18, 2024
@dmitrykvasnikov
Copy link

dmitrykvasnikov commented Nov 20, 2024

I have the same issue in doomemacs, emacs+lsp-mode , vanilla arch, ghc 9.10.1

@meritamen
Copy link

Same here, vanilla emacs+lsp-haskell, macOS Ventura 13.7.1, ghc 9.4.8, hls 2.9.0.1

@bradrn
Copy link
Contributor

bradrn commented Dec 8, 2024

I’m seeing the same issue in vanilla Emacs with lsp-haskell, Arch Linux (well, EndeavourOS), GHC 9.4.8, HLS 2.1.0.1

@fendor
Copy link
Collaborator

fendor commented Dec 8, 2024

Reading into the code, I don't think there is anything wrong, sometimes additional information can be requested, and sometimes the server doesn't have any additional information. E.g., documentation or type signatures for non-local identifiers.
We can't be that fine-grained in the Protocol, so the client always tries to resolve completion items which sometimes "fails" but the server can still use what they already have.

Is the current behaviour annoying, e.g., does Emacs or vim spam you with errors?

@bwkam
Copy link
Author

bwkam commented Dec 8, 2024

yeah in emacs, its extremely annoying. a buffer with that error keeps popping up as you type

@fendor
Copy link
Collaborator

fendor commented Dec 8, 2024

But this must be a new change in emacs, right? I think we had this behaviour for a while and just now we started to get these reports?

Seemingly, HLS is behaving correctly. I think this issue is resolvable by extending CompletionResolveData with a NothingToResolve and inserting as the default for all completion items.

@bradrn
Copy link
Contributor

bradrn commented Dec 9, 2024

Is the current behaviour annoying, e.g., does Emacs or vim spam you with errors?

Correct. I get a message every time the autocomplete event fires, i.e. every time I press a key (or nearly so).

@dmitrykvasnikov
Copy link

message every time the autocomplete event fires, i.e. every time I press a key (or nearly so).
That's exactly what's happening. Extremely annoying. I limited minibuffer height with 1 line, but in this case i don't see meaningful messages / menus from other plugins.

@fendor fendor linked a pull request Dec 9, 2024 that will close this issue
@fendor
Copy link
Collaborator

fendor commented Dec 9, 2024

I created #4463 which I will sneak into #4448 to get it out ASAP.

Does someone want to double check this works?

@dmitrykvasnikov
Copy link

dmitrykvasnikov commented Dec 10, 2024

Does someone want to double check this works?

If you tell me what to do - i'll try :-)

@fendor
Copy link
Collaborator

fendor commented Dec 10, 2024

If you use GHCup, the following works:

ghcup compile hls -g d51c68dcf7a418bde4d02f62345710f298168328 --ghc 9.6.6

Or whatever GHC version you use in your project.

You can also use clone the project, and run cabal install, then point emacs to your freshly installed HLS version.

@dmitrykvasnikov
Copy link

dmitrykvasnikov commented Dec 10, 2024

If you use GHCup, the following works:

ghcup compile hls -g d51c68dcf7a418bde4d02f62345710f298168328 --ghc 9.6.6

I did this for ghc 9.10.1
This message now doesn't appear when auto-completion list consist of haskell only keywords / modules etc, but if it includes one of my function in it - this message still continue to appear. Screenshots below

1733836130

1733836264

@fendor
Copy link
Collaborator

fendor commented Dec 10, 2024

Thanks, another test to add to the testsuite!

@fendor
Copy link
Collaborator

fendor commented Dec 10, 2024

@dmitrykvasnikov Where was the local function defined you tried to complete? In the same module, different module, etc...? I am unable to reproduce the issue.

@dmitrykvasnikov
Copy link

@fendor
In this same module (it's written above on screenshot). Just tried with function defined in different module - works fine, no message.
Just now I did as example:
func :: Int -> Int -> Int
func = (+)

So if after that i put in my code:
g = fu .. - in this moment autocomplete gives me suggestions (with function defined above) and error message appears.

@fendor
Copy link
Collaborator

fendor commented Dec 10, 2024

Can't reproduce, I am getting the correct message

Trace - 17:31:55] Received response 'completionItem/resolve - (20)' in 2ms.
Result: {
    "data": {
        "itemFile": "file:///home/hugin/Documents/haskell/hls-completion-resolve/A.hs",
        "itemName": [
            "A",
            "main-398bd560290e6bafe7a4d6959f05d45a6937707a",
            "v",
            "func"
        ],
        "itemNeedsType": false,
        "tag": "CompletionResolveData"
    },
    "detail": ":: Int -> Int -> Int",
    "documentation": {
        "kind": "markdown",
        "value": "*Defined at line 3, column 1 in this module*\n"
    },
    "insertText": "func",
    "insertTextFormat": 2,
    "kind": 3,
    "label": "func",
    "sortText": "00"
}

Maybe the compiled binary wasn't used? I am double checking my instructions.

@fendor
Copy link
Collaborator

fendor commented Dec 10, 2024

I am a little bit confused 😅 After running ghcup compile ..., does ls -alh ~/.ghcup/bin/haskell-language-server-9.10.1~2.9.0.1 hint that the binary was freshly created?
Does ~/.ghcup/bin/haskell-language-server-9.10.1 point to ~/.ghcup/bin/haskell-language-server-9.10.1~2.9.0.1?

@bwkam
Copy link
Author

bwkam commented Dec 10, 2024

I'm compiling this myself to see if I can reproduce (taking a while)

@bwkam
Copy link
Author

bwkam commented Dec 10, 2024

ok, so if I'm doing this correctly. the error still pops up, but less frequently. not so helpful footage of when it triggers attached

using ghc 9.6.6

checked the binary is freshly created

>ls -alh ~/.local/bin/haskell-language-server
Permissions Size User  Date Modified Name
lrwxrwxrwx     - bwkam 10 Dec 20:08   /home/bwkam/.local/bin/haskell-language-server -> ../state/cabal/store/ghc-9.6.5/haskell-language-server-2.9.0.1-e-haskell-language-server-bda016429039356b5e7ae15d0b54c3a626539f8f90dccf348e7458730e7bef3d/bin/haskell-language-server

Peek 2024-12-10 20-30

logs:

2024-12-10T18:29:54.785159Z | Warning | No plugin handles this "completionItem/resolve" request.
2024-12-10T18:29:54.786113Z | Warning | No plugin handles this "completionItem/resolve" request.
2024-12-10T18:29:55.405965Z | Warning | No plugin handles this "completionItem/resolve" request.
2024-12-10T18:29:58.902473Z | Info | Live bytes: 20.24MB Heap size: 662.70MB
2024-12-10T18:30:03.242066Z | Info | Could not identify reverse dependencies for NormalizedFilePath "/home/bwkam/Documents/dev/aoc24/app/Main.hs"
2024-12-10T18:30:06.793302Z | Warning | No plugin handles this "completionItem/resolve" request.
2024-12-10T18:30:06.793467Z | Warning | No plugin handles this "completionItem/resolve" request.
2024-12-10T18:30:08.573218Z | Warning | No plugin handles this "completionItem/resolve" request.
2024-12-10T18:30:08.573398Z | Warning | No plugin handles this "completionItem/resolve" request.
2024-12-10T18:30:09.078120Z | Warning | No plugin handles this "completionItem/resolve" request.

@dmitrykvasnikov
Copy link

I am a little bit confused 😅 After running ghcup compile ..., does `` hint that the binary was freshly created? Does ~/.ghcup/bin/haskell-language-server-9.10.1 point to `/.ghcup/bin/haskell-language-server-9.10.12.9.0.1`?

I've just checked - yes to both questions. haskell-language-server-wrapper updated as well (if it's relevant) .

@fendor
Copy link
Collaborator

fendor commented Dec 12, 2024

Very puzzling... the Completions shown by @bwkam look completely wrong, too. We should never suggest LANGUAGE pragmas in this context as a possible completion?!

@bwkam
Copy link
Author

bwkam commented Dec 12, 2024

yeah, I was not sure why it was suggesting that

@fendor
Copy link
Collaborator

fendor commented Dec 17, 2024

I am unable to reproduce the issue with #4463... As the next release is imminent, I would merge #4463 and hope it improves the situation until the HLS team can reproduce the issue again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: ghcide type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants