Skip to content

Commit 1a56c77

Browse files
fendorrm41339
authored andcommitted
Diagnostics for cabal-project-plugin
1 parent bd58606 commit 1a56c77

File tree

22 files changed

+726
-1
lines changed

22 files changed

+726
-1
lines changed

.github/actions/setup-build/action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ inputs:
2323
runs:
2424
using: "composite"
2525
steps:
26+
- name: Init submodules
27+
run: git submodule update --init
28+
shell: bash
29+
2630
- name: Workaround runner image issue
2731
if: runner.os == 'Linux'
2832
# https://github.com/actions/runner-images/issues/7061

.github/workflows/test.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ jobs:
9292
steps:
9393
- uses: actions/checkout@v3
9494

95+
- name: Init submodules
96+
run: git submodule update --init
97+
9598
- uses: ./.github/actions/setup-build
9699
with:
97100
ghc: ${{ matrix.ghc }}
@@ -238,6 +241,10 @@ jobs:
238241
name: Test hls-cabal-plugin test suite
239242
run: cabal test hls-cabal-plugin-tests || cabal test hls-cabal-plugin-tests
240243

244+
- if: matrix.test
245+
name: Test hls-cabal-project-plugin test suite
246+
run: cabal test hls-cabal-project-plugin-tests || cabal test hls-cabal-project-plugin-tests
247+
241248
# TODO enable when it supports 9.10
242249
- if: matrix.test && matrix.ghc != '9.10' && matrix.ghc != '9.12'
243250
name: Test hls-retrie-plugin test suite

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@
88
# Commit git commit -m "Removed submodule <name>"
99
# Delete the now untracked submodule files
1010
# rm -rf path_to_submodule
11+
12+
[submodule "vendor/cabal"]
13+
path = vendor/cabal
14+
url = https://github.com/rm41339/cabal.git

cabal.project

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,27 @@ packages:
55
./ghcide
66
./hls-plugin-api
77
./hls-test-utils
8+
./vendor/cabal/Cabal
9+
./vendor/cabal/Cabal-syntax
10+
./vendor/cabal/cabal-install
11+
./vendor/cabal/cabal-install-solver
12+
./vendor/cabal/Cabal-described
13+
./vendor/cabal/Cabal-tree-diff
814

15+
source-repository-package
16+
type: git
17+
location: https://github.com/fendor/cabal-add/
18+
tag: 3ae65c28bfc6eff66a7a05bb9547665f62a35b63
19+
20+
source-repository-package
21+
type: git
22+
location: https://github.com/fendor/haskell-ci/
23+
tag: e3e68f064f9610267bb47ea6404ccaa6924c2201
24+
subdir: cabal-install-parsers
25+
26+
package cabal-install
27+
tests: False
28+
benchmarks: False
929

1030
index-state: 2025-08-08T12:31:54Z
1131

@@ -50,9 +70,16 @@ constraints:
5070
-- cabal-add depends on cabal-install-parsers.
5171
allow-newer:
5272
cabal-install-parsers:Cabal-syntax,
73+
*:Cabal-syntax,
74+
*:cabal-install,
75+
*:Cabal,
76+
rere:QuickCheck
5377

5478
if impl(ghc >= 9.11)
5579
benchmarks: False
5680
allow-newer:
5781
cabal-install-parsers:base,
5882
cabal-install-parsers:time,
83+
84+
-- Disable these plugins as they aren't compatible Cabal-3.17, yet.
85+
flags: -floskell -fourmolu -hlint -ormolu -stan -stylishhaskell

ghcide/session-loader/Development/IDE/Session.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module Development.IDE.Session
1414
,retryOnException
1515
,Log(..)
1616
,runWithDb
17+
, cacheDir
1718
) where
1819

1920
-- Unfortunately, we cannot use loadSession with ghc-lib since hie-bios uses

haskell-language-server.cabal

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,86 @@ test-suite hls-cabal-plugin-tests
322322
, lsp-types
323323
, text
324324

325+
-----------------------------
326+
-- cabal project plugin
327+
-----------------------------
328+
329+
flag cabalProject
330+
description: Enable cabalProject plugin
331+
default: True
332+
manual: True
333+
334+
common cabalProject
335+
if flag(cabalProject)
336+
build-depends: haskell-language-server:hls-cabal-project-plugin
337+
cpp-options: -Dhls_cabal_project
338+
339+
library hls-cabal-project-plugin
340+
import: defaults, pedantic, warnings
341+
if !flag(cabalProject)
342+
buildable: False
343+
exposed-modules:
344+
Ide.Plugin.CabalProject
345+
Ide.Plugin.CabalProject.Parse
346+
Ide.Plugin.CabalProject.Diagnostics
347+
Ide.Plugin.CabalProject.Types
348+
349+
build-depends:
350+
, bytestring
351+
, Cabal-syntax >= 3.7
352+
, containers
353+
, deepseq
354+
, directory
355+
, filepath
356+
, extra >=1.7.4
357+
, ghcide == 2.11.0.0
358+
, hashable
359+
, hls-plugin-api == 2.11.0.0
360+
, hls-graph == 2.11.0.0
361+
, lens
362+
, lsp ^>=2.7
363+
, lsp-types ^>=2.3
364+
, regex-tdfa ^>=1.3.1
365+
, text
366+
, text-rope
367+
, transformers
368+
, unordered-containers >=0.2.10.0
369+
, containers
370+
, process
371+
, aeson
372+
, Cabal
373+
, pretty
374+
, cabal-install
375+
, cabal-install-solver
376+
, haskell-language-server:hls-cabal-plugin
377+
, base16-bytestring
378+
, cryptohash-sha1
379+
380+
hs-source-dirs: plugins/hls-cabal-project-plugin/src
381+
382+
test-suite hls-cabal-project-plugin-tests
383+
import: defaults, pedantic, test-defaults, warnings
384+
if !flag(cabalProject)
385+
buildable: False
386+
type: exitcode-stdio-1.0
387+
hs-source-dirs: plugins/hls-cabal-project-plugin/test
388+
main-is: Main.hs
389+
other-modules:
390+
Utils
391+
build-depends:
392+
, bytestring
393+
, Cabal-syntax >= 3.7
394+
, extra
395+
, filepath
396+
, ghcide
397+
, haskell-language-server:hls-cabal-project-plugin
398+
, hls-test-utils == 2.11.0.0
399+
, lens
400+
, lsp-types
401+
, text
402+
, hls-plugin-api
403+
, cabal-install
404+
325405
-----------------------------
326406
-- class plugin
327407
-----------------------------
@@ -1847,6 +1927,7 @@ library
18471927
, pedantic
18481928
-- plugins
18491929
, cabal
1930+
, cabalProject
18501931
, callHierarchy
18511932
, cabalfmt
18521933
, cabalgild

hls-plugin-api/src/Ide/Types.hs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
{-# LANGUAGE UndecidableInstances #-}
1515
{-# LANGUAGE ViewPatterns #-}
1616
module Ide.Types
17-
( PluginDescriptor(..), defaultPluginDescriptor, defaultCabalPluginDescriptor
17+
( PluginDescriptor(..), defaultPluginDescriptor, defaultCabalPluginDescriptor, defaultCabalProjectPluginDescriptor
1818
, defaultPluginPriority
1919
, describePlugin
2020
, IdeCommand(..)
@@ -1077,6 +1077,21 @@ defaultCabalPluginDescriptor plId desc =
10771077
Nothing
10781078
[".cabal"]
10791079

1080+
defaultCabalProjectPluginDescriptor :: PluginId -> T.Text -> PluginDescriptor ideState
1081+
defaultCabalProjectPluginDescriptor plId desc =
1082+
PluginDescriptor
1083+
plId
1084+
desc
1085+
defaultPluginPriority
1086+
mempty
1087+
mempty
1088+
mempty
1089+
defaultConfigDescriptor
1090+
mempty
1091+
mempty
1092+
Nothing
1093+
[".project"]
1094+
10801095
newtype CommandId = CommandId T.Text
10811096
deriving (Show, Read, Eq, Ord)
10821097
instance IsString CommandId where

plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Diagnostics.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ module Ide.Plugin.Cabal.Diagnostics
55
, warningDiagnostic
66
, positionFromCabalPosition
77
, fatalParseErrorDiagnostic
8+
, toBeginningOfNextLine
9+
, mkDiag
810
-- * Re-exports
911
, FileDiagnostic
1012
, Diagnostic(..)

0 commit comments

Comments
 (0)