Skip to content

Commit 912f631

Browse files
authored
Merge branch 'master' into nix_flake_fix_devShells
2 parents 9958922 + 47cb213 commit 912f631

File tree

13 files changed

+264
-140
lines changed

13 files changed

+264
-140
lines changed

.github/workflows/build.yml

+5
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ jobs:
4848
echo "tests: false" >> cabal.project.local
4949
echo "benchmarks: false" >> cabal.project.local
5050
51+
- name: Disable -dynamic
52+
run: |
53+
echo "package haskell-language-server" >> cabal.project.local
54+
echo " flags: -dynamic" >> cabal.project.local
55+
5156
- uses: ./.github/actions/setup-build
5257
with:
5358
ghc: ${{ matrix.ghc }}

docs/troubleshooting.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -165,34 +165,34 @@ Using an explicit `hie.yaml` to configure the cradle can resolve the problem, se
165165
Static binaries use the GHC linker for dynamically loading dependencies when typechecking TH code, and this can run into issues when loading shared objects linked against mismatching system libraries, or into GHC linker bugs (mainly the Mach linker used in Mac OS, but also potentially the ELF linker).
166166
Dynamically linked binaries (including`ghci`) use the system linker instead of the GHC linker and avoid both issues.
167167

168-
The easiest way to obtain a dynamically linked HLS binary is to build it locally. With `cabal` this can be done as follows:
168+
The easiest way to obtain a dynamically linked HLS binary is to build HLS locally. With `cabal` this can be done as follows:
169169

170170
```bash
171-
cabal update && cabal install pkg:haskell-language-server --ghc-options="-dynamic"
171+
cabal update && cabal install pkg:haskell-language-server"
172172
```
173173
174174
If you are compiling with a ghc version with a specific `cabal-ghc${ghcVersion}.project` in the repo you will have to use it. For example for ghc-9.0.x:
175175
176176
```bash
177-
cabal update && cabal install pkg:haskell-language-server --project-file=cabal-ghc90.project --ghc-options="-dynamic"
177+
cabal update && cabal install pkg:haskell-language-server --project-file=cabal-ghc90.project"
178178
```
179179

180-
With `stack` you also need add the ghc option `-dynamic`.
180+
Or with `stack`:
181181

182182
```bash
183-
stack install haskell-language-server --stack-yaml=stack-${ghcVersion}.yaml --ghc-options="-dynamic"
183+
stack install haskell-language-server --stack-yaml=stack-${ghcVersion}.yaml"
184184
```
185185
186186
You also can leverage `ghcup compile hls`:
187187
188188
```bash
189-
ghcup compile hls -g master --ghc 8.10.7 -- --ghc-options="-dynamic"
189+
ghcup compile hls -v 1.6.1.0 --ghc 8.10.7
190190
```
191191
192192
as it uses cabal underneath you might need to use a specific cabal.project for some ghc versions:
193193
194194
```bash
195-
ghcup compile hls -g master --ghc 9.0.2 --project-file cabal-ghc90.project -- --ghc-options="-dynamic"
195+
ghcup compile hls -v 1.6.1.0 --ghc 9.0.2 --cabal-project cabal-ghc90.project
196196
```
197197
198198
### Preprocessors

ghcide/test/exe/Main.hs

+30
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,36 @@ extendImportTests = testGroup "extend import actions"
15201520
, "import ModuleA as A (stuffB, (.*))"
15211521
, "main = print (stuffB .* stuffB)"
15221522
])
1523+
, knownBrokenForGhcVersions [GHC92] "missing comma. #2662" $ testSession "extend single line import with infix constructor" $ template
1524+
[]
1525+
("ModuleB.hs", T.unlines
1526+
[ "module ModuleB where"
1527+
, "import Data.List.NonEmpty (fromList)"
1528+
, "main = case (fromList []) of _ :| _ -> pure ()"
1529+
])
1530+
(Range (Position 2 5) (Position 2 6))
1531+
["Add NonEmpty((:|)) to the import list of Data.List.NonEmpty"]
1532+
(T.unlines
1533+
[ "module ModuleB where"
1534+
, "import Data.List.NonEmpty (fromList, NonEmpty ((:|)))"
1535+
, "main = case (fromList []) of _ :| _ -> pure ()"
1536+
])
1537+
, knownBrokenForGhcVersions [GHC92] "missing comma. #2662" $ testSession "extend single line import with prefix constructor" $ template
1538+
[]
1539+
("ModuleB.hs", T.unlines
1540+
[ "module ModuleB where"
1541+
, "import Prelude hiding (Maybe(..))"
1542+
, "import Data.Maybe (catMaybes)"
1543+
, "x = Just 10"
1544+
])
1545+
(Range (Position 3 5) (Position 2 6))
1546+
["Add Maybe(Just) to the import list of Data.Maybe"]
1547+
(T.unlines
1548+
[ "module ModuleB where"
1549+
, "import Prelude hiding (Maybe(..))"
1550+
, "import Data.Maybe (catMaybes, Maybe (Just))"
1551+
, "x = Just 10"
1552+
])
15231553
, testSession "extend single line import with type" $ template
15241554
[("ModuleA.hs", T.unlines
15251555
[ "module ModuleA where"

haskell-language-server.cabal

+14
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ flag brittany
208208
default: True
209209
manual: True
210210

211+
flag dynamic
212+
description: Build with the dyn rts
213+
default: True
214+
manual: True
215+
211216
common example-plugins
212217
hs-source-dirs: plugins/default/src
213218
other-modules: Ide.Plugin.Example,
@@ -364,6 +369,15 @@ executable haskell-language-server
364369
-Wno-unticked-promoted-constructors
365370
if flag(pedantic)
366371
ghc-options: -Werror
372+
if !os(windows) && flag(dynamic)
373+
-- We want to link against the dyn rts just like official GHC binaries do;
374+
-- the linked rts determines how external libs are loaded dynamically by TH.
375+
-- The standard way of doing this is via the --enable-dynamic-executables Cabal option
376+
-- Unfortunately it doesnt' work, see https://github.com/haskell/haskell-language-server/issues/2659
377+
-- One can use --ghc-options=-dynamic but this gets applied to the dependencies as well,
378+
-- which results in massive rebuilds and incompatibilities with profiling.
379+
-- So instead we set the -dynamic flag diretly here.
380+
ghc-options: -dynamic
367381

368382
build-depends:
369383
, aeson

plugins/hls-eval-plugin/hls-eval-plugin.cabal

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ library
4545
other-modules:
4646
Ide.Plugin.Eval.Code
4747
Ide.Plugin.Eval.CodeLens
48+
Ide.Plugin.Eval.Config
4849
Ide.Plugin.Eval.GHC
4950
Ide.Plugin.Eval.Parse.Comments
5051
Ide.Plugin.Eval.Parse.Option
@@ -105,10 +106,12 @@ test-suite tests
105106
build-depends:
106107
, aeson
107108
, base
109+
, containers
108110
, directory
109111
, extra
110112
, filepath
111113
, hls-eval-plugin
114+
, hls-plugin-api
112115
, hls-test-utils ^>=1.2
113116
, lens
114117
, lsp-types

plugins/hls-eval-plugin/src/Ide/Plugin/Eval.hs

+9-3
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,23 @@ module Ide.Plugin.Eval (
1111

1212
import Development.IDE (IdeState)
1313
import qualified Ide.Plugin.Eval.CodeLens as CL
14+
import Ide.Plugin.Eval.Config
1415
import Ide.Plugin.Eval.Rules (rules)
15-
import Ide.Types (PluginDescriptor (..), PluginId,
16+
import Ide.Types (ConfigDescriptor (..),
17+
PluginDescriptor (..), PluginId,
18+
defaultConfigDescriptor,
1619
defaultPluginDescriptor,
17-
mkPluginHandler)
20+
mkCustomConfig, mkPluginHandler)
1821
import Language.LSP.Types
1922

2023
-- |Plugin descriptor
2124
descriptor :: PluginId -> PluginDescriptor IdeState
2225
descriptor plId =
2326
(defaultPluginDescriptor plId)
2427
{ pluginHandlers = mkPluginHandler STextDocumentCodeLens CL.codeLens
25-
, pluginCommands = [CL.evalCommand]
28+
, pluginCommands = [CL.evalCommand plId]
2629
, pluginRules = rules
30+
, pluginConfigDescriptor = defaultConfigDescriptor
31+
{ configCustomConfig = mkCustomConfig properties
32+
}
2733
}

0 commit comments

Comments
 (0)