Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add InlayHint (LSP 3.17) #22

Merged
merged 6 commits into from
May 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
dotnet: [6.0.x]
fail-fast: false # we have timing issues on some OS, so we want them all to run
runs-on: ${{ matrix.os }}
timeout-minutes: 15

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v2
with:
dotnet-version: ${{ matrix.dotnet }}
global-json-file: global.json
- name: Run build
run: dotnet build -c Release
- name: Run publish
Expand Down
86 changes: 42 additions & 44 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,54 @@ name: Publish
on:
push:
tags:
- 'v*' # Publish on any new tag starting with v
- "v*" # Publish on any new tag starting with v

jobs:
build:

strategy:
matrix:
os: [windows-latest]
dotnet: [6.0.x]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v1

- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ matrix.dotnet }}

- name: Restore tools
run: dotnet tool restore

- name: Publish to NuGet
run: dotnet run --project build -- -t Push
env:
nuget-key: ${{ secrets.NUGET_KEY }}

- name: Get Changelog Entry
id: changelog_reader
uses: mindsers/changelog-reader-action@v1.1.0
with:
version: ${{ github.ref }}
path: ./CHANGELOG.md

- name: Create Release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: ${{ steps.changelog_reader.outputs.log_entry }}
draft: false
prerelease: false

- name: Upload binaries to release
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: release/*.nupkg
tag: ${{ github.ref }}
overwrite: true
file_glob: true
- uses: actions/checkout@v3

- name: Setup .NET Core
uses: actions/setup-dotnet@v2
with:
global-json-file: global.json

- name: Restore tools
run: dotnet tool restore

- name: Publish to NuGet
run: dotnet run --project build -- -t Push
env:
nuget-key: ${{ secrets.NUGET_KEY }}

- name: Get Changelog Entry
id: changelog_reader
uses: mindsers/changelog-reader-action@v1.1.0
with:
version: ${{ github.ref }}
path: ./CHANGELOG.md

- name: Create Release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: ${{ steps.changelog_reader.outputs.log_entry }}
draft: false
prerelease: false

- name: Upload binaries to release
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: release/*.nupkg
tag: ${{ github.ref }}
overwrite: true
file_glob: true
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"editor.formatOnSave": true
"editor.formatOnSave": true,
"yaml.schemas": {
"https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/github-workflow.json": ".github/workflows/**"
}
}
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.4.1] - 14.05.2022

### Changed

* [`textDocument/symbol` now returns `DocumentSymbol[]` instead of `SymbolInformation[]`](https://github.com/ionide/LanguageServerProtocol/pull/18) (thanks @artempyanykh!)

### Fixed

* [Workaround a VSCode language client bug preventing server shutdown](https://github.com/ionide/LanguageServerProtocol/pull/21) (thanks @artempyanykh!)

### Added

* [Types and methods for InlayHint support](https://github.com/ionide/LanguageServerProtocol/pull/22) (thanks @Booksbaum!)

## [0.4.0] - 28.04.2022

### Added
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"sdk": {
"version": "6.0.200"
}
}
}
10 changes: 10 additions & 0 deletions src/Client.fs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ type LspClient() =

default __.WorkspaceSemanticTokensRefresh() = ignoreNotification

/// The `workspace/inlayHint/refresh` request is sent from the server to the client.
/// Servers can use it to ask clients to refresh the inlay hints currently shown in editors.
/// As a result the client should ask the server to recompute the inlay hints for these editors.
/// This is useful if a server detects a configuration change which requires a re-calculation
/// of all inlay hints. Note that the client still has the freedom to delay the re-calculation of the inlay hints
/// if for example an editor is currently not visible.
abstract member WorkspaceInlayHintRefresh: unit -> Async<unit>

default __.WorkspaceInlayHintRefresh() = ignoreNotification

/// Diagnostics notification are sent from the server to the client to signal results of validation runs.
///
/// Diagnostics are “owned” by the server so it is the server’s responsibility to clear them if necessary.
Expand Down
5 changes: 4 additions & 1 deletion src/LanguageServerProtocol.fs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ module Server =
do! Task.Delay(10_000)
logger.trace (Log.setMessage "No `exit` notification within 10s after `shutdown` request. Exiting now.")
quitSemaphore.Release() |> ignore
} |> ignore
}
|> ignore

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

Expand Down Expand Up @@ -330,6 +331,8 @@ module Server =
"textDocument/semanticTokens/full", requestHandling (fun s p -> s.TextDocumentSemanticTokensFull(p))
"textDocument/semanticTokens/full/delta", requestHandling (fun s p -> s.TextDocumentSemanticTokensFullDelta(p))
"textDocument/semanticTokens/range", requestHandling (fun s p -> s.TextDocumentSemanticTokensRange(p))
"textDocument/inlayHint", requestHandling (fun s p -> s.TextDocumentInlayHint(p))
"inlayHint/resolve", requestHandling (fun s p -> s.InlayHintResolve(p))
"workspace/didChangeWatchedFiles",
requestHandling (fun s p -> s.WorkspaceDidChangeWatchedFiles(p) |> notificationSuccess)
"workspace/didChangeWorkspaceFolders",
Expand Down
21 changes: 20 additions & 1 deletion src/Server.fs
Original file line number Diff line number Diff line change
Expand Up @@ -332,4 +332,23 @@ type LspServer() =
default __.TextDocumentSemanticTokensFullDelta(_) = notImplemented

abstract member TextDocumentSemanticTokensRange: SemanticTokensRangeParams -> AsyncLspResult<SemanticTokens option>
default __.TextDocumentSemanticTokensRange(_) = notImplemented
default __.TextDocumentSemanticTokensRange(_) = notImplemented

/// The inlay hints request is sent from the client to the server to compute inlay hints for a given [text document, range] tuple
/// that may be rendered in the editor in place with other text.
abstract member TextDocumentInlayHint: InlayHintParams -> AsyncLspResult<InlayHint [] option>

default __.TextDocumentInlayHint(_) = notImplemented

/// The request is sent from the client to the server to resolve additional information for a given inlay hint.
/// This is usually used to compute the `tooltip`, `location` or `command` properties of a inlay hint’s label part
/// to avoid its unnecessary computation during the `textDocument/inlayHint` request.
///
/// Consider the clients announces the `label.location` property as a property that can be resolved lazy using the client capability
/// ```typescript
/// textDocument.inlayHint.resolveSupport = { properties: ['label.location'] };
/// ```
/// 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.
abstract member InlayHintResolve: InlayHint -> AsyncLspResult<InlayHint>

default __.InlayHintResolve(_) = notImplemented