* 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>
* 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
---------
Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* 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>
* 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>
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>
The implementation closely aligns with the original design, extensively incorporating existing code to minimize workload costs. The new API maintains a consistent style with the old API, which remains unchanged.
Features
With new expose stuff:
`KeyNamePath` -- path to search for properties
`definePropertiesProperty` -- define nested property
`usePropertyByPath` -- extract property by path
`usePropertyByPathEither` -- same as above
`usePropertyByPathAction` -- action api for `usePropertyByPath`
`HasPropertyByPath` -- constraint for using `usePropertyByPath` like the `HasProperty`
We can now define properties upon properties to create nested one. And use KeyNamePath to retrieve the property
```
nestedPropertiesExample = emptyProperties
& definePropertiesProperty #parent "parent" (emptyProperties & defineStringProperty #foo "foo" "foo")
& defineStringProperty #baz "baz" "baz"
nestedPropertiesExample2 = emptyProperties
& definePropertiesProperty #parent "parent" (emptyProperties & defineStringProperty #foo "foo" "xxx")
& defineStringProperty #baz "baz" "baz"
examplePath1 = SingleKey #baz
examplePath2 = ConsKeysPath #parent (SingleKey #foo)
```
To retrieve we can have
```
usePropertyByPathEither examplePath2 nestedPropertiesExample object
```
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.
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.
* 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>
* Bump lsp versions
Broadly:
- A few places where we need to pipe `ProgressToken`s around.
- I also just removed the progress reporting from resolve commands,
since it's going to often be costly to do progress reporting on
something that short. Possibly we could revisit after https://github.com/haskell/lsp/issues/549
- Some changes to the registration options we infer
- A few places where we need to adapt to ignoring registrations or not
- Adapting to use the ghcide verison of `getCompletionPrefix` everywhere
- Adapting to use the new mixed rope format
* stack
* More fixes
* Fix warnings in hls-graph, enable pedantic in CI
* Fix build with flags
* stylish-haskell
* Split Key stuff to separate module with explicit export list
* Try the cabal configure suggestion in CI flags job
* Newline fix
* Enable pedantic for all
* Typo
* stylish-haskell
* pedantic is already enabled for all
* Fix error in hls-plugin-api
* Address nitpick, use lsp-types in tests instead
fix https://github.com/haskell/haskell-language-server/issues/3957
Things have been done:
1. Switch `Name` to `Identifier` in the implementation and add `ModuleName` to the `HsSemanticTokenType`
2. Strip ``` ` ` ``` and `()`, and split out qualified names. e.g.``` `Preclude.length` ``` to ```Preclude.``` `length`
3. add tokenizer to walk ast with the souce rope to get more accurate result and faster. Should fix https://github.com/haskell/haskell-language-server/issues/3983.
4. add type sig to semanticConfig's TH result
* Implement semantic tokens lsp plugin draft
* SemanticTokens: combine information extracted from HieAst
* clean up
* map to default token types in lsp
* use lsp makeSemanticTokens to convert to lsp SemanticTokens type
* add test and cleanup
* refine semantic type to default one in lsp
* Use tokens from hieAst instead of renamedSource and add test
* use customize RefMap to get semantic type
* use refMap from useAsts
* Also compute imported names
* Also compute semantic type from TyThing
* Fix dependencies version
* fix version
* Retrieve nameSet from renamedSource to prevent names not visible(Such as by instance deriving) being handled
* add hlint config to ignore test data
* cean up test data
* revert flake.nix
* Rename query.hs to Query.hs
* Build: add semantic tokens to lts21
* Refactor and add README
* Semantic token, filter names in Ast
* CI: add consistancy check for wether semantic tokens computations is stable across different ghc versions
* Update documentation, cleanup test, remove default modifiers
* Fix: IO now classfied to TTypcon, add test for GADT and data family, Update documentation
* Restore stack.yaml
* fix stack build
* Refactor, move out ActualToken to Mappings and use ide logger
* Refactor: toLspTokenType should return Maybe type
* Stop use stale hieAst
* add getImportedNameSemanticRule rule to semantic tokens plugin
* do not retrieve hie in getImportedNameSemanticRule
* fix: add description for semantic tokens
* remove TValBind and TPaternBind and Use TFunction and TVariable instead
* cleanup
* Refactor useWithStaleMT and took care of the token range using position map
* fix build for 9.4
* refactor, use golden test
* refactor, use ExceptT for computeSemanticTokens
* Fix 9.2
* add persistentSemanticMapRule to prevent semantic tokens block on startup
* Fix, use hieKind instead of cast the type directly
* add options to turn semantic tokens on and off
* Disable stan plugin by default (#3917)
* Fix positionMapping in stale data (#3920)
* Fix positionMapping in stale data
* add test for updatePositionMapping
* add comment to demonstrate addOldDelta
* cleanup
* fix: for local variable, extract type from contextInfo instead of bind site, thus function in pattern binds can also be indentified
* clean up
* Update plugins/hls-semantic-tokens-plugin/src/Ide/Plugin/SemanticTokens/Query.hs
Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
* refactor: remove TNothing and compact the test output
* refactor: rename SemanticTokenType to HsSemanticTokenType to avoid confusion with lsp' SemanticTokenTypes
* refactor: push the computation of semantic token type to getSemanticTokensRule
* update documentation
* cleanup hieAstSpanNames
* remove renamed source from getSemanticTokensRule and optimize query function for semantic token type
* try to exclude names that is not visible in hie and cleanup
* add HieFunMaskKind, it is to differ wether a type at type index is a function or non-function
* expose function flag to expose (=>, ->, -=>, ==>)
* 1. Relax GetDocMap kindMap to get TyThing for more than type variables.
2. Backport isVisibleFunArg
* use customize logger, add test for unicode
* fix: handle unicode in semantic tokens
* update KindMap to TyThingMap
* cleanup
* add realSrcSpanToCodePointRange, realSrcLocToCodePointPosition to Development.IDE.GHC.Error
* add Note [Semantic information from Multiple Sources]
* move recoverFunMaskArray to Mappings.hs
* fix test, data.Set might not appear
* fix: handle semantic tokens with more than one ast
* fix: instance PluginMethod Request Method_TextDocumentSemanticTokensFull
* clean up
* turn semantic tokens off by default
* fix doc
* clean up doc
---------
Co-authored-by: fendor <fendor@users.noreply.github.com>
Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
* Merge definitions from all plugins for Document(Type)Definition message
- enables multiple plugins to provide Document(Type)Definition for the same message
* Remove unnecessary head usage in ghcide TestUtils
* Use Nothing for original selection when upgrading Location to LocationLink
in combineResponses of plugins to TextDocumentDefinition message
* Share combineResponses document definition and document type definition tests
* Downgrade locations to links when missing client capability in combineResponses (plugin API)
- Upgrade locations to links only when necessary (some responses are links)
* Test preserving link data in combineResponses of Definition message
* Add haddock to mergeDefinitions in plugin API
* Replace usage of OverloadedRecordDot with lenses
- to support GHC < 9.2
* Add TypeFamilies extension to TypesTests to support GHC < 9.4
* Require focus >= 1.0.3.2 to fix 9.8 build for ghcide and hls-graph
---------
Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
* Fix https://github.com/haskell/haskell-language-server/issues/3847
* Add unit test cases for `Ide.PluginUtils.extractTextInRange`.
* More detailed comment about the issue.
---------
Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Prepare release 2.3.0.0
* release ci: respect ADD_CABAL_ARGS on non-windows builds
* release ci: disable simdutf text for centos
* release ci: disable simdutf text for freebsd
* Fix cabal file of hls-fourmolu-plugin to allow it to be uploaded to hackage
Fixes#3819
* Update ghc version support docs
---------
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* 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
* Fix#3574 and support resolve in explicit records
* render shouldn't fail, added tests
* Improved comments
* Remove unused language extensions
* 8.10 and 9.0 fixes and separate collect names into it's own rule
* fix flags and add Resolve module haddock
* better tests
* works for all ghc versions
* Fix flags
* ignore incomplete record updates in explicit record fields
---------
Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* refactor: Avoids misleading name (renames `extractRange` to `extractOverlappingLinesWithRange`)
* fix: first workaround for qualified imports in GHC 9.4
* fix: stylish-haskell
* fix: stop using Debug.Trace
* refactor: uses `regex-applicative-text` to comply with Haskell 2010 Module Name
* ci: `regex-applicative-text` constraint in nightly CI
* fix: Switches from `regex-applicative-text` to `regex-applicative` (due to version constraints)
* Fixes import list
* doc: Notes on the rationale behind `missing`
* doc: `extractQualifiedModuleNameFromMissingName`
* refactor: extractText-related refactoring
* refactor: Use record wildcards alone
* refactor: cosmetic chagnes around indentation consistency
* fix: Fixes dead export
* Corrects typo (Thanks @fendor!)
Co-authored-by: fendor <fendor@users.noreply.github.com>
* refactor: Makes `mapNotInScope` local and renames to `qualify`
---------
Co-authored-by: fendor <fendor@users.noreply.github.com>