Skip to content

Commit 7c5296a

Browse files
Booksbaumbaronfel
andauthored
Add InlayHint (LSP 3.17) (#22)
Co-authored-by: Chet Husk <[email protected]>
1 parent 37ab624 commit 7c5296a

File tree

9 files changed

+241
-54
lines changed

9 files changed

+241
-54
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,16 @@ jobs:
77
strategy:
88
matrix:
99
os: [ubuntu-latest, windows-latest, macOS-latest]
10-
dotnet: [6.0.x]
1110
fail-fast: false # we have timing issues on some OS, so we want them all to run
1211
runs-on: ${{ matrix.os }}
1312
timeout-minutes: 15
1413

1514
steps:
16-
- uses: actions/checkout@v1
15+
- uses: actions/checkout@v3
1716
- name: Setup .NET Core
18-
uses: actions/setup-dotnet@v1
17+
uses: actions/setup-dotnet@v2
1918
with:
20-
dotnet-version: ${{ matrix.dotnet }}
19+
global-json-file: global.json
2120
- name: Run build
2221
run: dotnet build -c Release
2322
- name: Run publish

.github/workflows/publish.yml

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,56 +3,54 @@ name: Publish
33
on:
44
push:
55
tags:
6-
- 'v*' # Publish on any new tag starting with v
6+
- "v*" # Publish on any new tag starting with v
77

88
jobs:
99
build:
10-
1110
strategy:
1211
matrix:
1312
os: [windows-latest]
14-
dotnet: [6.0.x]
1513
runs-on: ${{ matrix.os }}
1614

1715
steps:
18-
- uses: actions/checkout@v1
19-
20-
- name: Setup .NET Core
21-
uses: actions/setup-dotnet@v1
22-
with:
23-
dotnet-version: ${{ matrix.dotnet }}
24-
25-
- name: Restore tools
26-
run: dotnet tool restore
27-
28-
- name: Publish to NuGet
29-
run: dotnet run --project build -- -t Push
30-
env:
31-
nuget-key: ${{ secrets.NUGET_KEY }}
32-
33-
- name: Get Changelog Entry
34-
id: changelog_reader
35-
uses: mindsers/[email protected]
36-
with:
37-
version: ${{ github.ref }}
38-
path: ./CHANGELOG.md
39-
40-
- name: Create Release
41-
uses: actions/create-release@latest
42-
env:
43-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44-
with:
45-
tag_name: ${{ github.ref }}
46-
release_name: ${{ github.ref }}
47-
body: ${{ steps.changelog_reader.outputs.log_entry }}
48-
draft: false
49-
prerelease: false
50-
51-
- name: Upload binaries to release
52-
uses: svenstaro/upload-release-action@v1-release
53-
with:
54-
repo_token: ${{ secrets.GITHUB_TOKEN }}
55-
file: release/*.nupkg
56-
tag: ${{ github.ref }}
57-
overwrite: true
58-
file_glob: true
16+
- uses: actions/checkout@v3
17+
18+
- name: Setup .NET Core
19+
uses: actions/setup-dotnet@v2
20+
with:
21+
global-json-file: global.json
22+
23+
- name: Restore tools
24+
run: dotnet tool restore
25+
26+
- name: Publish to NuGet
27+
run: dotnet run --project build -- -t Push
28+
env:
29+
nuget-key: ${{ secrets.NUGET_KEY }}
30+
31+
- name: Get Changelog Entry
32+
id: changelog_reader
33+
uses: mindsers/[email protected]
34+
with:
35+
version: ${{ github.ref }}
36+
path: ./CHANGELOG.md
37+
38+
- name: Create Release
39+
uses: actions/create-release@latest
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
with:
43+
tag_name: ${{ github.ref }}
44+
release_name: ${{ github.ref }}
45+
body: ${{ steps.changelog_reader.outputs.log_entry }}
46+
draft: false
47+
prerelease: false
48+
49+
- name: Upload binaries to release
50+
uses: svenstaro/upload-release-action@v1-release
51+
with:
52+
repo_token: ${{ secrets.GITHUB_TOKEN }}
53+
file: release/*.nupkg
54+
tag: ${{ github.ref }}
55+
overwrite: true
56+
file_glob: true

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"editor.formatOnSave": true
2+
"editor.formatOnSave": true,
3+
"yaml.schemas": {
4+
"https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/github-workflow.json": ".github/workflows/**"
5+
}
36
}

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.4.1] - 14.05.2022
8+
9+
### Changed
10+
11+
* [`textDocument/symbol` now returns `DocumentSymbol[]` instead of `SymbolInformation[]`](https://github.com/ionide/LanguageServerProtocol/pull/18) (thanks @artempyanykh!)
12+
13+
### Fixed
14+
15+
* [Workaround a VSCode language client bug preventing server shutdown](https://github.com/ionide/LanguageServerProtocol/pull/21) (thanks @artempyanykh!)
16+
17+
### Added
18+
19+
* [Types and methods for InlayHint support](https://github.com/ionide/LanguageServerProtocol/pull/22) (thanks @Booksbaum!)
20+
721
## [0.4.0] - 28.04.2022
822

923
### Added

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"sdk": {
33
"version": "6.0.200"
44
}
5-
}
5+
}

src/Client.fs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,16 @@ type LspClient() =
9191

9292
default __.WorkspaceSemanticTokensRefresh() = ignoreNotification
9393

94+
/// The `workspace/inlayHint/refresh` request is sent from the server to the client.
95+
/// Servers can use it to ask clients to refresh the inlay hints currently shown in editors.
96+
/// As a result the client should ask the server to recompute the inlay hints for these editors.
97+
/// This is useful if a server detects a configuration change which requires a re-calculation
98+
/// of all inlay hints. Note that the client still has the freedom to delay the re-calculation of the inlay hints
99+
/// if for example an editor is currently not visible.
100+
abstract member WorkspaceInlayHintRefresh: unit -> Async<unit>
101+
102+
default __.WorkspaceInlayHintRefresh() = ignoreNotification
103+
94104
/// Diagnostics notification are sent from the server to the client to signal results of validation runs.
95105
///
96106
/// Diagnostics are “owned” by the server so it is the server’s responsibility to clear them if necessary.

src/LanguageServerProtocol.fs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ module Server =
255255
do! Task.Delay(10_000)
256256
logger.trace (Log.setMessage "No `exit` notification within 10s after `shutdown` request. Exiting now.")
257257
quitSemaphore.Release() |> ignore
258-
} |> ignore
258+
}
259+
|> ignore
259260

260261
jsonRpc.AddLocalRpcMethod("shutdown", Action(onShutdown))
261262

@@ -330,6 +331,8 @@ module Server =
330331
"textDocument/semanticTokens/full", requestHandling (fun s p -> s.TextDocumentSemanticTokensFull(p))
331332
"textDocument/semanticTokens/full/delta", requestHandling (fun s p -> s.TextDocumentSemanticTokensFullDelta(p))
332333
"textDocument/semanticTokens/range", requestHandling (fun s p -> s.TextDocumentSemanticTokensRange(p))
334+
"textDocument/inlayHint", requestHandling (fun s p -> s.TextDocumentInlayHint(p))
335+
"inlayHint/resolve", requestHandling (fun s p -> s.InlayHintResolve(p))
333336
"workspace/didChangeWatchedFiles",
334337
requestHandling (fun s p -> s.WorkspaceDidChangeWatchedFiles(p) |> notificationSuccess)
335338
"workspace/didChangeWorkspaceFolders",

src/Server.fs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,4 +332,23 @@ type LspServer() =
332332
default __.TextDocumentSemanticTokensFullDelta(_) = notImplemented
333333

334334
abstract member TextDocumentSemanticTokensRange: SemanticTokensRangeParams -> AsyncLspResult<SemanticTokens option>
335-
default __.TextDocumentSemanticTokensRange(_) = notImplemented
335+
default __.TextDocumentSemanticTokensRange(_) = notImplemented
336+
337+
/// The inlay hints request is sent from the client to the server to compute inlay hints for a given [text document, range] tuple
338+
/// that may be rendered in the editor in place with other text.
339+
abstract member TextDocumentInlayHint: InlayHintParams -> AsyncLspResult<InlayHint [] option>
340+
341+
default __.TextDocumentInlayHint(_) = notImplemented
342+
343+
/// The request is sent from the client to the server to resolve additional information for a given inlay hint.
344+
/// This is usually used to compute the `tooltip`, `location` or `command` properties of a inlay hint’s label part
345+
/// to avoid its unnecessary computation during the `textDocument/inlayHint` request.
346+
///
347+
/// Consider the clients announces the `label.location` property as a property that can be resolved lazy using the client capability
348+
/// ```typescript
349+
/// textDocument.inlayHint.resolveSupport = { properties: ['label.location'] };
350+
/// ```
351+
/// then an inlay hint with a label part without a location needs to be resolved using the `inlayHint/resolve` request before it can be used.
352+
abstract member InlayHintResolve: InlayHint -> AsyncLspResult<InlayHint>
353+
354+
default __.InlayHintResolve(_) = notImplemented

0 commit comments

Comments
 (0)