haskell / haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Apache License 2.0
2.72k stars 368 forks source link

How to set up wingman with neovim built in LSP and nvim-lspconfig #2334

Closed kedashoe closed 3 years ago

kedashoe commented 3 years ago

Your environment

$ haskell-language-server-wrapper --probe-tools
haskell-language-server version: 1.4.0.0 (GHC: 8.10.4) (PATH: /home/kevin/.ghcup/bin/haskell-language-server-wrapper-1.4.0) (GIT hash: 253547816ee216c53ee7dacc0ad3cac43e863d30)
Tool versions found on the $PATH
cabal:      3.6.2.0
stack:      2.7.3
ghc:        9.0.1

Which OS do you use: ArchLinux

Which lsp-client do you use: Neovim built in LSP client with nvim-lspconfig

Describe your project: Just testing with default cabal init project

Contents of hie.yaml:

$ cat hie.yaml 
cradle:
  cabal:
    - path: "src"
      component: "lib:haskell-wingman-nvim"

    - path: "app/Main.hs"
      component: "haskell-wingman-nvim:exe:haskell-wingman-nvim"

Steps to reproduce

Edit file, run code action on hole, eg

myid :: a -> a
myid = _

Expected behaviour *

Get suggestions from wingman

Actual behaviour

Do not seem to be getting suggestions from wingman. Here is what I see:

hls

* Notes

I think maybe this is the expected behaviour? It looks like there are instructions for coc.nvim (https://github.com/haskell/haskell-language-server/tree/master/plugins/hls-tactics-plugin#cocnvim) so I guess by default there is more work to do to get wingman support. Has anyone got it working with the built in client and nvim-lspconfig? And thank you for the great project!

jneira commented 3 years ago

@isovector not sure if you are using wingman with nvim to give us some clue about its setup

isovector commented 3 years ago

I don't know about nvim-lsp, but in Coc, the default code action getter is broken with respect to Wingman. Somehow. In coc, the trick is to use the <Plug>(coc-codeaction-selected) operator, and then immediately add an l motion. My guess is that nvim isn't sending precise cursor information to the LSP.

tek commented 3 years ago

I use something like nmap <cr> v<plug>(coc-codeaction-selected)

kedashoe commented 3 years ago

Thank you all for the quick replies. Well, great news, I am a fool and it actually works out of the box with the built in lsp server and nvim-lspconfig! My problem was the project was using ghc-9.0.1. After reading some issues and realizing this might be the case, made a new project to test out in 8.10.7 and got wingman suggestions straight away.

I wonder if it would be worth mentioning it here? coc was great in its day, but seems there is momentum towards the built in lsp (and it seems to be able to support wingman without any additional config needed).

isovector commented 3 years ago

@kedashoe I'd be happy to merge a PR improving the documentation!