visortelle / haskell-spotlight

VSCode extension for Haskell
https://marketplace.visualstudio.com/items?itemName=visortelle.haskell-spotlight
MIT License
108 stars 3 forks source link

Using Haskell spotlight in a dev container #20

Closed kushagarr closed 9 months ago

kushagarr commented 9 months ago

Is your feature request related to a problem? Please describe.

I mostly use dev containers for development of any sort. Lately I have been meaning to learn and use Haskell for my personal utilities and scripts (so that I can be better in this language and gain confidence) I came across this tool but this does not work inside a dev container (I get a blank screen)

Describe the solution you'd like

I would like to use this extension for my Haskell development inside a dev container, I don't know if it is even possible.

otherwise a vm is the only way out for me.

visortelle commented 9 months ago

Hi @kushagarr.

I suppose you're talking about these dev containers: https://code.visualstudio.com/docs/devcontainers/containers

Do you see any errors in the extension logs?

I'm not familiar with dev containers. If you can provide a step-by-step list of actions I should do to reproduce it, I can take a look.

Is it the only VSCode extension you have problems with inside your dev container?


A bit offtopic: if you use dev containers for reproducible dev environment, probably it worth take a look at Nix, as on more universal and performant solution for this problem. There are projects like https://devenv.sh/basics/ that may simplify its setup.

kushagarr commented 9 months ago

image

This is what i get to see when I open it inside a dev container.

I suppose you're talking about these dev containers: https://code.visualstudio.com/docs/devcontainers/containers

Yes, they are just containers (docker containers) but using vs code you can use them as your development environment. Helps keep my host system clean, and good for experimentation with new tools and languages.

So the steps to reproduce would be something like this

  1. You must have docker installed on your system and Remote Development vs code extension installed in your vs code.

  2. Create a new empty folder and create a .devcontainer folder in it.

  3. cd inside .devcontainer folder and create 3 empty files with following names devcontainer.json, docker-compose.yml, Dockerfile

  4. paste the following content in Dockerfile

     FROM debian
     RUN rm /bin/sh && ln -s /bin/bash /bin/sh
    
     RUN apt-get update -y \
     && apt-get install -y pkg-config \
     build-essential \
     libpq-dev \
     libsasl2-dev \
     libecpg-dev \
     git \
     curl \
     wget \
     unzip \
     ca-certificates \
     procps \
     htop \
     && rm -rf /var/lib/apt/lists/*
    
    ENV LANG=C.UTF-8 \
    LC_ALL=C.UTF-8
    
    RUN apt-get update \
    && apt-get install -y libgmp-dev \
    zlib1g-dev \
    libtinfo-dev
    
    RUN curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
    RUN source ~/.bashrc && ghcup install hls
    
    CMD ["/bin/bash"]
  5. Paste the following code in docker-compose.yml

    version: '3.9'
    
    services:
      brick_learn:
        build: 
          context: ..
          dockerfile: .devcontainer/Dockerfile
    
        volumes:
          - ..:/brick_learn
    
        command: /bin/sh -c "while sleep 1000; do :; done"
  6. Paste the following code in devcontainer.json

    {
      "name" : "Brick Devcontainer",
      "dockerComposeFile" : [
          "docker-compose.yml"
      ],
    
      "service": "brick_learn",
      "workspaceFolder": "/brick_learn",
    
      "customizations": {
          "vscode": {
              "extensions": [
                  "haskell.haskell"
              ]
          }
      }
    }
  7. Once you have these files set up inside .devcontainer, cd .. to parent folder and start vscode with code ., You should see a pop on bottom right asking you to open this in a devcontainer. Click on it and your development environment will get ready in a few mins.

After that I think you can install the Haskell Spotlight vs code extension and try to open it with Alt + h and take it from there. I Hope you find this helpful.

visortelle commented 9 months ago

@kushagarr thank you for the provided instructions.

I just published v0.0.4. Let me know if you still have any issues.

Screenshot 2023-12-24 at 7 07 36 PM
kushagarr commented 9 months ago

Thanks @visortelle , it works wonderfully well. Thank you for your work.