Commit Graph

46 Commits

Author SHA1 Message Date
Pepe Iborra
39605333c3
Expose an option to control the number of Shake threads (#504) 2020-03-27 10:54:15 +01:00
Pepe Iborra
9ccd9eec08
Detect ghc mismatch (#462)
* Detect ghc version mismatches

* Add ghc-check to stack extra deps

* ghc-check: explicit libdir and delay version error
2020-03-24 12:40:21 +01:00
Pepe Iborra
f804b138dc
Support for interface files (#457)
* Rules for loading interface files

* Typechecking with interface files

* Add a note in the README about the optimal project setup

* Improve support for hs-boot files

The branch was failing to load GHC because the module graph was missing
edges between a .hs file and its .hs-boot file. This means the .hs-boot
file was getting added into the HPT after the .hs file which led to
confusing errors about variables being out of scope.

The fix is to maintain a map from hs-boot to hs files and then add an
edge for this case when calling `transitiveDependencies`.

Also tidy up some code in setupEnv which I assume was attempting to fix
this but in an incorrect manner.

Add the -boot suffix when looking for hi-boot files.

For some reason, the `hi` path is not set to the right thing for
`hs-boot` files. I don't know why not perhaps it is ok to use an
existing `.hi` file in place of an `hs-boot` file. More investigation
needed. My experience is that GHC is quite bad a recompilation avoidance
for hs-boot files anyway.

For example: https://gitlab.haskell.org/ghc/ghc/issues/17434

Add the -boot suffix when writing interface files

* Generate .hi and .hie files during type checking

* Refactor GetModIface to not retain TypeChecked module in memory

This improves memory performance on a cold cache.

* Trailing whitespace

* Turn debug log messages into diagnostics

* Implement "hie" files for ghc-8.6.5

This means that the .hi files patch can also be used with 8.6.5

* Add tests for hover/definition on imported symbols

* hlints

* Generate .hie files when missing

* Fix subtle bug in setDefaultHieDir

* Simplify optimal project setup in README

* Move interface loading diagnostics behind --test flag

Reusing the --test flag for this seems harmless, I cannot justify introducing a
new flag

* Avoid expensive interface file generation for files of interest

* avoid redundant arguments (thanks Moritz K)

* qualify a DAML only comment

* Skip module source when generating hie file

thanks Moritz Kiefer for noting that we don't care for the generated .hie files
to embed module sources

* runGhcEnv <-> evalGhcEnv

* Apply suggestions from code review

Thanks Moritz Kiefer

Co-Authored-By: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* Add suggested Show instance

Co-Authored-By: Matthew Pickering <matthewtpickering@gmail.com>

* Use Control.Exception.Safe

This is to avoid accidentally capturing asynchronous exceptions

* Rename atomicFileUpdate

* Fix a flaky test

We have to be careful with module naming in tests to avoid interference of .hi
files across tests

* Undo formatting of D.IDE.GHC.Util

* follow changes in master

Co-authored-by: Matthew Pickering <matthewtpickering@gmail.com>
Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2020-03-24 12:39:53 +01:00
Javier Neira
9951f35b08
Use NormalizedFilePath and adapt types of haskell-lsp-0.21 (#479)
* Use custom version of h-l-t

* Use normalized path functions from h-l-t

* Restore empty path corner case

* Create a wrapper over NFP to override IsString

* Use maybe instead fromMaybe

* Use patched version of lsp-types in all yaml files

* Remove unused import

* Rename specific NormalizeFilePath to NormalizeFilePath'

* Remove specific newtype and IsString instance

* Use released haskell-lsp-0.21

* Adapt to type changes of haskell-lsp-0.21

* Add tags field to CompletionItem

* Fix test case about empty file path

* Correct stack.yaml used in azure ci cache

* Build ghcide including tests in windows azure ci

* Qualify haskell-lsp modules to avoid name clashes
2020-03-23 09:07:04 +01:00
Alan Zimmerman
8b328bb7c5
Working on Plugin support for haskell-language-server (#477)
* Working on Plugin support for hls

Fix PluginCommand reply type for executeCommand needs

* Remove PluginCommand

It will move to haskell-language-server instead

* Make azure CI hlint happy

By removing explicit OverloadedStrings pragma, in favour of the one already
enabled in the cabal file.

* Remove unneeded 'do'

* Fix more nits from review
2020-03-16 11:31:18 +01:00
Pepe Iborra
c74e9b51f1
Fix two regressions since 0.1.0 (#471)
* Fix isWorkspaceFile for relative paths

This fixes a performance regression on GetFileExists

* Avoid interrupting hie-bios when it's doing its thing

I noticed that the GHC hie-bios direct cradle, which uses Hadrian, a Shake build
system, was failing to start due to the following problem:

1. ghcide starts evaluating the LoadCradle node
2. The evaluation gets cancelled
3. Immediately after, ghcide starts evaluating LoadCradle again
4. Hadrian fails, since there is still another Hadrian process alive taking its
Shake lock

* Improve watched files test suite
2020-03-10 18:06:39 +01:00
Pepe Iborra
0bf4e91ba4
Refactoring: remove isTesting from ShakeExtras (#469)
isTesting got added to ShakeExtras unnecessarily
2020-03-09 13:23:41 +01:00
Moritz Kiefer
bd25cd01ac
Set the streams to utf8 in Main.hs (#466) 2020-03-05 15:34:24 +01:00
Pepe Iborra
df63fd76c0
Tests for cradle loading (#460)
* Refactor: extract Rules to a separate module

* Add tests for cradle loading

* Fix default extensions in exe target

* Move cradle loaded messages behind a flag

* Use satisfy

Following a suggestion by Moritz Kiefer (@cocreature)
2020-03-04 17:31:24 +01:00
Pepe Iborra
ff62fdd87d
Fix regression in cradle loading logic (#450)
We were calling runCradle multiple times per cradle, concurrently. For Cabal
cradles this function runs Cabal, which is neither fast nor designed to be run
concurrently
2020-02-26 09:16:17 +01:00
Pepe Iborra
48a7867a07
Local hidir and hiedir folders to avoid conflicts with Cabal (#441)
* Local hidir and hiedir folders to avoid conflicts with Cabal

hi files created by ghcide would have different optimization settings,
triggering Cabal recompilation if they were stored in Cabal folders

hie files would end up in the src folder as -hiedir is not set by Cabal

Telling GHC to write interface/hie files is pointless since we do it ourselves,
and it also leads to the recompilation checker getting confused

Using hie-bios initSession does things like setting up the cache directory for
interface files and other things which ghcide would rather manage itself.

* linker options

Co-authored-by: Matthew Pickering <matthewtpickering@gmail.com>
2020-02-20 12:32:20 +01:00
Jinwoo Lee
00d914efa7
Automatically pick up new dependencies (#408)
* Automatically pick up new dependencies

hie-bios's componentDependencies returns the dependencies of a cradle
that might change the cradle. Add those deps to the shake graph so that
the GHC session is newly created whenever they change.

For that, add a new rule type, GetHscEnvEq, to cache GHC sessions with
the key of GHC options and dependencies. And delete the optGhcSession
field from IdeOptions.

This is for https://github.com/digital-asset/ghcide/issues/50.

hie-bios's componentDependencies can return files that don't exist yet:
https://github.com/mpickering/hie-bios/blob/master/src/HIE/Bios/Types.hs#L90-L93.
This PR handles changes in the existing dependency files, but doesn't
handle newly created dependency files.

* address comments

* revert hie.yaml

* address more comments

* add test

* make direct cradles work; and use direct cradle in test
2020-02-17 10:33:33 +01:00
Alan Zimmerman
71ecd105d9
Parameterize the haskell-lsp client config type (#416)
So that haskell-language-server can use its own config

And separate it out from the IdeConfiguration which is separately set by the
InitializeRequest message.
2020-02-14 13:21:27 +01:00
Moritz Kiefer
4e89d4574d
Use HashMap/HashSet for maps indexed by Normalized{FilePath,Uri} (#420)
Now that we have optimized Hashable instances for these, it makes
sense to use this consistently.
2020-02-11 10:09:48 +01:00
Matthew Pickering
76221fb354 Display output from initialising cradle in debug mode (#411) 2020-02-10 10:43:42 +01:00
Moritz Kiefer
4aaba4d3e0
Make debouncer configurable (#409)
We have been experiencing a few flaky tests in DAML caused by our CLI
compiler losing diagnostics. The reason for that is the debouncer
which meant that messages got delayed and not send before the process
exited.

This PR makes the debouncer abstract and adds a noopDebouncer which
doesn’t do any debouncing. This is also what we use in the terminal
ghcide test thingy.
2020-02-06 20:57:55 +01:00
fendor
1d04b09add
Update to latest hie-bios (#382)
* Update to latest hie-bios

* Remove explicit usage of type parameter Void from Cradle
2020-02-04 11:09:50 +01:00
Neil Mitchell
f06cae0cd1
Make ghcide on the command line use absolute file paths (#401) 2020-02-04 10:15:49 +01:00
Matthew Pickering
cb2828795d Pass shake-profiling option when not using --lsp (#385) 2020-01-28 09:04:02 +01:00
Neil Mitchell
331a144296 Add plugin type (#365)
* Add a plugin type

* Add a helper to construct codeAction values

* Remove a redundant $
2020-01-26 11:28:11 +00:00
Alan Zimmerman
20a723a47f Fix typo (#366) 2020-01-26 11:11:40 +00:00
Neil Mitchell
3ccebde867 Move the completions and code actions into Plugin (#359)
* Move the completions into a Plugin pile

* Fix HLint

* Turn CodeAction into a plugin as well

* Fix HLint

* Remove a redundant def <>
2020-01-26 09:36:48 +00:00
Pepe Iborra
2d9314ae1d Fix performance of getFileExists (#322)
* Improve hover performance by speeding up getFileExists

We touch the file system only the first time.
After that, we rely on the lsp client to tell us if a file is created or deleted

Fixes #101
2020-01-21 09:05:58 +01:00
Pepe Iborra
db456b0e51 Add a new flag --shake-profiling DIR (#307)
The flag provides a way to enable Shake profiling reports without recompiling.
Debug output prints links to the Shake reports for convenience
2020-01-06 19:56:40 +01:00
Pepe Iborra
b78efe36bb Extend version message to include path and git commit (#306) 2020-01-06 09:13:14 +01:00
Moritz Kiefer
b2ad2eb361
Fix build with Shake 0.18.4 (#272)
Shake 0.18.4 started exporting Info from this module which clashes
with the one from haskell-lsp. Fixes #271
2019-12-18 11:24:54 +01:00
Alejandro Serrano
1b1c58518d Filter out completely warnings not enabled by user (#263)
* Filter out completely warnings not enabled by user

* Suggestions by @cocreature

* Add tests

* Work more on tests

* Fix tests
2019-12-17 15:13:12 +01:00
Moritz Kiefer
fc30f1476f
Upgrade to hie-bios (#257)
This does not yet take advantage of any new features but we should at
least be able to benefit from bugfixes.
2019-12-16 11:42:44 +01:00
Jinwoo Lee
fa2c295f74 Indicate failures with exit code in command-line mode. (#233)
It'd be useful for scripting or integration tests.
2019-12-12 09:00:49 +01:00
Pepe Iborra
5091a1d202 Fix horrible path normalisation issue (#225) 2019-12-08 17:07:15 +01:00
Moritz Kiefer
5febbcbc48
Fix progress reporting (#153)
* Fix progress reporting

* Bump haskell-lsp and lsp-test revisions

* Change client name

* Fix typo

* Bump revisions
2019-10-17 11:11:52 +02:00
Jacek Generowicz
e583f13d8d Issue visual warning for humans if --lsp option used (#161)
Experience shows that people sometimes mistakenly start `ghcide` on
the command line with the `--lsp` option (which is intended to be used
only in server/client communication scenarios) and then wonder why
nothing is working..

So let's issue a warning message whenever `--lsp` is used.
2019-10-08 19:43:32 +02:00
Neil Mitchell
9d45eee21c #137, make the status message clearer about what worked and what didn't (#138) 2019-09-27 15:18:24 +02:00
Neil Mitchell
60ed687de9 Support multiple hie.yaml files (#127)
* Hack around https://github.com/mpickering/hie-bios/pull/56 - hie-bios expects files to really exist on disk

* Fix getLocatedImportsRule to pass the file to the session

* Add support for multiple simultaneous hie.yaml files.
Also rewrites the user experience on setup to be less verbose.
Also adds masking for GHC session construction.

* HLint

* Code review comments

* Switch to the Strict map
2019-09-25 13:01:41 +02:00
Jacek Generowicz
c24ef1c288 Add --version CLI option (#106)
* Add --version CLI option

* Extract ghcide version from cabal

* Extract precise GHC version from cabal preprocessor macro
2019-09-23 08:50:28 +02:00
Neil Mitchell
50e35f0e98 Use the hie-bios function that doesn't perform a downsweep. Fixes #99 (#102) 2019-09-20 17:33:37 +02:00
Ollie Charles
9a5ee23c01 Build on GHC 8.8 (#43) 2019-09-16 15:20:48 +02:00
Neil Mitchell
fc939e7dfb Add a comment that the test needs to change for multi environment 2019-09-11 09:34:16 +01:00
Neil Mitchell
405d62b064 Add multi environment support 2019-09-11 09:13:18 +01:00
Moritz Kiefer
5da86c3e44 Rename hie-core to ghcide (#2820)
* Rename hie-core to ghcide

The name `hie-core` has caused a lot of confusion as to how we relate
to haskell-ide-engine so changing it should hopefully help with that.
I also think that ghcide is still a good name once we hopefully
integrate with haskell-ide-engine more closely.

The name ghcide seems to have a reasonable amount of support on
Twitter https://twitter.com/ndm_haskell/status/1170681262987710464
which is of course the only good way to come up with names.

* Add a readme that points people to the new directory.

* Fix bogus replacements

* Use a proper link

* links are hard
2019-09-10 15:01:29 +02:00
Neil Mitchell
9bd78857d8 #2326, GHC 8.4 compatibility (#2796)
* #2326, GHC 8.4 compatibility

* Fix up CI

* Add a Shake lower bound

* Upgrade to a hie-bios which is GHC 8.4 compatible

* Add a GHC 8.4 stack

* Fix HLint again
2019-09-10 14:52:17 +02:00
Andreas Herrmann
bf7fea4f1d hie-core exe: initDynLinker (#2555)
The hie-core tests are flaky in stack. They can fail with the following
error message

```
hie-core: panic! (the 'impossible' happened)\n  (GHC version 8.6.5 for x86_64-unknown-linux):
        Dynamic linker not initialised

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
```

Explicitly initializing the dynamic linker at session startup should
avoid this issue.
2019-09-10 14:52:17 +02:00
Moritz Kiefer
0f0e6740c1 Only report progress when client supports it (#2517)
* Only report progress when client supports it

This fixes an issue that some people encountered when running hie-core
in Emacs with a version of haskell-lsp that does not understand
progress events.

* Fix tests

* More test fixes
2019-09-10 14:52:17 +02:00
Gary Verhaegen
10c59a01c2 update copyright notices (#2499) 2019-09-10 14:52:17 +02:00
Neil Mitchell
16873edb44 hie-core Logging and exceptions (#1933)
* Rename reportSeriousError to reportInternalError

* Stop using logError for logging things that are warnings to the user, not errors by us

* Rename logError

* Sort the log fields properly

* Delete tagAction from Logger

* Strip down the pure logger

* Delete unused pieces of the logger

* A quick check suggests the call stack will be useful in approximately none of the callers of logging, so just remove it

* When reporting an internal error, give as much detail as we can

* Change our logger to be based on Priority values

* HLint fixes

* Rename makeNopLogger

* In hie-core say what level of message you are setting

* Delete the unused makeOneLogger

* Make sure we can show messages floating around

* If a notification/response handler throws an exception, report it upwards

* Remove reportInternalError in favour of a general logging mechanism

* Add missing dependencies

* Just call fail for a dodgy error report

* Add a FIXME

* Make missing modules just an error
2019-09-10 14:52:17 +02:00
Neil Mitchell
72593a285d Make hie-core outside an IDE work better (#1895)
* Move the hie-core demo files around (they aren't really a demo anymore)

* Split the command line parsing into a separate module

* Give messages about how long starting something takes

* Make the interactive mode say what it is doing a bit more

* Add a --cwd flag to hie-core

* Take a list of files and directories for hie-core

* Update the readme to say how to test using hie-core

* Fix up the bazel file

* Add HLint exception
2019-09-10 14:52:17 +02:00