Skip to content

DRAFT: Cabal project plugin #4615

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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,6 @@ store/
gh-release-artifacts/

.hls/

# local cabal package
vendor/
10 changes: 10 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ packages:
./ghcide
./hls-plugin-api
./hls-test-utils
./vendor/parse-cabal-project/cabal/Cabal
./vendor/parse-cabal-project/cabal/Cabal-syntax
./vendor/parse-cabal-project/cabal/cabal-install
./vendor/parse-cabal-project/cabal/cabal-install-solver
./vendor/parse-cabal-project/cabal/Cabal-described
./vendor/parse-cabal-project/cabal/Cabal-tree-diff

package cabal-install
tests: False
benchmarks: False


index-state: 2025-05-12T13:26:29Z
Expand Down
77 changes: 77 additions & 0 deletions haskell-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,82 @@ test-suite hls-cabal-plugin-tests
, text
, hls-plugin-api

-----------------------------
-- cabal project plugin
-----------------------------

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

common cabalProject
if flag(cabalProject)
build-depends: haskell-language-server:hls-cabal-project-plugin
cpp-options: -Dhls_cabal_project

library hls-cabal-project-plugin
import: defaults, pedantic, warnings
if !flag(cabalProject)
buildable: False
exposed-modules:
Ide.Plugin.CabalProject
Ide.Plugin.CabalProject.Parse
Ide.Plugin.CabalProject.Diagnostics
Ide.Plugin.CabalProject.Types
Ide.Plugin.CabalProject.Orphans

build-depends:
, bytestring
, Cabal-syntax >= 3.7
, containers
, deepseq
, directory
, filepath
, extra >=1.7.4
, ghcide == 2.11.0.0
, hashable
, hls-plugin-api == 2.11.0.0
, hls-graph == 2.11.0.0
, lens
, lsp ^>=2.7
, lsp-types ^>=2.3
, regex-tdfa ^>=1.3.1
, text
, text-rope
, transformers
, unordered-containers >=0.2.10.0
, containers
, process
, aeson
, Cabal
, pretty
, cabal-install
, cabal-install-solver

hs-source-dirs: plugins/hls-cabal-project-plugin/src

test-suite hls-cabal-project-plugin-tests
import: defaults, pedantic, test-defaults, warnings
if !flag(cabalProject)
buildable: False
type: exitcode-stdio-1.0
hs-source-dirs: plugins/hls-cabal-project-plugin/test
main-is: Main.hs
other-modules:
build-depends:
, bytestring
, Cabal-syntax >= 3.7
, extra
, filepath
, ghcide
, haskell-language-server:hls-cabal-project-plugin
, hls-test-utils == 2.11.0.0
, lens
, lsp-types
, text
, hls-plugin-api

-----------------------------
-- class plugin
-----------------------------
Expand Down Expand Up @@ -1830,6 +1906,7 @@ library
, pedantic
-- plugins
, cabal
, cabalProject
, callHierarchy
, cabalfmt
, cabalgild
Expand Down
17 changes: 16 additions & 1 deletion hls-plugin-api/src/Ide/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ViewPatterns #-}
module Ide.Types
( PluginDescriptor(..), defaultPluginDescriptor, defaultCabalPluginDescriptor
( PluginDescriptor(..), defaultPluginDescriptor, defaultCabalPluginDescriptor, defaultCabalProjectPluginDescriptor
, defaultPluginPriority
, describePlugin
, IdeCommand(..)
Expand Down Expand Up @@ -1077,6 +1077,21 @@ defaultCabalPluginDescriptor plId desc =
Nothing
[".cabal"]

defaultCabalProjectPluginDescriptor :: PluginId -> T.Text -> PluginDescriptor ideState
defaultCabalProjectPluginDescriptor plId desc =
PluginDescriptor
plId
desc
defaultPluginPriority
mempty
mempty
mempty
defaultConfigDescriptor
mempty
mempty
Nothing
[".project"]

newtype CommandId = CommandId T.Text
deriving (Show, Read, Eq, Ord)
instance IsString CommandId where
Expand Down
Loading
Loading