Skip to content

Commit 310e6a4

Browse files
Kobayashipepeiborra
andauthored
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 <[email protected]>
1 parent 6123268 commit 310e6a4

35 files changed

+838
-88
lines changed

.github/workflows/hackage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
"hls-refine-imports-plugin", "hls-retrie-plugin",
3333
"hls-splice-plugin", "hls-tactics-plugin",
3434
"hls-call-hierarchy-plugin", "hls-alternate-number-format-plugin",
35-
"hls-qualify-imported-names-plugin",
35+
"hls-qualify-imported-names-plugin", "hls-selection-range-plugin",
3636
"haskell-language-server"]
3737
ghc: [ "9.0.2"
3838
, "8.10.7"

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ jobs:
234234
name: Test hls-qualify-imported-names-plugin test suite
235235
run: cabal test hls-qualify-imported-names-plugin --test-options="$TEST_OPTS" || cabal test hls-qualify-imported-names-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-qualify-imported-names-plugin --test-options="$TEST_OPTS"
236236

237+
- if: matrix.test
238+
name: Test hls-selection-range-plugin test suite
239+
run: cabal test hls-selection-range-plugin --test-options="$TEST_OPTS" || cabal test hls-selection-range-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-selection-range-plugin --test-options="$TEST_OPTS"
240+
237241
test_post_job:
238242
if: always()
239243
runs-on: ubuntu-latest

cabal-ghc90.project

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ packages:
2626
./plugins/hls-ormolu-plugin
2727
./plugins/hls-call-hierarchy-plugin
2828
./plugins/hls-alternate-number-format-plugin
29+
./plugins/hls-selection-range-plugin
2930

3031
tests: true
3132

@@ -35,7 +36,7 @@ package *
3536

3637
write-ghc-environment-files: never
3738

38-
index-state: 2022-01-11T22:05:45Z
39+
index-state: 2022-01-21T11:23:29Z
3940

4041
constraints:
4142
-- These plugins don't work on GHC9 yet

cabal-ghc921.project

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ packages:
2626
./plugins/hls-ormolu-plugin
2727
./plugins/hls-call-hierarchy-plugin
2828
./plugins/hls-alternate-number-format-plugin
29+
./plugins/hls-selection-range-plugin
2930

3031
with-compiler: ghc-9.2.1
3132

@@ -37,7 +38,7 @@ package *
3738

3839
write-ghc-environment-files: never
3940

40-
index-state: 2022-01-11T22:05:45Z
41+
index-state: 2022-01-21T11:23:29Z
4142

4243
constraints:
4344
-- These plugins don't build/work on GHC92 yet

cabal.project

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ packages:
2626
./plugins/hls-call-hierarchy-plugin
2727
./plugins/hls-alternate-number-format-plugin
2828
./plugins/hls-qualify-imported-names-plugin
29+
./plugins/hls-selection-range-plugin
2930

3031
-- Standard location for temporary packages needed for particular environments
3132
-- For example it is used in the project gitlab mirror to help in the MAcOS M1 build script
@@ -40,7 +41,7 @@ package *
4041

4142
write-ghc-environment-files: never
4243

43-
index-state: 2022-01-11T22:05:45Z
44+
index-state: 2022-01-21T11:23:29Z
4445

4546
constraints:
4647
hyphenation +embed

docs/features.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Many of these are standard LSP features, but a lot of special features are provi
1818
| [Highlight references](#highlight-references) | `textDocument/documentHighlight` |
1919
| [Code actions](#code-actions) | `textDocument/codeAction` |
2020
| [Code lenses](#code-lenses) | `textDocument/codeLens` |
21+
| [Selection range](#selection-range) | `textDocument/selectionRange` |
2122

2223
The individual sections below also identify which [HLS plugin](./what-is-hls.md#hls-plugins) is responsible for providing the given functionality, which is useful if you want to raise an issue report or contribute!
2324
Additionally, not all plugins are supported on all versions of GHC, see the [GHC version support page](supported-versions.md) for details.
@@ -141,7 +142,7 @@ Code action kind: `quickfix`
141142
Rewrites imported names to be qualified.
142143

143144
![Qualify Imported Names Demo](../plugins/hls-qualify-imported-names-plugin/qualify-imported-names-demo.gif)
144-
145+
145146
For usage see the ![readme](../plugins/hls-qualify-imported-names-plugin/README.md).
146147

147148
### Refine import
@@ -239,6 +240,13 @@ Shows module name matching file path, and applies it with a click.
239240

240241
![Module Name Demo](https://user-images.githubusercontent.com/54035/110860755-78ad8680-82bd-11eb-9845-9ea4b1cc1f76.gif)
241242

243+
## Selection range
244+
Provided by: `hls-selection-range-plugin`
245+
246+
Provides haskell specific
247+
[shrink/expand selection](https://code.visualstudio.com/docs/editor/codebasics#shrinkexpand-selection)
248+
support.
249+
242250
## Missing features
243251

244252
The following features are supported by the LSP specification but not implemented in HLS.
@@ -251,7 +259,6 @@ Contributions welcome!
251259
| Jump to implementation | Unclear if useful | `textDocument/implementation` |
252260
| Renaming | [Parital implementation](https://github.com/haskell/haskell-language-server/issues/2193) | `textDocument/rename`, `textDocument/prepareRename` |
253261
| Folding | Unimplemented | `textDocument/foldingRange` |
254-
| Selection range | Unimplemented | `textDocument/selectionRange` |
255262
| Semantic tokens | Unimplemented | `textDocument/semanticTokens` |
256263
| Linked editing | Unimplemented | `textDocument/linkedEditingRange` |
257264
| Document links | Unimplemented | `textDocument/documentLink` |

docs/supported-versions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ As such, the functionality provided by those plugins is not available in HLS whe
5050
| `hls-splice-plugin` | 9.2 |
5151
| `hls-stylish-haskell-plugin` | 9.0, 9.2 |
5252
| `hls-tactics-plugin` | 9.2 |
53+
| `hls-selection-range-plugin` | |
5354

5455
### Using deprecated GHC versions
5556

exe/Plugins.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ import Ide.Plugin.Splice as Splice
7272
import Ide.Plugin.AlternateNumberFormat as AlternateNumberFormat
7373
#endif
7474

75+
#if selectionRange
76+
import Ide.Plugin.SelectionRange as SelectionRange
77+
#endif
78+
7579
-- formatters
7680

7781
#if floskell
@@ -167,6 +171,9 @@ idePlugins includeExamples = pluginDescToIdePlugins allPlugins
167171
#endif
168172
#if alternateNumberFormat
169173
AlternateNumberFormat.descriptor "alternateNumberFormat" :
174+
#endif
175+
#if selectionRange
176+
SelectionRange.descriptor "selectionRange" :
170177
#endif
171178
-- The ghcide descriptors should come last so that the notification handlers
172179
-- (which restart the Shake build) run after everything else

flake.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake_hackage/flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
flake = false;
88
};
99
lsp-types = {
10-
url = "https://hackage.haskell.org/package/lsp-types-1.4.0.0/lsp-types-1.4.0.0.tar.gz";
10+
url = "https://hackage.haskell.org/package/lsp-types-1.4.0.1/lsp-types-1.4.0.1.tar.gz";
1111
flake = false;
1212
};
1313
lsp-test = {

0 commit comments

Comments
 (0)