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

add support for haskell-language-server 0.3.0.0 #716

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

ibizaman
Copy link
Contributor

@ibizaman ibizaman commented Jan 10, 2021

Adds an overlay for adding the haskell-language-server and its wrapper, activated by setting the argument hlsSupport to true in the reflex-platform.project function.

I got most of the boilerplate code from the (now removed) haskell-ide-engine support. The complicated part was finding the right set of dependencies needed to build hlp. I couldn't use the hlp nix expression available in the recent <nixpkgs> because I needed hlp to be compiled with the ghc version provided by reflex-platform, otherwise hlp failed on modules with template haskell code because of incompatible dynamic libraries.

I chose the package versions by first using all the packages in the source of haskell-language-server then by reaching to hackage for the rest and trying to pick the latest version of the packages.

{ system ? builtins.currentSystem
, reflex-platform ? fetchGit {
    url = "https://github.com/ibizaman/reflex-platform.git";
    ref = "haskell-language-server";
  }
}:
(import reflex-platform {
  inherit system;
  hlsSupport = true;
}).project (
  # ...
)

The binaries available in nix-shell:

$ nix-shell
[nix-shell]$ haskell-language-server-wrapper --version
haskell-language-server version: 0.8.0.0 (GHC: 8.6.5) (PATH: /nix/store/3jmpjn810z7japkc9r6h0nws5gj4g09z-haskell-language-server-0.8.0.0/bin/haskell-language-server-wrapper)

Also, I put up a cachix cache called ibizaman.

I ran the wrapper inside my project that uses template haskell and it worked:

$ haskell-language-server-wrapper

[...]

Completed (10 files worked, 0 files failed)

See the github action result for this commit.

Would you be interested in merging this, I’m happy to add any test and doc required.

@rubenmoor
Copy link

I am testing this with the obelisk example (from obelisk init) with the following as my default.nix and I can confirm that it works.

Having an IDE with reflex-platform is crucial. Your work is hugely appreciated!

{ system ? builtins.currentSystem
, unstable ? import <nixos-unstable> {}
, obelisk ? import ./.obelisk/impl {
  # pointing to local clone of ibizaman/reflex-platform:haskell-language-server
  reflex-platform-func = args@{ ... }: import ../reflex-platform (args // {
      inherit system;
      hlsSupport = true;
    });
    inherit system;
    iosSdkVersion = "13.2";

    # You must accept the Android Software Development Kit License Agreement at
    # https://developer.android.com/studio/terms in order to build Android apps.
    # Uncomment and set this to `true` to indicate your acceptance:
    # config.android_sdk.accept_license = false;

    # In order to use Let's Encrypt for HTTPS deployments you must accept
    # their terms of service at https://letsencrypt.org/repository/.
    # Uncomment and set this to `true` to indicate your acceptance:
    # terms.security.acme.acceptTerms = false;
  }
}:
with obelisk;
project ./. ({ ... }: {
  android.applicationId = "systems.obsidian.obelisk.examples.minimal";
  android.displayName = "Obelisk Minimal Example";
  ios.bundleIdentifier = "systems.obsidian.obelisk.examples.minimal";
  ios.bundleName = "Obelisk Minimal Example";
  # shellToolOverrides = ghc: super: { haskell-language-server = unstable.haskell-language-server; };
})

@ibizaman ibizaman force-pushed the haskell-language-server branch 2 times, most recently from c2f1d1e to 04ba213 Compare May 13, 2021 17:06
srghma added a commit to srghma/reflex-platform that referenced this pull request Aug 21, 2021
@srghma
Copy link

srghma commented Aug 21, 2021

@ibizaman could you help

I have merged your changes on top of current master (actually it doesnt matter, I have tried also v7.1.0 and v7.0.0), then did

./scripts/hack-on haskell-overlays/reflex-packages/dep/universe
./scripts/hack-on haskell-overlays/reflex-packages/dep/dependent-sum-universe-orphans
./scripts/hack-on haskell-overlays/reflex-packages/dep/reflex
./scripts/hack-on haskell-overlays/reflex-packages/dep/cabal-macosx
./scripts/hack-on haskell-overlays/reflex-packages/dep/jsaddle-dom
./scripts/hack-on haskell-overlays/reflex-packages/dep/reflex-dom
./scripts/hack-on haskell-overlays/reflex-packages/dep/ghcjs-dom
./scripts/hack-on haskell-overlays/reflex-packages/dep/dependent-monoidal-map
./scripts/hack-on haskell-overlays/reflex-packages/dep/reflex-todomvc
./scripts/hack-on haskell-overlays/reflex-packages/dep/gargoyle
./scripts/hack-on haskell-overlays/reflex-packages/dep/reflex-aeson-orphans
./scripts/hack-on haskell-overlays/reflex-packages/dep/jsaddle
./scripts/hack-on haskell-overlays/reflex-packages/dep/patch
./try-reflex
code .

it prints info

No cradle found for examples/helloDom.hs. Proceeding with implicit cradle. You should ignore this message, unless you see a 'Multi Cradle: No prefixes matched' error.

it works at some files, but not in others

e.g. in haskell-overlays/reflex-packages/dep/reflex-dom/reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs I have two errors

Ambiguous module name ‘GHCJS.DOM.Document’:
  it is bound as JSDOM.Generated.Document by a reexport in package jsaddle-dom-0.9.4.1
  it is bound as GHCJS.DOM.Document by package ghcjs-dom-0.9.4.0not found

Q: what this error means?

it's because ghcjs-base is not enabled in haskell-overlays/reflex-packages/dep/reflex-dom/reflex-dom-core/reflex-dom-core.cabal?

2021-08-21-05pm-16-38-screenshot

Could not load module ‘Foreign.JavaScript.Internal.Utils’
it is a hidden module in the package ‘reflex-dom-core-0.6.2.0’not found

related code

  if impl(ghcjs)
    hs-source-dirs: src-ghcjs
    build-depends:
      ghcjs-base,
      hashable >= 1.2 && < 1.4
  else
    hs-source-dirs: src-ghc
    if !os(windows)
      build-depends: unix == 2.7.*

Q: how to tell haskell-language-server to use src-ghc or src-ghcjs dir?


all relevant images https://imgur.com/a/i20PGnY

logs haskellvscode.log

@srghma
Copy link

srghma commented Aug 21, 2021

I also have tried with

  tryReflexShell = pinBuildInputs ("shell-" + system) (tryReflexPackages ++
    (
      let
        inherit (nixpkgs) callPackage fetchFromGitHub mkShell;
        easy-hls-src = fetchFromGitHub {
          owner  = "jkachmar";
          repo   = "easy-hls-nix";
          rev    = "6cb50f04e3a61b1ec258c6849df84dae9dfd763f";
          sha256 = "1rvi6067nw64dka8kksl7f34pwkq7wx7pnhnz3y261fw9z5j4ndp";
        };
        easy-hls = callPackage easy-hls-src {
          ghcVersions = [ "8.6.5" ];
        };
      in
        [easy-hls]
    )
  );

1.3.0 instead of 0.8 in this commit. Same warnings

2021-08-21-06pm-11-57-screenshot

logs haskellvscode.log

@srghma
Copy link

srghma commented Aug 21, 2021

I also see other error

Module ‘Data.GADT.Compare’ does not export ‘(:~:)(..)’

I think what is happening is that hie sees

flag use-template-haskell
  description: Use template haskell to generate lenses
  default: True
  manual: True

and it see default: True, but chooses not to use it, but use both False and True and stumbles (I think) on a legacy code

2021-08-21-06pm-28-56-screenshot

@Ericson2314
Copy link
Member

What confuses me about this sort of thing is that there is no requirement that ones project and HLS be built with at all similar package sets, right? Wouldn't it be better to just make sure HLS builds completely separately?

@ibizaman
Copy link
Contributor Author

@Ericson2314 I agree and I don’t think this PR introduces this. It defines the dependencies for HLP through the override but those do not trickle to the rest. At least that was not my intention.

I’ll try to get back to the PR but see no point updating it forever if there is no intent to merge it. Which I would totally understand if the devs don’t want to, it’s quite a huge project to embed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants