Skip to content

Enable stylish-haskell for ghc-9.10 and ghc-9.12 #4559

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
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
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ jobs:
name: Test hls-stan-plugin
run: cabal test hls-stan-plugin-tests || cabal test hls-stan-plugin-tests

# TODO enable when it supports 9.10
- if: matrix.test && matrix.ghc != '9.10' && matrix.ghc != '9.12'
- if: matrix.test
name: Test hls-stylish-haskell-plugin
run: cabal test hls-stylish-haskell-plugin-tests || cabal test hls-stylish-haskell-plugin-tests

Expand Down
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ packages:
./hls-test-utils


index-state: 2025-04-08T01:30:37Z
index-state: 2025-04-19T07:34:07Z

tests: True
test-show-details: direct
Expand Down
2 changes: 1 addition & 1 deletion docs/support/plugin-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ For example, a plugin to provide a formatter which has itself been abandoned has
| `hls-qualify-imported-names-plugin` | 2 | |
| `hls-ormolu-plugin` | 2 | |
| `hls-rename-plugin` | 2 | |
| `hls-stylish-haskell-plugin` | 2 | 9.10.1, 9.12.2 |
| `hls-stylish-haskell-plugin` | 2 | |
| `hls-overloaded-record-dot-plugin` | 2 | |
| `hls-semantic-tokens-plugin` | 2 | |
| `hls-floskell-plugin` | 3 | 9.10.1, 9.12.2 |
Expand Down
8 changes: 4 additions & 4 deletions haskell-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -1551,14 +1551,14 @@ flag stylishHaskell
manual: True

common stylishHaskell
if flag(stylishHaskell) && (impl(ghc < 9.10) || flag(ignore-plugins-ghc-bounds))
if flag(stylishHaskell)
build-depends: haskell-language-server:hls-stylish-haskell-plugin
cpp-options: -Dhls_stylishHaskell

library hls-stylish-haskell-plugin
import: defaults, pedantic, warnings
-- https://github.com/haskell/stylish-haskell/issues/479
if !(flag(stylishHaskell) && (impl(ghc < 9.10) || flag(ignore-plugins-ghc-bounds)))
if !flag(stylishHaskell)
buildable: False
exposed-modules: Ide.Plugin.StylishHaskell
hs-source-dirs: plugins/hls-stylish-haskell-plugin/src
Expand All @@ -1570,13 +1570,13 @@ library hls-stylish-haskell-plugin
, hls-plugin-api == 2.10.0.0
, lsp-types
, mtl
, stylish-haskell ^>=0.12 || ^>=0.13 || ^>=0.14
, stylish-haskell >=0.12 && <0.16
, text


test-suite hls-stylish-haskell-plugin-tests
import: defaults, pedantic, test-defaults, warnings
if !(flag(stylishHaskell) && (impl(ghc < 9.10) || flag(ignore-plugins-ghc-bounds)))
if !flag(stylishHaskell)
buildable: False
type: exitcode-stdio-1.0
hs-source-dirs: plugins/hls-stylish-haskell-plugin/test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,15 @@ provider recorder ide _token typ contents fp _opts = do
-- If no such file has been found, return default config.
loadConfigFrom :: FilePath -> IO Config
loadConfigFrom file = do
#if MIN_VERSION_stylish_haskell(0,15,0)
let configSearchStrategy = SearchFromDirectory (takeDirectory file)
config <- loadConfig (makeVerbose False) configSearchStrategy
#else
currDir <- getCurrentDirectory
setCurrentDirectory (takeDirectory file)
config <- loadConfig (makeVerbose False) Nothing
setCurrentDirectory currDir
#endif
pure config

-- | Run stylish-haskell on the given text with the given configuration.
Expand Down
Loading