Commit Graph

155 Commits

Author SHA1 Message Date
Michael Peyton Jones
71aa2d38e0
Bump to new lsp versions (#4279) 2024-06-06 13:19:32 +00:00
soulomoon
838a51f761
Refactor hls-test-util and reduce getCurrentDirectory after initilization (#4231)
What's done
* [x] Refactor the `runSession*` family function, properly add `TestConfig`, `runSessionWithTestConfig`, as the most generic `runSession*` function.
* [x] remove raraly used variants of `runSession*` functions and replaced by `runSessionWithTestConfig`. 
* [x] migrate `ExceptionTests ClientSettingsTests CodeLensTests CPPTests CradleTests` to use the `hls-test-utils`
* [x] Only shift to lsp root when current root is different from the lsp root in DefaultMain of ghcide. 
* [x] Remove most usage for `getCurrentDirectory`(After DefaultMain is called), Only remain those in top level of wrapper and exe, implement https://github.com/haskell/haskell-language-server/issues/3736#issuecomment-1924507928
* [x] add Note [Root Directory]

Co-authored-by: fendor <fendor@users.noreply.github.com>
2024-05-27 14:03:43 +00:00
fendor
5deb99605f
Drop Logger from HLS code base. (#4171)
Move ghcide completely to colog-logging style.
Move plugins that were relying on `ideLogger` to colog style logging.
Move opentelemetry to colog-logging style.

This allows us to drop legacy code and unify the logging experience in
HLS.

We add a bunch of new Log constructors at various locations that aim to
be identical to their previous `Logger` statements.
2024-04-16 07:43:26 +00:00
fendor
2ec645d375
Exit with non-zero exitcode if wrapper fails to launch (#4110)
* Exit with non-zero exitcode if wrapper fails to launch

Only when in LSP mode, we want to launch the LSP server that offers the
restart capability.

* Install recommended GHC version for release wrapper tests

---------

Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
2024-03-03 22:38:56 +00:00
Michael Peyton Jones
975db494a2
Use GHC2021 (#4033)
Co-authored-by: Jan Hrček <honza.hrk@gmail.com>
2024-02-02 12:10:51 +00:00
Michael Peyton Jones
2b49d9dd7f
Give plugins descriptions, include versions of key dependencies (#3903)
* Plugins have descriptions

* Plugins based on external tools report the version they are built with

* Sort plugins
2023-12-17 21:33:27 +00:00
wz1000
7db6215c6d
Add support for multi unit argument syntax (#3462)
* Add support for the multi unit argument syntax introduced in GHC 9.4: https://downloads.haskell.org/ghc/9.4.4/docs/users_guide/using.html#multiple-home-units

We now support arguments of the form
```
-unit @unitA -unit @unitB
```

where the response files `unitA` and `unitB` contain the actual list of arguments for that unit:

```
-this-unit-id a-0.1.0.0
-i
-isrc
A1
A2
```

Also refactor the session loader and simplify it.

Also adds error messages on GHC 9.4 if the units are not closed (#3422).

fixes

Fix closure check

session-loader: override old units with new in multi-unit support

Remove implicit-hie

session-loader: remember which files caused old components to be loaded, and
also pass them on to hie-bios so it can in turn pass them to `cabal repl` when
loading newer components.

This allows us to create valid set of build flags encompassing both the old and
new components, and the closure of all components in between.

The observation is that if you want to load some components X, Y, Z and so on,
cabal repl X Y Z ... will be more likely to give you a valid multi component
build plan/flags than cabal repl all, or any way of combining the results of
cabal repl X, cabal repl Y ...

Use new hie-bios

Move implicit cradles to HLS

Fix build on 9.0

Werror

Improve handling of specialTarget

* hie-bios doesn't mention the component name in the message anymore

* stack fixes

* wrapper: remove unused argument

* werror

* werror

* Implicit cradle: match implicit-hie-cradle logic

* Fix eval plugin

* ignore multi unit tests on 9.2

* Some fixes for 9.2

* Add hie.yaml for call-hierarchy-plugin tests

* Add hie.yaml for explicit-record-fields-plugin

* Add hie.yaml for hls-overloaded-record-dot-plugin
2023-11-23 00:08:04 +00:00
Michael Peyton Jones
e4234a3a5e
Adapt to lsp changes for workspace/configuration (#3773)
* Adapt to lsp changes for workspace/configuration

This has a few substantive changes and a lot of messing with tests.

- We now tell `lsp` our config section, and parse just that section.
- We move the logic for updating the shake build rules for client config
  from a `workspace/didChangeConfiguration` handler to the new `lsp`
  callback, which will ensure it gets called in all circumstances that
  can be relevant.

The test changes are more annoying:
- We ignore config and logging messages by default now, so we have to
  stop doing that when we care about it.
- Many tests didn't really need to _change_ the config, but rather just
  to set it once at the beginning. I adjusted a lot of test functions to
  allow passing in the initial config for this reason.

* don't reduce the message timeout for wingman

* Fix stan plugin

* Doh
2023-08-25 14:04:42 +00:00
Nathan Maxson
b6dc425054
Move Recorder to hls-plugin-api (#3714) 2023-07-23 07:38:14 +00:00
Michael Peyton Jones
53604eb494
Add arguments to direct logs to various locations (#3665)
* Add arguments to direct logs to various locations

This adds arguments to HLS to allow the user to select whether to send
logs to any or all of:
- a file
- stderr
- the client

Importantly, we can toggle off the default stderr logging, so the vscode
extension can turn it off to avoid the double logging that arises from
logging to both the client and stderr.

I've set the default to _not_ log to the client. This is a change of
behaviour (today we log to the client by default), but I think it gives
the best experience by default, since most clients do show stderr output
somewhere, and then we probably want to make a case-by-case decision on
whether to use the client logging instead.

* Remove weird test

* Fix warning
2023-06-23 21:45:59 +00:00
Nathan Maxson
a918c02a61
HLS for the new generated LSP 2 release (#3621) 2023-06-19 08:49:38 +03:00
Michael Peyton Jones
408a2afd99
Add a log-level argument to set the log level (#3651)
* Add a log-level argument to set the log level

`--debug` remains as an alias for `--log-level Debug`.

* Fix warning

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2023-06-13 15:11:21 +00:00
Michael Peyton Jones
a951ad3324
Commit to prettyprinter >= 1.7 (#3649)
ghcide already depends on 1.7 which added the new module hierarchy
naming, so let's commit to that and use it throughout. Lets us delete
some CPP, which is always good.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2023-06-12 21:18:12 +00:00
fendor
014c8f9024
Remove hslogger from codebase (#3526)
Co-authored-by: Fendor <walross.power@gmail.com>
Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
2023-03-18 14:46:00 +00:00
Zubin Duggal
b9565a1b5a Use hie-bios 0.12 2023-03-17 19:02:45 +05:30
Pepe Iborra
6f5a73507f
Support optional plugins (#3193)
* Support initial generic config for plugins

This enables opt-in  plugins, i.e. plugins that are not enabled by default

* Support initial generic config for plugins

This enables opt-in  plugins, i.e. plugins that are not enabled by default

* Address review comments and remove optionality in configInitialGenericConfig

I can't remember why this was optional in the first place, which probably means no good reason for it to be

* use defConfig instead of def

* test

* descriptor is the golden source for plugin default configs

Read plugin defaults from plugin descriptor instead of copying into initial config

This is less fragile as now the initial generic config specified in the plugin
descriptor is enforced by construction.

The downside is that now the descriptor is needed to parse the config, which
means a few places where a plugin id was enough now require a plugin descriptor,
which is much harder to get. We paper over this by moving these call sites to
the Action monad.

* redundant import

* simplify

* Build fixes

* Build fixes

* pedantic fixes
2022-12-11 21:11:34 +01:00
Andy
21c8e9b83e
Hlint: A handful of fixes to hints (#3259)
* CI: rwe/actions-hlint-run v2

* fmt script: Fix missing directories

Otherwise will fail

* Hlint: Automatically fix warnings via apply-refact

* Hlint: Do not suggest fromMaybe

Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
2022-10-10 11:47:42 +00:00
Zubin Duggal
816cd6301e Prepare 1.8.0.0
Use hiedb from hackage

gitlab-ci: remove workaround for windows 9.2.2
gitlab-ci: remove workaround for windows 9.2.2

hie-bios

update hie bios

update hie bios

bounds

hie-bios fixes

hie-bios fixes

lsp 1.6

cabal.project fixes

hie-bios fixes

lsp and hie-bios from hackage

Mark hie-bios error as expectFail

hie-bios fixes

hie-bios fixes

Stack

Stack

stack fixes
2022-09-14 02:27:17 +05:30
Pepe Iborra
d0e3e0fe3f
HLS benchmarks (#3117)
* extract ghcide:experiments-types

* extract haskell-language-server:plugins and let go of examples

The main goal here is to move the Plugins module into an internal
library so that it can be reused from the benchmark suite.

In order to
make that easier, and since they hardly serve a purpose in a repository
with 25 plugins, I delete the Example and Example2 plugin descriptors
and their dependencies.

* HLS benchmark suite

Port the ghcide benchmark suite to HLS and benchmark plugin
"configurations" independently.

This includes the following changes to the ghcide benchmark suite and
HLS:
- Support for "configurations" which are defined as sets of plugin ids.
  The benchmark will be run with only these plugins enabled and all
  others disabled
- Support for configurable concurrency. This relies on RTS -ol and -po
  flags to place the RTS traces in the target location rather than in
  the cwd

This change requires two commits, the next one places
ghcide/bench/hist/Main.hs into its final location to help 'git'
recognize the change as a file move

* ghcide/bench/hist/Main.hs -> bench/Main.hs

* CI - fix artifact names for uniqueness

* disable shorten HLS step

* Do not store eventlogs to avoid out of disk space

* render durations up to milliseconds

* shorten titles

Goal is to display the formatted CSV (via column) one row per line

* exclude formatting plugin configurations

* Extract ghcide-bench to a standalone package

* ghcide-bench: fix stderr capturing

* Fix mem stats

We parse maxResidency and allocatedBytes from the RTS -S output, but runSessionWithHandles kills the server without waiting for it to exit and these stats don't get logged.

The solution is to use runSessionWithHandles', but unfortunately it is internal and not exposed. I have raised a PR to expose it and in the meantime we need a source repo package.

* feedbacks

* delete Example plugins
2022-08-25 15:08:57 +01:00
Pepe Iborra
9ef66c9679 Add plugin priorities 2022-08-19 15:49:39 +05:30
Pepe Iborra
c9ed045f7b
Do not send Heap Stats to the LSP log (#3111) 2022-08-18 06:25:01 +00:00
Lei Zhu
49373fd014
Fix #3047 (#3092)
* Make path canonicalized

* Update extra-source-files

* Replace with normalise

* Change to a more detailed log

* Comment patch detail

* 2 spaces indent
2022-08-14 14:44:59 +00:00
Andy
e20b026c50
Probe-tools: Print stack ghc version (#3093)
* Probe-tools: Print stack ghc version

The ghc version on the $PATH is often not relevant for stack projects.
The ghc version stack is using is printed in addition.

* Probetools: cradle ghc version added to wrapper

* Revert stack ghc changes to Ide.Main

* Update exe/Wrapper.hs

Co-authored-by: fendor <fendor@users.noreply.github.com>

* Probe tools: Print version with padded spaces

Addressing <https://github.com/haskell/haskell-language-server/pull/3093#discussion_r944428948>

Co-authored-by: fendor <fendor@users.noreply.github.com>
2022-08-12 15:42:27 +00:00
Kobayashi
255498147a
upgrade lsp to 1.5 (#3072)
* upgrade lsp to 1.5

* fix stack.yaml

* try fix tests

* disable verbose logging in ghcide

* fix more tests in ghcide

* fix floskell test

* disable debug log in func-test

* disable debug log in lsp itself

* Revert "disable debug log in func-test"

This reverts commit 1fd6658c77.

* remove unused import

* fix hls test utils

* upgrade lsp in nix

* fix func-tests

* Revert "fix func-tests"

This reverts commit 2ecd76d0ba.

* fix waitForDiagnosticsFromSourceWithTimeout

* use Null as dummy message in waitForDiagnosticsFromSourceWithTimeout

* simplify a test case

* add comment about lsp bad logs
2022-08-12 09:09:07 +00:00
Lei Zhu
0e74593e8d
hls-explicit-fixity-plugin (#2941)
* init hls-explicit-fixity-plugin

* Update dependencies

* Refactor: Prevent block on startup

* Run pre-commit

* Compatibility: Add emptyMessages

* Remove unused ModIface

* Comment why to make this plugin a lower priority

* Provide hover content while testing fail

* Avoid lambda

* 4 space indent

* Pass Text instead of Name

Co-authored-by: Pepe Iborra <pepeiborra@gmail.com>
2022-08-11 11:48:18 -04:00
Kobayashi
dc682ba118
add a prefix to plugin CPP (#3065) 2022-07-29 10:28:31 +00:00
Dmitry Pogodin
347a7187f2
Run pre-commit hooks (#3059) 2022-07-28 16:48:13 +00:00
Gregory Gerasev
078fc14dda
Stan integration #258 (#2908) 2022-07-28 02:11:31 +03:00
Kobayashi
445192e21d
refactor selection range plugin (#3003)
* update Gitpod config

* update nix shellHook & docs

* install pre-commit hook

* add kokobd as code owner to .gitpod.*

* add gen-hie to Gitpod

* add tools for doc

* remove .pre-commit-config.yaml from .gitignore

* set vscode formatter to stylish-haskell in Gitpod

* refactor selection range plugin

* refine selection range

* add CodeKind to CodeRange

* rename hls-selection-range-plugin to hls-code-range-plugin

* update docs about selection range

* cleanup RuleTypes.hs

* add the missing bang pattern

* fix subRange

* add some unit tests to CodeRange.Rules

* add tests for removeInterleaving

* add even more tests

* fix extra sources

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-07-11 04:24:35 +00:00
Stefan Matting
cdc8f78a98
Turn HLS-wrapper into an LSP Server (#2960)
* Make wrapper a LSP on failure

* Fix incorrect imports

* revert import block for smaller diff

* add missing imports

* Fix: callProcess on win32 machines not called

* import container only on win32

* add missing liftIO

Co-authored-by: Pepe Iborra <pepeiborra@gmail.com>
2022-06-26 11:39:07 +00:00
fendor
907a6e645b
Teach HLS about different file extensions (#2945)
* Fix parameter switch-up

* Generalise file extension handling for plugins

NotificationHandler now distinguishes between different file extensions
RequestHandler distinguishes between different file extensions

* Introduce PluginMethod Typeclass hierarchy

The hierarchy looks as follows:

            PluginMethod (pluginEnabled)
                          |
         -----------------------------------
         |                                 |
 PluginRequestMethod             PluginNotificationMethod

* Add example plugin

* Improve documentation for plugins

* Simplify Plugin Handling code

Co-authored-by: Jana Chadt <jana.chadt@nets.at>
Co-authored-by: Jana Chadt <jana.chadt@tuwien.ac.at>
Co-authored-by: Fendor <walross.power@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-06-22 15:38:13 +00:00
Akshay Mankar
2121495209
hls-class-plugin: Only create placeholders for unimplemented methods (#2956)
* hls-class-plugin: Only create placeholders for unimplemented methods

* hls-class-plugin: Add logs
2022-06-20 02:46:29 +00:00
George Thomas
09968a1567
More Fourmolu improvements (#2959)
* Use proper structured logging for Fourmolu

Previously we just printed directly to stdout and stderr.

* Don't run Fourmolu in debug mode

It prints to stderr, due to uses of `traceM`, and it's not nice to work around this downstream.

It's of questionable utility anyway. The fact that it mostly prints information about extensions, and does so in a hard-to-read format (a string displayed as a list!) indicates that it probably isn't widely used.

* Fourmolu: parse strings to integers before comparing versions

Whoever originally wrote this (😳) had clearly had one too many beers the night before: `show @Int` is not monotonic since e.g. "10" < "2".
2022-06-17 13:31:31 +00:00
Nick Suchecki
8f68882f81
Add throwPluginError to Plugin Utilities (#2924)
* Add new PluginUtility function.

Add the function `throwPluginError`. This function is intended to
provide a common `ResponseError` message for use in logging.

Renamed `response` to `pluginResponse` for more clarity.

* Call hierarchy clean up

* Make Descriptor usable as String/Text or PluginID

* Update reference to ChangeTypeSignature descriptor

* Use unpack rather than show

* Import cleanup

* Merge cleanup

* Fix test suites for effected plugins

* forgot to change the CodeAction kind in the test suite...

* Update new plugin
2022-05-27 15:11:08 +00:00
Lei Zhu
faa88f685e
A plugin for GADT syntax converter (#2899)
* initial hls-gadt-plugin

* Correct condition

* Render context correctly

* Fix typo

* Support from ghc-8.6 to ghc-9.0

* ghc8.6 compat

* Try to fix test for ghc-8.6

* Pretty name

* Add GADTs pragma automatically

* Enrich Readme

* Clean up

* Update hls docs

* Update CODEOWNERS

* Fix typo

* Rename withTempDir with withCanonicalTempDir

* Add @michaelpj's suggestions

* Pass PluginId through descriptor

* Explicit forall
2022-05-26 17:13:09 +08:00
Pepe Iborra
65fbc5e41c
Restore compat. with prettyprinter 1.6 (#2877) 2022-05-01 15:58:43 +00:00
wz1000
3c24c20c5d
Avoid race conditions with VFS and VFS versions (#2789)
* Avoid race conditions with VFS and VFS version

We need to take VFS snapshots as soon as we get a change notification.

Consider the following interleaving of events:

1. Change Notification A (updates LSP VFS)
2. Restart Shake Session (A changed) initiated
3. Change Notification B (updates LSP VFS)
4. Restart Shake Session (A changed) takes VFS snapshot and possibly performs more computation
5. Restart Shake Session (B changed)

In particular, between step 3 and 5, we took a snapshot for a previous build,
but this snapshot included changes from a newer VFS state that the build should
not have seen.

To fix this, we need to take snapshots as soon as a notification handler is
called, before forking any threads. This works because LSP calls all handlers
in a single threaded fashion and these handlers block message processing. It
is essential to this on the LSP handler thread rather than the reactor thread
that GHCIDE sets up in order to maintin the property.

* Disable flaky test 'add missing module (non workspace)'
2022-04-16 20:43:44 +00:00
Michael Peyton Jones
82a3cd5640
Refactor LSP logger and log via window/logMessage also (#2758)
* Refactor LSP logger and log via `window/logMessage`

* Skip logging notifications in tests

Co-authored-by: Pepe Iborra <pepeiborra@gmail.com>
2022-03-08 17:56:32 +00:00
Julian Ospald
73fdd91e5a
Fix the tower of Babel (#2757) 2022-03-06 21:24:51 +00:00
Pepe Iborra
30b3fec2f0
Adjust rendering of error logs and drop unneeded MonadUnliftIO instance (#2755)
* drop unneeded MonadUnliftIO instance

* Adjust error message

* fixups
2022-03-06 14:29:20 +00:00
Pepe Iborra
5afb0770c9
LSP window message log recorder (#2750)
* failing to set the unsafe dynflags is an error

* makeLspRecorder

* include link to the issue tracker

* avoid double popup

* catch another ghc lib dir error
2022-03-06 09:18:46 +00:00
Nick Suchecki
911fe59d7f
Change Type Signature Plugin (#2660)
* First go

* Match against specific error message.

* Basic Change Type Signature implementation.

This implementation only matches a single GHC Error message:

```
    • Couldn't match type ‘Int’
                     with ‘Data.HashSet.Internal.HashSet Int’
      Expected type: Int -> Int
        Actual type: Data.HashSet.Internal.HashSet Int -> Int
    • In the expression: head . toList
      In an equation for ‘test’: test = head . toList
```

Specifically on `Expected type: ...`, `Actual type:...` and `In an equation ...`.

There are plenty of error messages that match this format but aren't actually valid.

* GHC 9.2.0 compat change

* Lift expectedError message into a separate binding

* Move ChangeTypeAction into it's own plugin

* Add New Error Message parsing.

- Add new regex for matching extra errors message types

- Revamp original regex to match more.

- Add basic test suite.

- Begin adding `tidyActualType` semantics to provide slightly prettier
TyVars

* Added Error Message Validation to ignore bad Messages.

- Add Pretty Printing for Types
- Added a few test scenarios

* Miscellaneous Cleanup.

* Update Tide Type Signature logic.

- Be able to tidy signatures with operators in it
- Use T.words instead of regex matching to split tyVars

* Remove locA (defaults to id in 8.10) to satisfy 9.0+

* Touch up 9.2.1

* Clean up review notes

* Update stack.yamls

* Fix copy-paste error

* Fix Local Signature resolution

* Improve logging (#2558)

* convert to contravariant logging style part 1, uses additional hardcoded log file to see it side by side with original logging

* convert Session to contravariant logging style

* convert Plugin/HLS and FireStore to contravariant logging style

* convert Rules (and most of the universe) to contravariant logging style

* fix tests, allow old style logging and contravariant logging to write to same log file

* fix import inside wrong CPP

* add CPP for LogTactic constructor

* remove redundant import

* fix ghcide tests

* remove unused import

* fix plugin tests

* LSP_TEST_STDERR should apply to contra logger as well

* fix tactic plugin test

* use CPP for Log datatype plugin constructors, remove unused imports

* add a few Pretty instances, add prettyprinter to haskell-language-sever and hls-plugin-api dependencies

* add Pretty Log instances for Session, FileStore, Notifications

* add remaining Pretty Log instances

* add logToPriorities

* fix slight interleaving issue with hslogger and logger both logging, have default logger be mutex stderr or file handle, use stderr if failing to open log file

* forgot to add .cabal files with hslogger dep

* dont use UnliftIO file IO helpers because they are too new

* remove log helper comments, use Doc instead of Text as final console/file logger input, renaming, export Log constructors

* remove accidentally added useless file, removed prettyprinter dep from hls-plugin-api because stack ghc8.6.5 doesnt have it?

* use deprecated prettyprint modules import for the sake of circleci ghc-8.6.5

* use dummy stderr logger for plugin cli commands, use priorityToHsLoggerPriority function instead of manual mapping

* remove old plugin detritus that somehow got committed

* fix prettyprinter imports for 8.6.5

* try enforcing prettyprinter bounds?

* enforcing bound makes no sense

* maybe changing stack yamls does trick

* filter out warnings when their diags are empty to more closely match original

* add ability to select wanted logging columns, match prev ghcide exe logging behaviour

* dont log anything when diags are empty in some defineEarlyCutoff versions

* use non-deprecated prettyprinter imports

* fix ghcide test module

* change logWith to accept priority at call site, remove all logToPriority functions, add cmapWithPrio that contramaps through WithPriority

* remove useless hiding import list, add comments to default recorder makers

* make cradleToOptsAndLibDir take concrete cradle to remove existential type var in Log constructor

* Types.Logger now re-exports prettyprinter, remove unused dependencies on prettyprinter and hslogger

* existential type var to remove boilerplate in Plugins.hs, remove a few Show instances

* add SourceLoc logging column, inline logToDoc functions, add comment explaining hslogger setup existence

* qualify a name to match original source

* fix -WError

* Delete the Telemetry log level (#2727)

It's a bit non-standard, and moreover it's entirely dead.

* Wall and 9.2 fix

* Remove unneeded comments/code

Co-authored-by: J. S <shenjonathan0@gmail.com>
Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
Co-authored-by: Pepe Iborra <pepeiborra@me.com>
2022-03-03 23:08:42 +00:00
J. S
3b687a52ac
Improve logging (#2558)
* convert to contravariant logging style part 1, uses additional hardcoded log file to see it side by side with original logging

* convert Session to contravariant logging style

* convert Plugin/HLS and FireStore to contravariant logging style

* convert Rules (and most of the universe) to contravariant logging style

* fix tests, allow old style logging and contravariant logging to write to same log file

* fix import inside wrong CPP

* add CPP for LogTactic constructor

* remove redundant import

* fix ghcide tests

* remove unused import

* fix plugin tests

* LSP_TEST_STDERR should apply to contra logger as well

* fix tactic plugin test

* use CPP for Log datatype plugin constructors, remove unused imports

* add a few Pretty instances, add prettyprinter to haskell-language-sever and hls-plugin-api dependencies

* add Pretty Log instances for Session, FileStore, Notifications

* add remaining Pretty Log instances

* add logToPriorities

* fix slight interleaving issue with hslogger and logger both logging, have default logger be mutex stderr or file handle, use stderr if failing to open log file

* forgot to add .cabal files with hslogger dep

* dont use UnliftIO file IO helpers because they are too new

* remove log helper comments, use Doc instead of Text as final console/file logger input, renaming, export Log constructors

* remove accidentally added useless file, removed prettyprinter dep from hls-plugin-api because stack ghc8.6.5 doesnt have it?

* use deprecated prettyprint modules import for the sake of circleci ghc-8.6.5

* use dummy stderr logger for plugin cli commands, use priorityToHsLoggerPriority function instead of manual mapping

* remove old plugin detritus that somehow got committed

* fix prettyprinter imports for 8.6.5

* try enforcing prettyprinter bounds?

* enforcing bound makes no sense

* maybe changing stack yamls does trick

* filter out warnings when their diags are empty to more closely match original

* add ability to select wanted logging columns, match prev ghcide exe logging behaviour

* dont log anything when diags are empty in some defineEarlyCutoff versions

* use non-deprecated prettyprinter imports

* fix ghcide test module

* change logWith to accept priority at call site, remove all logToPriority functions, add cmapWithPrio that contramaps through WithPriority

* remove useless hiding import list, add comments to default recorder makers

* make cradleToOptsAndLibDir take concrete cradle to remove existential type var in Log constructor

* Types.Logger now re-exports prettyprinter, remove unused dependencies on prettyprinter and hslogger

* existential type var to remove boilerplate in Plugins.hs, remove a few Show instances

* add SourceLoc logging column, inline logToDoc functions, add comment explaining hslogger setup existence

* qualify a name to match original source

* fix -WError
2022-02-20 21:50:28 +00:00
Julian Ospald
5271f6312c
Improve wrapper cradle errors (#2711)
* Improve wrapper cradle errors

* Refactor cradle result unpacking

* Fix runGhcCmd when NoImplicitPrelude is on

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-02-14 21:58:27 +00:00
Julian Ospald
a96b623c2b
Implement distribution of dynamic builds (#2675) 2022-02-11 07:54:09 +00:00
Kobayashi
310e6a4683
support selection range lsp feature (#2565)
* add selection range support

* add the whole import area as a selection step

* add selection range plugin to all project files

* merge type signature with value definition

* support ghc 9

* fix it for ghc-9.0

* remove unnecessary import

* reformat GhcIde.hs

* selection range: make it easier to understand

* selection range: improve error handling

* update lsp-types to 1.4.0.1

* add selection range to doc

* fix comment for findSelectionRangesByPositions

* remove a use of partial function

* update author & maintainer

* use foldlM1 instead of foldl1

* add testdata to cabal file

* update performace tips and log level

* update lsp-types in nix

Co-authored-by: Pepe Iborra <pepeiborra@gmail.com>
2022-01-24 13:13:56 +00:00
Nick Suchecki
1a74937ca5
HLS Plugin to provide Alternate Literal Formats. (#2350)
* Initialize and Setup Plugin Source.

* Provide Traversal Module to Haskell AST that collects Literals.

* Change Literals module to return type.

Update our parsing module to return the data type we will use in our
plugin.

The datatype: Literal

Constructors:

Overloaded - Contains an overloaded literal with a SrcSpan

NonOverloaded - Contains non-overloaded literals with a SrcSpan

NoLocation - currently unused.

This data type is bound to change. This module is designed to capture
ALL numeric literals for use in the plugin. When parsing Haskell source
tree, certain cases result in getting a plain `Expr`. This means it is
not annotated with a SrcSpan. As a result, we pass along a SrcSpan
through most functions to keep track of the most recent SrcSpan
encountered. This isn't a fool proof plan and may be removed in the
future.

* Implement Logic for actual CodeActions.

The traversal of Haskell source has been turned into a rule. This rule
generates hidden diagnostics which allow a user to run a code action
over (most) literals.

There is some "dead code" in the sense that some literals (prims to be
exact) are not allowed to be changed, despite existing in code. The
other "dead code" exists in the FormatType type. Certain extensions
exist that alter how numbers are shown or act, we make note of those
extensions but call them "NoFormat", which essentially means it's a
NOOP.

Most of the conversion is done via the Numeric module. There are plenty
of "show" functions that provide the translation of numbers into the
various formats. The only custom format is a slightly "dumb"
NumDecimal-extension-function that generates three separate options,
instead of using a numeric defined function.

* Clarify source code comments. Reformat file structure.

* Set up Test Scaffolding.

* Miscellaneous clean-up.

* Use Regex to Match Source Text.

* Remove unneccessary diagnostics from Rule.

* Update all stack versions to include new Plugin.

* Clean up Conversion.hs and AlternateNumberFormat.

Clean up function names and add supporting haddock documentation for
exported functions.

* Update cabal file bounds and add Github workflow test

* Add plugin package to all cabal.project

* Add plugin to test suite

* Push SYB changes. Test.hs is merely for testing and will be removed prior to Merge.

* Use Generics.SYB for parsing Literals from GHC Source.

Updated Literals.hs to use custom SYB traversal of the AST.

* Update hls-alternate-number-format-plugin.cabal

* WIP: run tests

* Test additions and GHC compatability changes.

* Removed dead code.

PrimLiterals were defined originally, however GHC source doesn't provide
the source text. This is one of the needs of the plugin so we don't
provide duplicate suggestions.

Swapped `Maybe Text` to `Text`. Similar to above we now ignore all
literals that have no source text attached.

Swapped `Maybe SrcSpan` to `RealSrcSpan`. Again, similar to the previous
points we now ignore literals that don't get a sourceSpan attached.
Similarly, we drop any `UselessSpan`'s as those are also not very
helpful.

* Use Set to remove duplicates from CollectLiterals Result.

Certain AST representations are traversed multiple times with the switch
to SYB. Using Set allows to easily remove duplicate Literals from our
result.

Added a test suite to monitor for regressions.

* Delete Test.hs

Inadvertently commit this file.

* Add README and bump version to 1.0.0.0.

* Update HLS cabal file for version change.

* Additional Tests.

* Update Test file to use Path library function.

* Miscellaneous Code Fixes.

- Remove unneeded imports/functions.

- Export only specified functions from each module (and add Haddock
  Comment if necessary)

- Minor text changes for accuracy

* Add README to Extra Source Files.

* Update Extra Source Files to include Test Haskell Source files.

* Update Features.md and Minor Bug Fix :)

* Add new plugins to hackage workflow

* Fix Bug caused by Minor Bug Fix.

Co-authored-by: jneira <atreyu.bbb@gmail.com>
Co-authored-by: Fendor <power.walross@gmail.com>
2021-12-01 14:12:06 +00:00
J. S
d0ccc2f9f3
Qualify imported names plugin (#2355)
* actual initial qualify imported names implementation

* renamed and added tests for QualifyImportedNames plugin

* fix backtick and parenthesized operators not being qualified correctly

* add tests, and remove logging

* add license, readme, and demo

* remove old demo, add slightly better demo

* remove old mp4 demo, add slightly gif demo

* update readme to use demo

* readme typo

* slight rewording of readme

* slight rewording of readme 2

* remove Demo header from readme

* don't need ShakeExtras and remove some more logging stuff

* hopefully fix ghc 9 differences, rename plugin cabal file

* forgot comma on module re-export

* minimize imports

* fix Hashmap import for ghc <= 8.8, remove unused extension pragmas

* fix hls-qualify-imported-names ghcide bound

* add test suite to CI

* add more tests for qualify imported names plugin

* change ghcide bound to match what @hololeap is doing

* add qualify imported names to feature list

* add demo, readme, test files, test hie.yaml to extra source files

Co-authored-by: Javier Neira <atreyu.bbb@gmail.com>
2021-11-29 17:58:25 +00:00
Oliver Madine
28222e9005
New rename plugin implementation (#2108)
* initial commit

project structure
initial test cases
directly modify source to rename references

* code style

* enable for ghc < 8.8.0

* remove aeson from build-depends

* update support

support ghc9
revert retrie version bump
disable feature by default

* enable plugin for testing

* fix test.yml

* code style, ghc9 retrie bump

remove unnecessary flag in test.yml
consistent indentation
increase retrie version for ghc 9.0.1 (decreased by mistake)

* avoid using Data.List.nub

* code style

fix typo in indentation test
break lines at 100 chars
rename some vars

* code style / performance

remove Retire dependency by using exactprint directly
group references by file to increase speed of checking `elem` per file
add test cases (typeclass, let expression)
add some documentation
fix bug when looking up reference in HieDb
improve error messages
rename some function / vars

* replace GhcPlugins import with Name import

* use GHC.Types.Name for ghc >= 9.0.1
2021-08-21 20:06:53 +02:00
Lei Zhu
d815d0474d
Call hierarchy support (#1955)
* Initialize structure

* Add basic tests

* prepareCallHierarchy

* Add prepare call hierarchy tests

* Prepare call hierarchy support

* add outgoing calls

* Rename incoming to outgoing

* Add incoming calls support

* Fix panic error caused by parameters

* Prepare callhierarchy tests

* Duplication items support

* Format and add missing components for review

* Use local lsp

* Add CI test

* Fix typo

* Add flag for 9.0.1

* Change lsp repo

* Fix query error in data declaration

* Add incoming/outgoing call tests

* Add flag for test ghc 9.0.1

* Ignore test on 9.0.1

* Add 9.0.1 test

* Specifying lsp for cabal

* Refresh hiedb before incoming/outgoing calls

* Add moduleUnit on ghc 9.0.1

* Compatible with ghc 9.0.1

* Add missing qualifier

* Remove ghcide capability test
2021-07-27 22:40:04 +01:00