emacs-lsp / lsp-haskell

lsp-mode :heart: haskell
https://emacs-lsp.github.io/lsp-haskell
GNU General Public License v3.0
236 stars 62 forks source link

Code actions / Apply hints no longer working #118

Closed bhrgunatha closed 3 years ago

bhrgunatha commented 3 years ago

emacs --version
GNU Emacs 27.1

I'm using the offical Arch package along with the (unofficial) AUR haskell-language-server-bin which just downloads the linux build from the official github repo

I'm working my way through the haskell fp-course fork that uses stack.

It's been working well but I've recently converted my crufty, but stable and familiar old config to use-package.

Here are the relevant parts of my config

I have the following versions from melpa:

lsp-haskell 20210209.2150
lsp-mode    20210314.1828
lsp-ui      20210220.703  

The problem is now the code actions or hints that lsp-haskell reports no longer work. They did work in the past, but during the upheaval it's now broken.

As a simple example

module Test where
fn :: Int -> Int
fn = \x -> x * 2

There are 2 hints reported via flycheck. The flycheck errors buffer shows the hints

 Found:
   fn = \ x -> x * 2
 Why not:
   fn x = x * 2
 (lsp)

 Found:
   \ x -> x * 2
 Why not:
   (* 2)
 (lsp)

Clicking on Apply all hints doesn't change the buffer though and a message appears lsp-request: ExitFailure 1.

When I check the hls.log I see errors parsing json responses:

Command "haskell-language-server-wrapper --lsp -d -l /tmp/hls.log" is present on the path.
Command "haskell-language-server-wrapper --lsp -d -l /tmp/hls.log" is present on the path.
Found the following clients for /home/bhrgunatha/docs/scratch/Test.hs: (server-id lsp-haskell, priority 0)
The following clients were selected based on priority: (server-id lsp-haskell, priority 0)
Creating watch for /home/bhrgunatha
haskell-lsp:incoming message parse error. {"jsonrpc":"2.0","id":1,"result":null}
 Error in $.result: parsing () failed, expected Array, but encountered Null

haskell-lsp:incoming message parse error. {"jsonrpc":"2.0","id":2,"result":null}
 Error in $.result: parsing () failed, expected Array, but encountered Null

Command "haskell-language-server-wrapper --lsp -d -l /tmp/hls.log" is present on the path.
Command "haskell-language-server-wrapper --lsp -d -l /tmp/hls.log" is present on the path.
Found the following clients for /home/bhrgunatha/docs/scratch/Test.hs: (server-id lsp-haskell, priority 0)
The following clients were selected based on priority: (server-id lsp-haskell, priority 0)
haskell-lsp:incoming message parse error. {"jsonrpc":"2.0","id":3,"result":null}
 Error in $.result: parsing () failed, expected Array, but encountered Null

haskell-lsp:incoming message parse error. {"jsonrpc":"2.0","id":4,"result":null}
 Error in $.result: parsing () failed, expected Array, but encountered Null

It looks like lsp-haskell is not getting the expected responses from the haskell-language-server. I've see the same error reported hundreds of times in the lsp.log buffer over many restarts of emacs trying to investigate the problem.

I see 2 processes on my machine

haskell-language-server-8.10.4 --lsp -d -l /tmp/hls.log
haskell-language-server-wrapper --lsp -d -l /tmp/hls.log

I'm not sure if the problem is with lsp-haskell, lsp-mode, or the haskell language server but lsp-haskell is mentioned in the log file so I'm reporting the problem here.

michaelpj commented 3 years ago

The log message you're seeing is this: https://github.com/haskell/haskell-language-server/issues/1476

However, that's apparently benign, so I don't think it can be responsible for the problem you're seeing. Regardless, I think this is almost certainly a HLS issue. Could you open an issue there, ideally including what's in /tmp/hls.log?

bhrgunatha commented 3 years ago

I will do that, thanks. You know, I searched (unsuccessfully) for that message. Even now the only thing I can find is my own post on reddit's emacs sub :). So thanks for the link too!

michaelpj commented 3 years ago

Looks like you made on there, so I'll close this one.