Skip to content
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 .github/actions/setup-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ inputs:
runs:
using: "composite"
steps:
- name: Init submodules
run: git submodule update --init

- name: Workaround runner image issue
if: runner.os == 'Linux'
# https://github.com/actions/runner-images/issues/7061
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Init submodules
run: git submodule update --init

- uses: ./.github/actions/setup-build
with:
ghc: ${{ matrix.ghc }}
Expand Down Expand Up @@ -238,6 +241,10 @@ jobs:
name: Test hls-cabal-plugin test suite
run: cabal test hls-cabal-plugin-tests || cabal test hls-cabal-plugin-tests

- if: matrix.test
name: Test hls-cabal-project-plugin test suite
run: cabal test hls-cabal-project-plugin-tests || cabal test hls-cabal-project-plugin-tests

# TODO enable when it supports 9.10
- if: matrix.test && matrix.ghc != '9.10' && matrix.ghc != '9.12'
name: Test hls-retrie-plugin test suite
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@
# Commit git commit -m "Removed submodule <name>"
# Delete the now untracked submodule files
# rm -rf path_to_submodule

[submodule "vendor/cabal"]
path = vendor/cabal
url = https://github.com/rm41339/cabal.git
24 changes: 24 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,27 @@ packages:
./ghcide
./hls-plugin-api
./hls-test-utils
./vendor/cabal/Cabal
./vendor/cabal/Cabal-syntax
./vendor/cabal/cabal-install
./vendor/cabal/cabal-install-solver
./vendor/cabal/Cabal-described
./vendor/cabal/Cabal-tree-diff

source-repository-package
type: git
location: https://github.com/fendor/cabal-add/
tag: 3ae65c28bfc6eff66a7a05bb9547665f62a35b63

source-repository-package
type: git
location: https://github.com/fendor/haskell-ci/
tag: e3e68f064f9610267bb47ea6404ccaa6924c2201
subdir: cabal-install-parsers

package cabal-install
tests: False
benchmarks: False

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

Expand Down Expand Up @@ -50,6 +70,10 @@ constraints:
-- cabal-add depends on cabal-install-parsers.
allow-newer:
cabal-install-parsers:Cabal-syntax,
*:Cabal-syntax,
*:cabal-install,
*:Cabal
rere:QuickCheck

if impl(ghc >= 9.11)
benchmarks: False
Expand Down
14 changes: 6 additions & 8 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -443,22 +443,20 @@ This will install `eglot` and enable it by default in `haskell-mode`.
To configure `haskell-language-server` we use the `eglot-workspace-configuration` variable.
With `M-x eglot-show-workspace-configuration` you can see the JSON that `eglot` will send to `haskell-language-server`.
See <https://joaotavora.github.io/eglot/#Customizing-Eglot> for more information.
As an example, the setting below will disable the `stan` plugin.
As an example, the setting below will disable the `stan` plugin and use `fourmolu` for formatting:

```emacs-lisp
(use-package eglot
:ensure t
:config
(add-hook 'haskell-mode-hook 'eglot-ensure)
(add-hook 'haskell-mode-hook 'eglot-ensure) ; start eglot automatically in haskell projects
:config
(setq-default eglot-workspace-configuration
'((haskell
(plugin
(stan
(globalOn . :json-false)))))) ;; disable stan
'(:haskell (:plugin (:stan (:globalOn :json-false)) ; disable stan
:formattingProvider "fourmolu"))) ; use fourmolu instead of ormolu
:custom
(eglot-autoshutdown t) ;; shutdown language server after closing last file
(eglot-confirm-server-initiated-edits nil) ;; allow edits without confirmation
(eglot-autoshutdown t) ; shutdown language server after closing last file
(eglot-confirm-server-initiated-edits nil) ; allow edits without confirmation
)
```

Expand Down
1 change: 1 addition & 0 deletions ghcide/session-loader/Development/IDE/Session.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
,retryOnException
,Log(..)
,runWithDb
, cacheDir
) where

-- Unfortunately, we cannot use loadSession with ghc-lib since hie-bios uses
Expand Down Expand Up @@ -629,7 +630,7 @@
[] -> error $ "GHC version could not be parsed: " <> version
((runTime, _):_)
| compileTime == runTime -> do
atomicModifyIORef' cradle_files (\xs -> (cfp:xs,()))

Check warning on line 633 in ghcide/session-loader/Development/IDE/Session.hs

View workflow job for this annotation

GitHub Actions / Hlint check run

Warning in loadSessionWithOptions in module Development.IDE.Session: Use atomicModifyIORef'_ ▫︎ Found: "atomicModifyIORef' cradle_files (\\ xs -> (cfp : xs, ()))" ▫︎ Perhaps: "atomicModifyIORef'_ cradle_files ((:) cfp)"
session (hieYaml, toNormalizedFilePath' cfp, opts, libDir)
| otherwise -> return (([renderPackageSetupException cfp GhcVersionMismatch{..}], Nothing),[])
-- Failure case, either a cradle error or the none cradle
Expand Down Expand Up @@ -896,7 +897,7 @@
x <- map errMsgDiagnostic closure_errs
DriverHomePackagesNotClosed us <- pure x
pure us
isBad ci = (homeUnitId_ (componentDynFlags ci)) `OS.member` bad_units

Check warning on line 900 in ghcide/session-loader/Development/IDE/Session.hs

View workflow job for this annotation

GitHub Actions / Hlint check run

Suggestion in newComponentCache in module Development.IDE.Session: Redundant bracket ▫︎ Found: "(homeUnitId_ (componentDynFlags ci)) `OS.member` bad_units" ▫︎ Perhaps: "homeUnitId_ (componentDynFlags ci) `OS.member` bad_units"
-- Whenever we spin up a session on Linux, dynamically load libm.so.6
-- in. We need this in case the binary is statically linked, in which
-- case the interactive session will fail when trying to load
Expand Down
85 changes: 85 additions & 0 deletions haskell-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,90 @@ test-suite hls-cabal-plugin-tests
, lsp-types
, text

-----------------------------
-- 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.Completion.Completions
Ide.Plugin.CabalProject.Completion.Data

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
, haskell-language-server:hls-cabal-plugin
, base16-bytestring
, cryptohash-sha1

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:
Completer
Utils
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
, cabal-install
, haskell-language-server:hls-cabal-plugin

-----------------------------
-- class plugin
-----------------------------
Expand Down Expand Up @@ -1847,6 +1931,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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ module Ide.Plugin.Cabal.Diagnostics
, warningDiagnostic
, positionFromCabalPosition
, fatalParseErrorDiagnostic
, toBeginningOfNextLine
, mkDiag
-- * Re-exports
, FileDiagnostic
, Diagnostic(..)
Expand Down
2 changes: 1 addition & 1 deletion plugins/hls-cabal-plugin/test/testdata/completer.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ be
library
lib

co
co
Loading
Loading