fsharp icon indicating copy to clipboard operation
fsharp copied to clipboard

Implement LSP `textDocument/definition`

Open abonie opened this issue 7 months ago • 0 comments

Implement the textDocument/definition endpoint for the F# LSP server. This endpoint will provide the "go to definition" functionality.

The LSP specification for this endpoint can be found under this link.

The implementation should use the F# Compiler Service API: src/Compiler/Service/service.fsi

The current implementation of this feature can serve as a reference point. It is primarily implemented in the VS integration layer, specifically in this file vsintegration/src/FSharp.Editor/Navigation/GoToDefinition.fs. The main idea is to parse and check the source file and then use the GetDefinitionLocation method of the checker's result.

Other LSP endpoints in the F# LSP server can be found here for reference: src/FSharp.Compiler.LanguageServer/Handlers/LanguageFeaturesHandler.fs. F# LSP server is using Common Language Server Protocol Framework which contains useful types and methods for handling LSP requests. It's implementation can be found in the Roslyn repo, specifically https://github.com/dotnet/roslyn/tree/main/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework

abonie avatar May 28 '25 21:05 abonie