haskell / haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Apache License 2.0
2.71k stars 368 forks source link

Allow project-local configuration #3479

Closed turion closed 1 year ago

turion commented 1 year ago

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

I have some projects formatted with fourmolu and others with ormolu. I'd like to set fourmolu as default formatter, and use ormolu in some specific projects.

Describe the solution you'd like

I'd like to be able to add a file (could be part of hie.yaml) to a project where I can override HLS settings for only this project. When HLS starts in that project, it should read, for example, that I want a different formatter in this project.

Additional context

I use VSCodium.

fendor commented 1 year ago

Hi, thank you for your bug report!

You can achieve that by writing a local settings.json file for vscode, by creating the file .vscode/settings.json in the root of your project with the contents:

{
    "haskell.formattingProvider": "fourmolu"
}

You can specify all options the vscode plugin supports in there.

turion commented 1 year ago

Thanks, that works! I was surprised the file really can reside in my/project/.vscode/settings.json.

~In my case, I had to add it to .vscodium/settings.json, and I had to add other options as well such as "haskell.manageHLS": "PATH".~

fendor commented 1 year ago

I think vscodium can read both.

In any way, why do you need "haskell.manageHLS"? Did you want to override it, or do you think it is necessary in some way?

turion commented 1 year ago

Sorry, both of by assessments about .vscodium and the extra settings were wrong. I got an error message and thought that this was the cause. But in fact the error was that after startup, there is a window of ~10 seconds where the formatter doesn't work yet.

In any way, why do you need "haskell.manageHLS"? Did you want to override it, or do you think it is necessary in some way?

I installed HLS via NixOS and wanted it to find the HLS on the path. It's part of my global settings. I thought that maybe it didn't merge the configs correctly, and I had to repeat this option again. But I was wrong.