cabal-version: 2.4
name:          hls-hlint-plugin
version:       1.0.4.0
synopsis:      Hlint integration plugin with Haskell Language Server
description:
  Please see the README on GitHub at <https://github.com/haskell/haskell-language-server#readme>

license:       Apache-2.0
license-file:  LICENSE
author:        The Haskell IDE Team
maintainer:    atreyu.bbb@gmail.com
copyright:     The Haskell IDE Team
category:      Development
build-type:    Simple
extra-source-files:
  LICENSE
  test/testdata/**/*.yaml
  -- this one is not matched by the previous glob
  test/testdata/ignore/.hlint.yaml
  test/testdata/**/*.hs
  test/testdata/**/*.h

flag pedantic
  description: Enable -Werror
  default:     False
  manual:      True

flag ghc-lib
  default:     False
  manual:      True
  description:
    Force dependency on ghc-lib-parser even if GHC API in the ghc package is supported

flag hlint33
  default:     True
  manual:      False
  description:
    Hlint-3.3 doesn't support versions ghc-lib < 9.0.1 nor ghc <= 8.6, so we can use hlint-3.2 for backwards compat
    This flag can be removed when all dependencies support ghc-lib-9.0.* and we drop support for ghc-8.6

library
  exposed-modules:    Ide.Plugin.Hlint
  hs-source-dirs:     src
  build-depends:
    , aeson
    , apply-refact          >=0.9.3.0
    , base                  >=4.12    && <5
    , binary
    , bytestring
    , containers
    , data-default
    , deepseq
    , Diff                  ^>=0.4.0
    , directory
    , extra
    , filepath
    , ghc-exactprint        >=0.6.3.4
    , ghcide                ^>=1.7
    , hashable
    , hlint
    , hls-plugin-api        ^>=1.4
    , hslogger
    , lens
    , lsp
    , refact
    , regex-tdfa
    , stm
    , temporary
    , text
    , transformers
    , unordered-containers
    -- can be removed if https://github.com/ndmitchell/hlint/pull/1325#issue-1077062712 is merged
    -- and https://github.com/haskell/haskell-language-server/pull/2464#issue-1077133441 is updated
    -- accordingly
    , ghc-lib-parser-ex

  if (flag(hlint33))
    -- This mirrors the logic in hlint.cabal for hlint-3.3
    -- https://github.com/ndmitchell/hlint/blob/d3576de4529d8df6cca5a345f5b7e04474ff7bff/hlint.cabal#L79-L88
    -- so we can make sure that we do the same thing as hlint
    build-depends: hlint ^>=3.3
    if (!flag(ghc-lib) && impl(ghc >=9.0.1) && impl(ghc <9.1.0))
      build-depends: ghc ==9.0.*
    else
      build-depends:
        , ghc
        , ghc-lib            ^>=9.0
        , ghc-lib-parser-ex  ^>=9.0

      cpp-options:   -DHLINT_ON_GHC_LIB

  else
    -- This mirrors the logic in hlint.cabal for hlint-3.2
    -- https://github.com/ndmitchell/hlint/blob/c7354e473c7d09213c8adc3dc94bf50a6eb4a42d/hlint.cabal#L79-L88
    build-depends: hlint ^>=3.2
    if (!flag(ghc-lib) && impl(ghc >=8.10.1) && impl(ghc < 8.11.0))
      build-depends: ghc >=8.10 && <9.0
    else
      build-depends:
        , ghc
        , ghc-lib            ^>=8.10.7.20210828
        , ghc-lib-parser-ex  ^>=8.10

      cpp-options:   -DHLINT_ON_GHC_LIB

  ghc-options:
    -Wall -Wredundant-constraints -Wno-name-shadowing
    -Wno-unticked-promoted-constructors

  if flag(pedantic)
    ghc-options: -Werror

  default-language:   Haskell2010
  default-extensions:
    DataKinds
    TypeOperators

test-suite tests
  type:             exitcode-stdio-1.0
  default-language: Haskell2010
  hs-source-dirs:   test
  main-is:          Main.hs
  ghc-options:      -threaded -rtsopts -with-rtsopts=-N
  build-depends:
      aeson
    , base
    , containers
    , filepath
    , hls-hlint-plugin
    , hls-plugin-api
    , hls-test-utils      ^>=1.3
    , lens
    , lsp-types
    , text