cabal-version:      2.2
category:           Development
name:               haskell-language-server
version:            0.9.0.0
synopsis:           LSP server for GHC
description:
  Please see the README on GitHub at <https://github.com/haskell/haskell-language-server#readme>

homepage:           https://github.com/haskell/haskell-language-server#readme
bug-reports:        https://github.com/haskell/haskell-language-server/issues
author:             The Haskell IDE Team
maintainer:         alan.zimm@gmail.com
copyright:          The Haskell IDE Team
license:            Apache-2.0
license-file:       LICENSE
build-type:         Simple
tested-with:        GHC == 8.6.4 || == 8.6.5 || == 8.8.2 || == 8.8.3 || == 8.8.4 || == 8.10.1 || == 8.10.2 || == 8.10.3
extra-source-files:
  README.md
  ChangeLog.md
  include/ghc-api-version.h

flag agpl
  description: Enable AGPL dependencies
  default:     True
  manual:      True

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

source-repository head
  type:     git
  location: https://github.com/haskell/haskell-language-server

common agpl
  if flag(agpl)
    cpp-options: -DAGPL

common common-deps
  build-depends:
    , base       >=4.12 && <5
    , directory
    , extra
    , filepath
    , text

library
  import:           agpl, common-deps
  exposed-modules:
    Ide.Arguments
    Ide.Main
    Ide.Version

  other-modules:    Paths_haskell_language_server
  autogen-modules:  Paths_haskell_language_server
  hs-source-dirs:   src
  build-depends:
    , containers
    , data-default
    , ghc
    , ghcide                >=0.7
    , gitrev
    , haskell-lsp           ^>=0.23
    , hls-plugin-api        >=0.6
    , hslogger
    , optparse-applicative
    , optparse-simple
    , process
    , shake
    , unordered-containers

  ghc-options:      -Wall -Wredundant-constraints -Wno-name-shadowing

  if flag(pedantic)
    ghc-options: -Werror

  default-language: Haskell2010

-- Plugin flags are designed for 'cabal install haskell-language-server':
-- - Packaged plugins should be manual:False
-- - Non packaged plugins and bulk flags should be manual:True
-- - Bulk flags should be default:False
-- - Individual flags should be default:True

flag all-plugins
  description: Enable all non formatter plugins
  default:     False
  manual:      True

flag all-formatters
  description: Enable all fomatters
  default:     False
  manual:      True

flag class
  description: Enable class plugin
  default:     True
  manual:      False

flag haddockComments
  description: Enable haddockComments plugin
  default:     True
  manual:      False

flag eval
  description: Enable eval plugin
  default:     True
  manual:      False

flag importLens
  description: Enable importLens plugin
  default:     True
  manual:      False

flag retrie
  description: Enable retrie plugin
  default:     True
  manual:      False

flag tactic
  description: Enable tactic plugin
  default:     True
  manual:      False

flag hlint
  description: Enable hlint plugin
  default:     True
  manual:      False

flag moduleName
  description: Enable moduleName plugin
  default:     True
  manual:      True

flag pragmas
  description: Enable pragmas plugin
  default:     True
  manual:      True

flag splice
  description: Enable splice plugin
  default:     True
  manual:      False

-- formatters

flag floskell
  description: Enable floskell plugin
  default:     True
  manual:      True

flag fourmolu
  description: Enable fourmolu plugin
  default:     True
  manual:      True

flag ormolu
  description: Enable ormolu plugin
  default:     True
  manual:      True

flag stylishHaskell
  description: Enable stylishHaskell plugin
  default:     True
  manual:      True

flag brittany
  description: Enable brittany plugin
  default:     True
  manual:      True

common example-plugins
  hs-source-dirs: plugins/default/src
  other-modules: Ide.Plugin.Example,
                 Ide.Plugin.Example2

common class
  if flag(class) || flag(all-plugins)
    build-depends: hls-class-plugin
    cpp-options: -Dclass

common haddockComments
  if flag(haddockComments) || flag(all-plugins)
    build-depends: hls-haddock-comments-plugin
    cpp-options: -DhaddockComments

common eval
  if flag(eval) || flag(all-plugins)
    build-depends: hls-eval-plugin
    cpp-options: -Deval

common importLens
  if flag(importLens) || flag(all-plugins)
    build-depends: hls-explicit-imports-plugin
    cpp-options: -DimportLens

common retrie
  if flag(retrie) || flag(all-plugins)
    build-depends: hls-retrie-plugin
    cpp-options: -Dretrie

common tactic
  if flag(tactic) || flag(all-plugins)
    build-depends: hls-tactics-plugin
    cpp-options: -Dtactic

common hlint
  if flag(hlint) || flag(all-plugins)
    build-depends: hls-hlint-plugin
    cpp-options: -Dhlint

common moduleName
  if flag(moduleName) || flag(all-plugins)
    hs-source-dirs: plugins/default/src
    other-modules: Ide.Plugin.ModuleName
    cpp-options: -DmoduleName

common pragmas
  if flag(pragmas) || flag(all-plugins)
    hs-source-dirs: plugins/default/src
    build-depends: fuzzy
    other-modules: Ide.Plugin.Pragmas
    cpp-options: -Dpragmas

common splice
  if flag(splice) || flag(all-plugins)
    build-depends: hls-splice-plugin
    cpp-options: -Dsplice

-- formatters

common floskell
  if flag(floskell) || flag(all-formatters)
    hs-source-dirs: plugins/default/src
    other-modules: Ide.Plugin.Floskell
    build-depends: floskell                 ^>=0.10
    cpp-options: -Dfloskell

common fourmolu
  if flag(fourmolu) || flag(all-formatters)
    hs-source-dirs: plugins/default/src
    other-modules: Ide.Plugin.Fourmolu
    build-depends: fourmolu                 ^>=0.3
    cpp-options: -Dfourmolu

common ormolu
  if flag(ormolu) || flag(all-formatters)
    hs-source-dirs: plugins/default/src
    other-modules: Ide.Plugin.Ormolu
    build-depends: ormolu                   ^>=0.1.2
    cpp-options: -Dormolu

common stylishHaskell
  if flag(stylishHaskell) || flag(all-formatters)
    hs-source-dirs: plugins/default/src
    other-modules: Ide.Plugin.StylishHaskell
    build-depends: stylish-haskell          ^>=0.12
    cpp-options: -DstylishHaskell

common brittany
  if (flag(brittany) || flag(all-formatters)) && flag(agpl)
    hs-source-dirs: plugins/default/src
    other-modules: Ide.Plugin.Brittany
    build-depends: brittany                 >= 0.13.1.0
    cpp-options: -Dbrittany

executable haskell-language-server
  import:             agpl
                    , common-deps
                    -- plugins
                    , example-plugins
                    , class
                    , haddockComments
                    , eval
                    , importLens
                    , retrie
                    , tactic
                    , hlint
                    , moduleName
                    , pragmas
                    , splice
                    , floskell
                    , fourmolu
                    , ormolu
                    , stylishHaskell
                    , brittany

  main-is:          Main.hs
  hs-source-dirs:   exe
  other-modules:    Plugins

  ghc-options:
    -threaded -Wall -Wno-name-shadowing -Wredundant-constraints
    -- allow user RTS overrides
    -rtsopts
    -- disable idle GC
    -- increase nursery size
    "-with-rtsopts=-I0 -A128M"
  if flag(pedantic)
    ghc-options: -Werror

  build-depends:
    , aeson
    , binary
    , bytestring
    , containers
    , deepseq
    , ghc
    , ghc-boot-th
    , ghcide
    , hashable
    , haskell-language-server
    , haskell-lsp              ^>=0.23
    , lens
    , regex-tdfa
    , hslogger
    , optparse-applicative
    , hls-plugin-api
    , lens
    , mtl
    , regex-tdfa
    , safe-exceptions
    , shake                    >=0.17.5
    , temporary
    , transformers
    , unordered-containers
    , with-utf8

  include-dirs:     include
  default-language: Haskell2010

executable haskell-language-server-wrapper
  import:           agpl, common-deps
  main-is:          Wrapper.hs
  hs-source-dirs:   exe
  other-modules:    Paths_haskell_language_server
  autogen-modules:  Paths_haskell_language_server
  ghc-options:
    -threaded -Wall -Wno-name-shadowing -Wredundant-constraints
    -- allow user RTS overrides
    -rtsopts
    -- disable idle GC
    -- increase nursery size
    "-with-rtsopts=-I0 -A128M"
  if flag(pedantic)
    ghc-options: -Werror

  build-depends:
    , ghc
    , ghc-paths
    , ghcide
    , gitrev
    , haskell-language-server
    , hie-bios
    , optparse-applicative
    , optparse-simple
    , process

  default-language: Haskell2010

-- This common stanza simulates a previous private lib
-- We removed it due to issues with stack when loading the project using a stack based hie.yaml
-- See https://github.com/haskell/haskell-language-server/issues/114
common hls-test-utils
  import:           agpl, common-deps
  hs-source-dirs:   test/utils
  other-modules:    Test.Hls.Util
  build-depends:
    , aeson
    , blaze-markup
    , containers
    , data-default
    , haskell-lsp
    , hie-bios
    , hls-plugin-api        >=0.6
    , hslogger
    , hspec
    , hspec-core
    , lens
    , lsp-test              >=0.11.0.6
    , stm
    , tasty-expected-failure
    , tasty-hunit
    , temporary
    , transformers
    , unordered-containers
    , yaml

  ghc-options:      -Wall -Wredundant-constraints

  if flag(pedantic)
    ghc-options: -Werror

  default-language: Haskell2010

test-suite func-test
  import:             agpl, common-deps, hls-test-utils
  type:               exitcode-stdio-1.0
  default-language:   Haskell2010
  build-tool-depends:
    haskell-language-server:haskell-language-server -any,
    ghcide:ghcide-test-preprocessor -any

  build-depends:
    , bytestring
    , data-default
    , hspec-expectations
    , lens
    , tasty
    , tasty-ant-xml           >=1.1.6
    , tasty-golden
    , tasty-rerun
    , ghcide

  hs-source-dirs:     test/functional plugins/hls-tactics-plugin/src plugins/hls-eval-plugin/test plugins/hls-splice-plugin/src

  main-is:            Main.hs
  other-modules:
    Class
    Command
    Completion
    Config
    Deferred
    Definition
    Diagnostic
    Eval
    Format
    FunctionalBadProject
    FunctionalCodeAction
    FunctionalLiquid
    HieBios
    Highlight
    ModuleName
    Progress
    Reference
    Rename
    Symbol
    TypeDefinition
    Tactic
    Splice
    HaddockComments
    Ide.Plugin.Splice.Types
    Ide.Plugin.Tactic.TestTypes

  ghc-options:
    -Wall -Wno-name-shadowing -threaded -rtsopts -with-rtsopts=-N

  if flag(pedantic)
    ghc-options: -Werror -Wredundant-constraints

test-suite wrapper-test
  import:             agpl, hls-test-utils
  type:               exitcode-stdio-1.0
  build-tool-depends:
    haskell-language-server:haskell-language-server-wrapper -any

  default-language:   Haskell2010
  build-depends:
    , base
    , directory
    , process
    , tasty
    , tasty-ant-xml  >=1.1.6
    , tasty-rerun

  hs-source-dirs:     test/wrapper
  main-is:            Main.hs
  ghc-options:        -Wall