fsprojects / zarchive-sublime-fsharp-package

F# development tools for SublimeText 3
32 stars 7 forks source link

Code intelligence for external libraries? #73

Closed changlan closed 9 years ago

changlan commented 9 years ago

Hi!

I manage the project packages using paket and FAKE (without fsproj files). It turns out that code intelligence does not recognize the library names and identifiers. Is code intelligence for external libraries supposed to be supported? For example, I used FParsec in my project, and the DLLs and XMLs are under ./packages/FParsec/lib/.

Thanks!

rojepp commented 9 years ago

You compile usibg fsc (or fsharpc) directly from FAKE? Or are you only using .fsx files?

changlan commented 9 years ago

Yes, I compile the code using fsc from FAKE, because in OS X command line it's easier to set up than xbuild. Below is my build.fsx:

#r @"packages/FAKE/tools/FakeLib.dll"
open Fake
open Fake.FscHelper

let buildDir = "./build/"

Target "clean" (fun _ ->
    CleanDirs [ buildDir ]
)

Target "all" (fun _ ->
    ["src/parser.fs"]
    |> Fsc (fun p -> 
        { p with Output = buildDir + "Main.exe"
                 References = 
                    [ "packages/FParsec/lib/net40-client/FParsec.dll"
                      "packages/FParsec/lib/net40-client/FParsecCS.dll" ] 
                 OtherParams = 
                    [ "--standalone"] })
)

"clean"
    ==> "all"

RunTargetOrDefault "all"
rojepp commented 9 years ago

I like the simplicity of this. However, it does not leave us any way to find the referenced assemblies, other than reflecting over compiled output, which is certainly not right. It may not even compile! :)

Do you have any ideas on how to discover these references? This kills all tools (VS, XS, Emacs etc), so it is not really a Sublime issue. It's really more of an FSharp ecosystem issue. :)

Maybe you could use FAKE to generate the .fsproj from input similar to what you are feeding Fsc above? Then you'd compile the .fsproj instead, and tooling should work.

rneatherway commented 9 years ago

For reference there is a thread on the mailing list about this: https://groups.google.com/forum/#!topic/fsharp-opensource/zTeIo5ZnGyk

A summary would be that currently you need an .fsproj as @rojepp says. This is because that is how the compiler options are extracted to feed to the compiler services. The two main options here are, I think:

  1. Write a small FAKE helper to generate a very simple .fsproj file. Given that you know the compiler options you want (as you are running Fsc), this should be fairly easy.
  2. Define a new 'simple project' format using YAML or whatever and add support for it to FsAutoComplete, where it would be easy to plugin a new project parser. However, note that determining which assemblies you want to reference from the GAC may not be straightforward.
guillermooo commented 9 years ago

I think we can close this?

changlan commented 9 years ago

OK, it's working when I have a fsproj file. Thanks for the advice!