Coder Social home page Coder Social logo

Comments (9)

Ptival avatar Ptival commented on July 22, 2024 1

Fixed by:

(add-hook! 'haskell-mode-hook
  (setq lsp-haskell-process-args-hie (list "-d" "-l" "/tmp/hie.log" "-r" (haskell-cabal-find-dir))))

I feel like this could be the default value.

from lsp-haskell.

tonyday567 avatar tonyday567 commented on July 22, 2024 1

Had the same issue.

I also had to clear the .emacs.d/.lsp-session-v1 cache to remove prior incorrect root information.

from lsp-haskell.

michaelpj avatar michaelpj commented on July 22, 2024 1

Looking in lsp-mode, it seems that this issue comes up frequently. Their position seems to be:

  • You should get an interactive choice of root, which gives you the option to pick where the right root is.
  • As far as lsp-mode guessing the root goes, they delegate to projectile which apparently has hooks for configuring that.

So I think we shouldn't implement logic ourselves for this.

from lsp-haskell.

Ptival avatar Ptival commented on July 22, 2024

Note: this was harder than I thought.

Essentially you need to modify lsp-haskell-process-wrapper-function before the Haskell mode starts, so that the command sent to the server is correct.

But the value of lsp-haskell--get-root is . until the Haskell mode has started.

My personal workaround is to have a hook to set lsp-haskell-process-wrapper-function before the Haskell mode starts, defining it as:

(lambda (argv)
  (append argv (list "-r" (haskell-cabal-find-dir default-directory))))

from lsp-haskell.

Ptival avatar Ptival commented on July 22, 2024

Somehow things seem worse now. When I enter a Haskell buffer, lsp-haskell--hie-command seems to be called twice:

  • once from the file that I opened (in which case my workaround works)
  • then, a second time, from my project directory (which is bad: I no longer know which file is being processed)

from lsp-haskell.

Ptival avatar Ptival commented on July 22, 2024

The following repository lets one reproduce the issue:

https://github.com/Ptival/mock-haskell-project-02/tree/7b3e875347bae083ec5975e1b32dfea9373c439d

If you try to open a Haskell file from this repository, HIE will be started in the root directory, rather than in the not-root directory, and thus will fail to figure out which GHC to use and crash.

from lsp-haskell.

Ptival avatar Ptival commented on July 22, 2024

The main issue I see is that LSP runs commands from the projectile project root, but hie-wrapper needs to be ran either from the directory that contains the cabal file, or be given such directory with the -r option.

from lsp-haskell.

alanz avatar alanz commented on July 22, 2024

The behaviour in hie/ghcide/hls changed, it used to detect from the root directory given in the LSP protocol initialisation, but now expects to be in the given directory. Will update.

from lsp-haskell.

FranklinChen avatar FranklinChen commented on July 22, 2024

I'm using hls 0.3.0 and there seems no "-r" option but the following worked for me:

(add-hook 'haskell-mode-hook
          (lambda ()
            (setq lsp-haskell-process-args-hie (list "-d" "-l" "/tmp/hie.log" "--cwd" (haskell-cabal-find-dir)))))

from lsp-haskell.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.