Skip to content

Question: my install of haskell-language-server + coc + vim only partially working #187

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

Closed
fjhheras opened this issue Jul 5, 2020 · 9 comments
Labels
status: needs info Not actionable, because there's missing information type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@fjhheras
Copy link

fjhheras commented Jul 5, 2020

I have a cabal system installed with ghcup. I installed haskell-language-server using cabal v2-run ./install.hs --project-file install/shake.project hls

Installation was sucessful, but it is not detecting the installed packages in my cabal projects, among other problems. The hlint I installed with cabal install hlint detects the cabal installed packages with no problem.

To solve this, I tried to create a hie.yaml file with the following contents: radle: {cabal: {component: "lib:haskell-language-server"}}, but when running haskell-language-server I receive this error:

  Failed to parse result of calling cabal
  
  cabal: Internal error in target matching. It should always be possible to find
  a syntax that's sufficiently qualified to give an unambiguous match. However
  when matching 'lib:haskell-language-server' we found
  lib:haskell-language-server (unknown-component) which does not have an
  unambiguous syntax. The possible syntax and the targets they match are as
  follows:
  'lib:haskell-language-server' which matches lib:haskell-language-server
  (unknown-component), :pkg:lib:lib:lib:file:haskell-language-server
  (unknown-file)

Other things (maybe unrelated) that I was not able to configure with vim+coc were:

  • Linting with hlint
  • Go to definition
@fendor
Copy link
Collaborator

fendor commented Jul 5, 2020

Hi, thank you for your bug report!
Can you explain your project setup? You will, for example, have better results if you use hie on a cabal or stack project.

Your hie.yaml is meant to explain to hls how your project is loaded. In this case you should describe which files belong to which component. In your given hie.yaml file, you define that any files in this project belong to the component lib:haskell-language-server, the library of the project haskell-language-server.
Assuming you are using a cabal project, your component is lib:<name of the cabal file>.
Here is a rough explanation of this syntax: https://cabal.readthedocs.io/en/latest/cabal-commands.html#cabal-v2-build

@fjhheras
Copy link
Author

fjhheras commented Jul 5, 2020

I am a Haskell beginner, and this is a repo where I am going through the exercises in a book:

https://github.com/fjhheras/haskellbook_exercises

My intention was to create a common cabal project for all chapters, and then call each exrcise file individually using cabal exec -- runghc chapter17/identity.hs for example (scripts of previous chapters are not working with this new system yet). Therefore I did not configure anything in the cabal file, except for dependencies.

@fendor
Copy link
Collaborator

fendor commented Jul 5, 2020

That projects looks complicated to configure correctly... We will need a full cabal project, e.g. each file must be possible to open with cabal. If you use a big cabal project, you will probably need a cabal.project file.
We can try too help you set up hls for it, once you managed to create a cabal project for each chapter.

@Avi-D-coder
Copy link
Collaborator

Once you have a cabal.project, https://github.com/Avi-D-coder/implicit-hie should be able to generate a correct hie.yaml file.

What's your motive for wanting all the chapters to be in one cabal project?
Why not just treat each chapter as a self-contained cabal package? If cabal build succeeds in a chapter, just run gen-hie > hie.yaml in each chapter.

@fjhheras
Copy link
Author

fjhheras commented Jul 5, 2020

Hi, thank you for your help. I changed the structure so now I have a cabal project for each chapter. The way I did it needs 6 extra lines for each executable (e.g. https://github.com/fjhheras/haskellbook_exercises/blob/master/chapter17/chapter17.cabal), I wonder if there is a better way

With the new structure, a haskell-language-server installation works, but still does not recognise the cabal project dependencies (In comparison, a haskell-ide-engine installation now works perfectly, and even linting is working).

For haskell-language-server to work, as @Avi-D-coder proposed, I installed gen-hie and generated the following hie.yaml file:

cradle:
  cabal:
    - path: "./identity.hs"
      component: "chapter17:exe:identity"

    - path: "./listapplicative.hs"
      component: "chapter17:exe:listapplicative"

    - path: "./lookups.hs"
      component: "chapter17:exe:lookups"

    - path: "./ziplist.hs"
      component: "chapter17:exe:ziplist"

Once placed, haskell-language-server-wrapper is giving me the following errors:

Program error: Failed to load interface for ‘Main’no unit id matching ‘main’ was found

and

  Multi Cradle: No prefixes matched
  pwd: /home/user/Documents/haskell/haskellbook_exercises/chapter17
  filepath: /home/user/Documents/haskell/haskellbook_exercises/chapter17/Setup.hs
  prefixes:
  ("./identity.hs",Cabal {component = Just "chapter17:exe:identity"})
  ("./listapplicative.hs",Cabal {component = Just "chapter17:exe:listapplicative"})
  ("./lookups.hs",Cabal {component = Just "chapter17:exe:lookups"})
  ("./ziplist.hs",Cabal {component = Just "chapter17:exe:ziplist"})
Files that failed:
[INFO] finish: User TypeCheck (took 0.05s)
 * /home/user/Documents/haskell/haskellbook_exercises/chapter17/Setup.hs
 * /home/user/Documents/haskell/haskellbook_exercises/chapter17/ziplist.hs

@jneira jneira added status: needs repro type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Jul 6, 2020
@oblitum
Copy link
Contributor

oblitum commented Jul 19, 2020

@fjhheras have you checked coc wiki about how to install HLS? I'm using binaries provided by @bubba without issues.

@jneira
Copy link
Member

jneira commented Sep 23, 2020

@fjhheras Setup.hs is known to fail and ziplist.hs seems to has something different to others (that work). It seems it fails due to #204 so adding a module Main where header would workaround it.

@jneira jneira added the status: needs info Not actionable, because there's missing information label Sep 23, 2020
@jneira jneira removed the status: needs info Not actionable, because there's missing information label Oct 21, 2020
@jneira
Copy link
Member

jneira commented Oct 21, 2020

  • hlint support is not available (although it will be soon)
  • afaik the errors are covered by other issues

So i would close it if you agree, feel free to reopen

@jneira jneira added status: needs info Not actionable, because there's missing information editor: vim/neovim labels Oct 21, 2020
@fjhheras
Copy link
Author

OK, no worries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs info Not actionable, because there's missing information type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

No branches or pull requests

5 participants