* Jump to instance definition and explain typeclass evidence
* improve hover rendering
* Add "Goto Implementation" LSP handler
Adds the necessary instances for handling the request type
`Method_TextDocumentImplementation`.
Further, wire up the appropriate handlers for the "gotoImplementation"
request.
* Add docs for 'Jump to Implementation' request
* Add Tests for 'Goto Implementation' feature
* Add pretty link for source location to hover
* Improve documentation for Evidence tree rendering
Also, add extensive note about skipping 'EvLetBinding' evidence nodes.
* Remove unused test code with helpful error message
---------
Co-authored-by: Zubin Duggal <zubin.duggal@gmail.com>
* Change return type of getFileContents from Text to Rope
- This avoids a few conversions between Rope and Text in the next commit
- Note: Syntactic changes to Development.IDE.Plugin.CodeAction around line
2000 are to work around the following stylish-haskell failure:
plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs: <string>:2002:5:
error: [GHC-58481]
parse error (possibly incorrect indentation or mismatched brackets)
* Get virtual files from the Shake VFS in plugins
This commit changes plugins to get virtual files from the Shake VFS
rather than from the language server's VFS.
- Replace `Ide.Types.pluginGetVirtualFile` with
`Development.IDE.Core.FileStore.getFileContents`
- Replace `Ide.Types.pluginGetVersionedTextDoc` with
`Development.IDE.Core.FileStore.getVersionedTextDoc`
* Rename `getFileContents` to `getFileModTimeContents`
* Add util functions for common cases of Shake VFS file access
* Cleanup
* Fix warning
* Install notification handlers for cabal files
The cabal formatters read the file contents from the shake VFS. Thus, we
need to make sure there are notification handlers that add the cabal
files to the VFS!
Formatters have to depend on the `hls-cabal-plugin` to have the
necessary notification handlers installed during test time.
---------
Co-authored-by: soulomoon <fwy996602672@gmail.com>
Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
Co-authored-by: Fendor <fendor@posteo.de>
Co-authored-by: fendor <fendor@users.noreply.github.com>
* Provide explicit import in inlay hints
* Filter explict imports inlay hints by visible range
* Update lsp dep by source-repository-package
to writing test before new release of haskell/lsp.
* Add test for hls-explicit-imports-plugin inlay hints
* Comment inlay hints start position
* Use `isSubrangeOf` to test if the range is visible
* Remove inlayHintsResolveProvider placeholder for now
* Use explicit InlayHintKind_Type
* Revert "Update lsp dep by source-repository-package"
This reverts commit 245049a580.
* Combine InlayHints by sconcat them
and remove `instance PluginRequestMethod Method_InlayHintResolve`
since have not decide how to combine.
* compress multiple spaces in abbr import tilte
* update test to match inlay hints kind
* rename squashedAbbreviateImportTitle to abbreviateImportTitleWithoutModule
* Request inlay hints with testEdits
* ExplicitImports fallback to codelens when inlay hints not support
* fix explicitImports inlayHints test
* simplify isInlayHintsSupported
* comment fallback
* empty list instead of null codeLens
* clearify name `paddingLeft`
* fix clientCapabilities
* add test for inlay hints without its client caps
* use codeActionNoInlayHintsCaps to avoid error
* simplify isInlayHintSupported
* comment about paddingLeft
* use null as inlay hints kind
* add tooltip for explicit imports inlay hints to improve UX
* chore comments
* refactor
* comment InL [] to indicate no info
* ignore refine inlay hints
* add plcInlayHintsOn config
* update func-test
* keep order to make Parser works
* always provide refine in code lens
* init explicit record fields inlay hints
* dotdot location in label part
* update test for dotdot location in label part
* get(Type)Definition with its Identifier
* add flipped filterByRange
* filter label with name
* update test
* re-generate schema
* fix explict-record-fields plugin in GHC 910
* fix use correct currentPosition
* comment
* rename flippedFilterByRange to elementsInRange
* refactor: lift
* refactor: break pointfree
* refactor
* recover accidentally deleted macros
---------
Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
If you click go-to definition on the field under `exposed-module` or `other-module`
it will open the file where this module was defined.
The go-to definition function compares the highlighted text with modules in the cabal file.
If there is a match, it takes the respective build target and tries to fetch their `hsSourceDirs` from the `PackageDescription`. (by looking at all `buildInfos` with matching names).
After finding them, it constructs a path using directory where the cabal file is located, the info from `hsSourceDirs` and a name of the module converted to a path.
If the file exists it returns the `Definition` with the acquired location.
---------
Co-authored-by: fendor <fendor@users.noreply.github.com>
Co-authored-by: Chrizzl <hochrainer.christoph@gmail.com>
Co-authored-by: VeryMilkyJoe <jana.chadt@nets.at>
If HLS detects a message like "module `Bla.Bla.Bla` is a member of a hidden package `bla-1.2.3`" it suggests a quick fix, that finds the closest cabal file and adds the dependency there.
Solution uses [`Distribution.Client.Add`](https://hackage.haskell.org/package/cabal-add-0.1/candidate/docs/Distribution-Client-Add.html) from the `cabal-add` and automaticly adds version requirement, if it's detected.
For now, the `cabal-add` project was linked using [remote package specification](https://cabal.readthedocs.io/en/3.4/cabal-project.html#specifying-packages-from-remote-version-control-locations). Some parts were heavily inspired by the `cabal-add` code in the main module and might be rewritten later.
`CodeAction` works by parsing all haskell diagnostics, and is constructed if a suited message was found. Parsed information is passed down to a new command, which itself uses tools provided by `cabal-add`. The command conducts IO actions with found cabal file.
* WIP: Speed up hls-hlint-plugin-tests
Move test data to temporary directory.
Avoid `waitForDiagnosticsWithSource` as it unconditionally waits for
diagnostics.
* use captureKickdiagnostics for cabal plugin
* fix hlint-plugin resolve tests
* haskell-stylish fix
* fix unused imports
* fix unused imports, unused defs
* resolve conflicts with master with refactor kickSignal
* remove redundant imports
* remove more redundant imports
* refactor kicks to use runWithsignal
---------
Co-authored-by: Fendor <power.walross@gmail.com>
Add code action for incorrect field names in cabal files
The codeactions will suggest possible corrections for unknown field names in a cabal file.
---------
Co-authored-by: Fendor <fendor@posteo.de>
Co-authored-by: Jana Chadt <jana.chadt@nets.at>
* Prepare release 2.9.0.0
* Bump 'bytestring' version for release CI test scripts
The older 'bytestring-0.11.1.0' version doesn't compile with the recent
GHC 9.10.1 release. Bump the version to '0.12.1.0' which can be
successfully compiled on all supported GHC versions.
* Update supported GHC version table
* Move plugin ghc support conditionals into .cabal file
Having them in the cabal.project file is a very neat way to
enable/disable a plugin, but it negatively affects Hackage users as they
can no longer trivially install HLS from Hackage.
This discussion might be revisited in the future, but not during a
release process.
* Disable tests and benchmarks in release test pipeline
On some platforms, building bytestring-0.12.1.0 is not fully supported
yet. Hence, we disable tests and benchmarks, to allow building on the
platform Windows with GHC 9.10.1.
* Always show debug output in release test ci
* Upgrade cabal version in the release pipeline
* Switch to `text` for release test package
---------
Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
At the moment import fields always suggest any common stanza names
occuring in the file, while it should be only the ones defined before
the cursor position.
Also moves all CabalFields utility into a separate module
Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
* Support for 9.10
This includes supports for all plugins, other than formatters and hlint.
We need ghc-exactprint and retrie release before merging this.
* Remove indexed-traversable allow-newer
* Fix couple of warnings
* Fix flags job for hls-graph
* foldl' exposed from Prelude since base 4.20
* Fix flags job for hls-plugin-api
* Fix ghcide hover test
* Fix flags job for hls-eval-plugin
* unzip since 4.19
* More pedantic fixes
* Don't CPP in tests, fix another test
* Switch to ghc-exactprint and witherable from hackage
* Fix all warnings in hls-refactor-plugin
* Remove more no longer necessary allow newers
* Fix all warnings in hls-gadp-plugin and hls-qualify-imported-names-plugin
* Remove allow-newer for boring
* Bump to lsp 2.6, remove more allow-newers
* outline tests
* disable simple plugin on 9.10
* Remove allow-newer for ghc-trace-events
* fix appendConstraint
* stylish
* Remove commutative-semigroups and monoid-subclasses from allow-newer
* Remove free from allow-newer
* Fix 'type wilcard actions' tests
* Remove hie-bios from allow-newer
* Fix suggestNewDefinition tests
* Revert "Fix suggestNewDefinition tests"
This reverts commit 2f3300e964.
* Remove makeDeltaAst breaking tests unrelated to addArgument
* Fix 79 code action tests
* Fix 12 more tests
* Remove co-log-core from allow-newer
* Fix 21 more tests
* Fix 8 import disambiguation tests
* fix windows ghcide tests
* Fix adding argument to function body
* update retrie commit, progress in add argument tests
* Fix few stylish-haskell parse errors
* Fix remaining redundant constraint tests
* Remove allow-newer for constraint-extras
* Fix warnings after master merge
* Fix most add argument tests except for one
* Remove dependent-map from allow-newer
* Try removing some allow-newers from lsp
* Ormolu is updated, add links for other tool dependencies
* Revert "Try removing some allow-newers from lsp"
This reverts commit 6f60029ff2.
* Try this
* Fix all gadt plugin and most class plugin tests, enable 2 tests for ghc 9.4+
* Undo spurious changes
* Update eval plugin tests
* Disable broken refactor plugin test for now
* Fix warnings
* Add source-repository-package to unblock floskell
* Make call hierarchy plugin tests green
* fix semantic tokens 9.10
* Fix remaining class plugin test
* Update hls-change-type tests
* Make class plugin more robust
* Fix stylish parse errors, simplify CPP
* Cleanups
* Remove retrie dep from hls-refactor-plugin
* More retrie fixes
* Fix cabal-plugin-tests by respecting maxCompletions client cfg + a bit of CPP
* Fixup ghcide-tests
* disable retrie, splice and floskell plugins for 9.10
* Update tested-with + fix import warning
* Fix stylish
* Fix compilation with 9.2.8, fix stack jobs
* Remove no longer relevant :type +v test
* Disable tests of disabled plugins in CI
* Try a better broken specifier?
* Fix invalid CI config
* Use getClientConfigAction instead of introducing new HandlerM action
* Move CPPd imports to prevent stylish from evaluating CPP
* Disable stan tests with ghc 9.10 in CI
* attempt fixing exactprint <9.10
* Try enabling fourmolu now
* Revert "Try enabling fourmolu now"
This reverts commit 7142686f62.
* Update code-range-plugin tests
* Fix No newline at the end of file
* Use more recent cabal-gild
* Try setting some linker flags for macos
* Ignore non-local variable completion test on windows for GHC 9.8
---------
Co-authored-by: Jan Hrček <honza.hrk@gmail.com>
Co-authored-by: Patrick <fwy996602672@gmail.com>
Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
Co-authored-by: Fendor <fendor@posteo.de>
Instead of custom parsing of the cabal file, we use `readFields` to parse
the cabal file, as accurately as cabal supports. This allows us to
additionally benefit from future improvements to the cabal lexer.
Then, we traverse the fields and find the most likely location of the
cursor in the cabal file.
Based on these results, we can then establish the context accurately.
Further, we extend the known rules for the cabal plugin, to avoid
expensive reparsing using `readFields`.
Co-authored-by: VeryMilkyJoe <jana.chadt@nets.at>
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>
* Another attempt at using the lsp API for some progress reporting
* Fixing tests
* Remove trace
* Make splice plugin tests not depend on progress
* More test fixing
* Switch to hackage
* stack
* warnings
* more
* Put tests back
---------
Co-authored-by: Patrick <fwy996602672@gmail.com>
We add an option to `Config` that allows clients to specify how HLS
should load components.
We support two loading strategies:
* SessionLoadSingleComponent: Always load only a single component
when a new component is discovered.
* SessionLoadMultipleComponents: Always allow the cradle to load
multiple components at once. This might not be always possible,
e.g., if the tool doesn't support multiple components loading.
The cradle decides how to handle these situations.
By default, we use the conservative `SessionLoadSingleComponent` mode.
Additionally, changing the config at run-time leads to a reload of the
GHC session, allowing users to switch between the modes without
restarting the full server.
* Mark plugins as not buildable if the flag is disabled
This ensures that cabal does not consider them at all, and won't try to
solve for their dependencies. So if we turn off the fourmolu plugin, cabal
really won't consider fourmolu at all.
This gets us some of the benefits of #4156 with much less work.
Fixes#4100.
* Stick to no space after flag for consistency
* Add cabal-gild as a cabal file formatter plugin
* Add support for multiple cabal formatters
In addition, allow different cabal file formatter provider to specify an
explicit file path, instead of searching only on $PATH.
* Fix cabal formatter test flags
* hls-notes-plugin: Initial implementation
* hls-notes-plugin: add to feature list and plugin table
* hls-notes-plugin: Add more documentation comments
* hls-notes-plugin: Fix tests after #3846, add CI job
* hls-notes-plugin: Address review comments
* hls-notes-plugin: Allow Note definition within single line comments
* hls-notes-plugin: Improve "Note not found" error message
* hls-notes-plugin: Allow single line notes to be indented
* treewide: Add missing underscores to note definitions
* hls-notes-plugin: Wait until HLS is done in tests
* hls-notes-plugin: Fix tests on windows
The regex did not allow windows line endings in note definitions
---------
Co-authored-by: Jan Hrcek <2716069+jhrcek@users.noreply.github.com>
Co-authored-by: fendor <fendor@users.noreply.github.com>
Fix bench for newer ghc versions
The following have been done:
1. No longer use the implicit-hie to generate the hie.yaml for the bench examples and in favor of using "cradle:\n cabal:\n", seems to be working with modern cabal.
2. upgrade benchmark to use 9.6, 9.8 (The latest two we support for now).
3. upgrade bench examples to `Cabal version: 3.10.2.1, lsp-types version: 2.1.1.0`
4. fix minor error that `*.hp` files duplicates its extension name
---------
Co-authored-by: fendor <fendor@users.noreply.github.com>
* Remove bitrotted CPP gated code
A lot of the HLINT_ON_GHC_LIB gated code has been bitrotting since this
flag was removed. This could be reintroduced if we wanted to directly
work on the same parsed AST, but as the hlint ghc plugin showed this
may not make much difference: https://www.haskellforall.com/2023/09/ghc-plugin-for-hlint.html
* Reintroduce ghc-lib flag for hlint plugin
The ghc-lib flag was removed in haskell#3015, but it's still useful to
be able to compile hls-hlint-plugin using the GHC API if you've done so
for hlint and ghc-lib-parser-ex, rather than using ghc-lib-parser as it
simplifies the build and dependencies.