fsprojects / fsharp-language-server

Other
218 stars 37 forks source link

textDocument/definition does not work for FSharp.Core #69

Open runbmp opened 5 years ago

runbmp commented 5 years ago

Hello,

I am using coc-fsharp in neovim.

Attempting to go to definition on List.average

[<EntryPoint>]
let main _argv =
    List.average [1.0;2.0;3.0]

Coc verbose logging gives:

[Trace - 1:51:06 PM] Sending request 'textDocument/definition - (2)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/runbmp/Documents/work/fsharp_projects/Fdis/Program.fs"
    },
    "position": {
        "line": 9,
        "character": 10
    }
}

Looking at symbol List.average

[Trace - 1:51:06 PM] Received response 'textDocument/definition - (2)' in 16ms.
Result: [
    {
        "uri": "file:///E:/A/_work/130/s/src/fsharp/FSharp.Core/list.fsi",
        "range": {
            "start": {
                "line": 36,
                "character": 19
            },
            "end": {
                "line": 36,
                "character": 26
            }
        }
    }
]

but the response of "uri": "file:///E:/A/_work/130/s/src/fsharp/FSharp.Core/list.fsi" makes no sense to me as I do not have that directory or even drive mapped

dotnet --version 3.0.101

dotnet-sdk insalled via homebrew

➜ brew cask info dotnet-sdk
dotnet-sdk: 3.0.101,1b9f265d-ba27-4f0c-8b4d-1fd42bd8448b:2bbd64abddeeea91149df3aa39d049ae
https://www.microsoft.com/net/core#macos
/usr/local/Caskroom/dotnet-sdk/3.0.101,1b9f265d-ba27-4f0c-8b4d-1fd42bd8448b:2bbd64abddeeea91149df3aa39d049ae (107.8MB)
From: https://github.com/Homebrew/homebrew-cask/blob/master/Casks/dotnet-sdk.rb
==> Name
.NET Core SDK
==> Artifacts
dotnet-sdk-3.0.101-osx-x64.pkg (Pkg)
/usr/local/share/dotnet/dotnet (Binary)

My fsproj file is:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <LangVersion>preview</LangVersion>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="Program.fs" />
  </ItemGroup>

</Project>
baronfel commented 5 years ago

This is related to the fact that recent versions of FSharp.Core started supporting Sourcelink. I saw this issue too and starting implementing support for sourcelink-go-to-definition over in https://github.com/fsharp/FsAutoComplete/pull/508, but as part of that work I found that the underlying F# Compiler Services APIs give odd 'root's, as you see: https://github.com/dotnet/fsharp/issues/7918. You'd see this behavior for any F# library that supports Sourcelink as well, by the way.

So I think 7918 needs to be addressed before we can fix this either in my efforts or in this repository.

runbmp commented 5 years ago

Interestingly enough, both ionide-vim and ionide-vscode-fsharp appear to be able to handle this.

Thanks for the fast response and the amazing project!