ionide / FsAutoComplete

F# language server using Language Server Protocol
Other
409 stars 154 forks source link

LSP endpoint to provide FSI data to load project references + optional subset of files to load #467

Open cannorin opened 4 years ago

cannorin commented 4 years ago

I'm trying to replicate the "send references for FSI" feature of Ionide-VSCode in Ionide-vim, but it seems impossible to be done with VimScript since it has not only to parse the .fsproj but also to get the actual assembliy locations.

If FSAC can provide an endpoint for getting referenced assemblies, it will make it very easy to implement.

baronfel commented 4 years ago

How does this sound? https://github.com/fsharp/FsAutoComplete/pull/442

cannorin commented 4 years ago

@baronfel Sounds VERY GOOD! Sorry for not searching for PRs :bowing_man: Should I close this in favor of that?

baronfel commented 4 years ago

Not at all! This issue can serve as the motivating issue for the PR. Would the proposed command response structure give you what you need to go forward? I hadn't yet integrated the work with ionide to test what a full end-to-end sample might look like, but if you can go forward with it in vim and prove it works for you, we could merge this ahead of ionide having its support.

cannorin commented 4 years ago

If I understand correctly it returns references and other options as command line options which can be fed directly to FSI executable, and I believe it can easily be integrated into the current implementation of Ionide-vim.

baronfel commented 4 years ago

Yeah, specifically the response types here: https://github.com/fsharp/FsAutoComplete/pull/442/files#diff-76fd5b6caf9773b324afea969b1a8ceaR424-R435 I was originally going to generate a file which could be #loaded as the first line of an fsx script invisibly, but then I realized that FSI supports the--reference` syntax so you can preload your references (and any optional .fs files that needed to be added to the 'load', via use of the following flags:

        - INPUT FILES -
--use:<file>                             Use the given file on startup as initial input
--load:<file>                            #load the given file on startup
--reference:<file>                       Reference an assembly (Short form: -r)

on top of that, a project file will end up defining several FSC options, and in order to pass them into the FSI invocation you need to have then available before you run dotnet fsi, so that's why I ended up with the structures in that PR.

/braindump

cannorin commented 4 years ago

Nice. Does it also accept a solution file instead of project files? FSAC's workspacePeek will peek a solution file if exists, and retrieving projects from a solution involves some hard work to be done with VimScript.

baronfel commented 4 years ago

It does not currently. What would you want a 'solution FSI context' to contain?

cannorin commented 4 years ago

Since simply combining all the project contexts would easily conflict and break each other, it will be great if you can add an endpoint to FSAC which peeks currently loaded projects so that users can choose one of them.

baronfel commented 4 years ago

I'm going to rename this issue to be about the project FSI context, and I'll make a new issue for listing the set of loaded projects. Then once that is done, you could daisy-chain user interactions: