Skip to content

Enable fourmolu and ormolu for GHC 9.12 #4554

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

Merged
merged 1 commit into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ jobs:
name: Test hls-stylish-haskell-plugin
run: cabal test hls-stylish-haskell-plugin-tests || cabal test hls-stylish-haskell-plugin-tests

- if: matrix.test && matrix.ghc != '9.12'
- if: matrix.test
name: Test hls-ormolu-plugin
run: cabal test hls-ormolu-plugin-tests || cabal test hls-ormolu-plugin-tests

- if: matrix.test && matrix.ghc != '9.12'
- if: matrix.test
name: Test hls-fourmolu-plugin
run: cabal test hls-fourmolu-plugin-tests || cabal test hls-fourmolu-plugin-tests

Expand Down
16 changes: 7 additions & 9 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,13 @@ constraints:
bitvec -simd,


if impl(ghc >= 9.8.4) && impl(ghc < 9.8.5)
-- By depending on ghc-lib-parser and ghc, we are encountering
-- a constraint conflict, ghc-9.8.4 comes with `filepath-1.4.301.0`,
-- and `ghc-lib-parser-9.8.4.20241130` specifies `filepath >=1.5 && < 1.6.
-- See https://github.com/digital-asset/ghc-lib/issues/572 for details.
allow-older:
ghc-lib-parser:filepath
constraints:
ghc-lib-parser==9.8.4.20241130
-- Some of the formatters need the latest Cabal-syntax version,
-- but 'cabal-install-parsers-0.6.2' only has Cabal-syntax (>=3.12.0.0 && <3.13).
-- So, we relax the upper bounds here.
-- fourmolu-0.18.0 and ormolu-0.8 depend on Cabal-syntax == 3.14.*, while
-- cabal-add depends on cabal-install-parsers.
allow-newer:
cabal-install-parsers:Cabal-syntax,

if impl(ghc >= 9.11)
benchmarks: False
Expand Down
4 changes: 2 additions & 2 deletions docs/support/plugin-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ For example, a plugin to provide a formatter which has itself been abandoned has
| `hls-eval-plugin` | 2 | |
| `hls-explicit-fixity-plugin` | 2 | |
| `hls-explicit-record-fields-plugin` | 2 | |
| `hls-fourmolu-plugin` | 2 | 9.12.2 |
| `hls-fourmolu-plugin` | 2 | |
| `hls-gadt-plugin` | 2 | 9.12.2 |
| `hls-hlint-plugin` | 2 | 9.10.1, 9.12.2 |
| `hls-module-name-plugin` | 2 | |
| `hls-notes-plugin` | 2 | |
| `hls-qualify-imported-names-plugin` | 2 | |
| `hls-ormolu-plugin` | 2 | 9.12.2 |
| `hls-ormolu-plugin` | 2 | |
| `hls-rename-plugin` | 2 | |
| `hls-stylish-haskell-plugin` | 2 | 9.10.1, 9.12.2 |
| `hls-overloaded-record-dot-plugin` | 2 | |
Expand Down
20 changes: 10 additions & 10 deletions haskell-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -1442,19 +1442,19 @@ flag fourmolu
manual: True

common fourmolu
if flag(fourmolu) && (impl(ghc < 9.11) || flag(ignore-plugins-ghc-bounds))
if flag(fourmolu)
build-depends: haskell-language-server:hls-fourmolu-plugin
cpp-options: -Dhls_fourmolu

library hls-fourmolu-plugin
import: defaults, pedantic, warnings
if !flag(fourmolu) || (impl(ghc > 9.11) && !flag(ignore-plugins-ghc-bounds))
if !flag(fourmolu)
buildable: False
exposed-modules: Ide.Plugin.Fourmolu
hs-source-dirs: plugins/hls-fourmolu-plugin/src
build-depends:
, filepath
, fourmolu ^>= 0.14 || ^>= 0.15 || ^>= 0.16
, fourmolu ^>= 0.14 || ^>= 0.15 || ^>= 0.16 || ^>=0.17 || ^>=0.18
, ghc-boot-th
, ghcide == 2.10.0.0
, hls-plugin-api == 2.10.0.0
Expand All @@ -1468,7 +1468,7 @@ library hls-fourmolu-plugin

test-suite hls-fourmolu-plugin-tests
import: defaults, pedantic, test-defaults, warnings
if !flag(fourmolu) || (impl(ghc > 9.11) && !flag(ignore-plugins-ghc-bounds))
if !flag(fourmolu)
buildable: False
type: exitcode-stdio-1.0
hs-source-dirs: plugins/hls-fourmolu-plugin/test
Expand Down Expand Up @@ -1496,13 +1496,13 @@ flag ormolu
manual: True

common ormolu
if flag(ormolu) && (impl(ghc < 9.11) || flag(ignore-plugins-ghc-bounds))
if flag(ormolu)
build-depends: haskell-language-server:hls-ormolu-plugin
cpp-options: -Dhls_ormolu

library hls-ormolu-plugin
import: defaults, pedantic, warnings
if !flag(ormolu) || (impl(ghc > 9.11) && !flag(ignore-plugins-ghc-bounds))
if !flag(ormolu)
buildable: False
exposed-modules: Ide.Plugin.Ormolu
hs-source-dirs: plugins/hls-ormolu-plugin/src
Expand All @@ -1515,14 +1515,14 @@ library hls-ormolu-plugin
, lsp
, mtl
, process-extras >= 0.7.1
, ormolu ^>=0.1.2 || ^>= 0.2 || ^>= 0.3 || ^>= 0.5 || ^>= 0.6 || ^>= 0.7
, ormolu ^>=0.5.3 || ^>= 0.6 || ^>= 0.7 || ^>=0.8
, text
, transformers


test-suite hls-ormolu-plugin-tests
import: defaults, pedantic, test-defaults, warnings
if !flag(ormolu) || (impl(ghc > 9.11) && !flag(ignore-plugins-ghc-bounds))
if !flag(ormolu)
buildable: False
type: exitcode-stdio-1.0
hs-source-dirs: plugins/hls-ormolu-plugin/test
Expand Down Expand Up @@ -2009,9 +2009,9 @@ test-suite func-test
-- formatters
if flag(floskell) && (impl(ghc < 9.10) || flag(ignore-plugins-ghc-bounds))
cpp-options: -Dhls_floskell
if flag(fourmolu) && (impl(ghc < 9.11) || flag(ignore-plugins-ghc-bounds))
if flag(fourmolu)
cpp-options: -Dhls_fourmolu
if flag(ormolu) && (impl(ghc < 9.11) || flag(ignore-plugins-ghc-bounds))
if flag(ormolu)
cpp-options: -Dhls_ormolu

test-suite wrapper-test
Expand Down
11 changes: 11 additions & 0 deletions test/testdata/schema/ghc912/default-config.golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
"explicit-fixity": {
"globalOn": true
},
"fourmolu": {
"config": {
"external": false,
"path": "fourmolu"
}
},
"ghcide-code-actions-bindings": {
"globalOn": true
},
Expand Down Expand Up @@ -89,6 +95,11 @@
"moduleName": {
"globalOn": true
},
"ormolu": {
"config": {
"external": false
}
},
"overloaded-record-dot": {
"globalOn": true
},
Expand Down
18 changes: 18 additions & 0 deletions test/testdata/schema/ghc912/vscode-extension-schema.golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@
"scope": "resource",
"type": "boolean"
},
"haskell.plugin.fourmolu.config.external": {
"default": false,
"markdownDescription": "Call out to an external \"fourmolu\" executable, rather than using the bundled library.",
"scope": "resource",
"type": "boolean"
},
"haskell.plugin.fourmolu.config.path": {
"default": "fourmolu",
"markdownDescription": "Set path to executable (for \"external\" mode).",
"scope": "resource",
"type": "string"
},
"haskell.plugin.ghcide-code-actions-bindings.globalOn": {
"default": true,
"description": "Enables ghcide-code-actions-bindings plugin",
Expand Down Expand Up @@ -213,6 +225,12 @@
"scope": "resource",
"type": "boolean"
},
"haskell.plugin.ormolu.config.external": {
"default": false,
"markdownDescription": "Call out to an external \"ormolu\" executable, rather than using the bundled library",
"scope": "resource",
"type": "boolean"
},
"haskell.plugin.overloaded-record-dot.globalOn": {
"default": true,
"description": "Enables overloaded-record-dot plugin",
Expand Down
Loading