haskell / haskell/vscode-haskell

Support projects in subfolders

Open
#1,016 5 comments 2 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
597
Forks
98
PR merge metrics
No merged PRs in 30d

Description

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

I'm currently working on a project of which a Haskell project is only a small part. When trying to open the root folder in VSCode however, the Haskell extension does not pick up on the Stack project in the Haskell-specific subfolder.

**Describe the solution you'd like**

I would like the extension to select the Haskell project folder by looking for stack.yaml/*.cabal/whatever files, instead of just naively picking the opened folder as Haskell project folder.

This is also what Kate does, its LSP client default configuration has the following line for HLS:
`"rootIndicationFileNames": ["*.cabal", "stack.yaml", "cabal.project", "package.yaml"]`

**Describe alternatives you've considered**

- Just open the Haskell project in a separate VSCode window, and have two windows open (kind of annoying imo)
- Allow creating a file that instructs HLS where to actually find the project (a bit hacky, but would be a decent workaround)
- Open both toplevel and projects in a multi-root workspace

**Additional context**

Consider the following folder layout:
```
toplevel
| - project
| | - stack.yaml, project.cabal, src/, all other parts of a Haskell project
| - otherStuff
```

In my example, I open toplevel in VSCode (instead of project), but want HLS to use project as root folder.

So if I open the file `project/src/Main.hs`, I want HLS to start with `Directory: toplevel/project`, not `Directory: toplevel` which causes it to miss the stack/cabal files that allow it to know what dependencies I am using etc.

Contributor guide

Open the contributing guide

Research direction

No source files, tests, or entry points are named. Reproduce the described toplevel/project layout and open project/src/Main.hs, then trace how the extension chooses the HLS root. Done means the HLS directory is toplevel/project when stack.yaml, a .cabal file, cabal.project, or package.yaml is found there.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell, typescript, vscode
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.