fsharp / zarchive-vim-fsharp

F# bindings for vim
MIT License
143 stars 34 forks source link

Issue with fsproj-file location #79

Open viktorvan opened 7 years ago

viktorvan commented 7 years ago

tl dr; Could it be a reasonable default to look for fsproj-files in the current folder and any parent folders recursively?

According to the plugin documentation, opening an .fs-file will load any fsproj-file in that directory.

And some experimentation will show this to be true :) With the following project structure:

Given that Library.fs opens modules from File1 and File2 and given that File2 opens a module from File1.

  1. I can open a vim-session for Library.fs an it will resolve any modules correctly because if will have loaded Project.fsproj.

  2. If I start a new vim-session and start with opening File2 it will not be able to resolve the module in File1 because Project.fsproj will not be loaded since it is located in a parent folder.

  3. However if I start a new vim-session and open Library.fs (which will load Project.fsproj) and then open File2 it will resolve the modules in File1 since the project file already is loaded.

Could we solve 2. by letting the plugin search for fsproj-files in parent directories?

kjnilsson commented 7 years ago

Yes within reason. Perhaps limited to 2 or 3 parent directories. On Fri, 2 Jun 2017 at 08:56, Viktor Andersson notifications@github.com wrote:

tl dr; Could it be a reasonable default to look for fsproj-files in the current folder and any parent folders recursively?

According to the plugin documentation, opening an .fs-file will load any fsproj-file in that directory.

And some experimentation will show this to be true :) With the following project structure:

  • Project.fsproj
  • Library.fs
  • Folder/File1.fs
  • Folder/File2.fs

Given that Library.fs opens modules from File1 and File2 and given that File2 opens a module from File1.

1.

I can open a vim-session for Library.fs an it will resolve any modules correctly because if will have loaded Project.fsproj. 2.

If I start a new vim-session and start with opening File2 it will not be able to resolve the module in File1 because Project.fsproj will not be loaded since it is located in a parent folder. 3.

However if I start a new vim-session and open Library.fs (which will load Project.fsproj) and then open File2 it will resolve the modules in File1 since the project file already is loaded.

Could we solve 2. by letting the plugin search for fsproj-files in parent directories?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/fsharp/vim-fsharp/issues/79, or mute the thread https://github.com/notifications/unsubscribe-auth/ABIDlNpecqAmmvYHSibwzRCoEiWTMlDKks5r_7IbgaJpZM4Nt5lO .

kjnilsson commented 7 years ago

actually the limit should be configurable with a default that retains the current behaviour (only scanning the same dir as the file).

viktorvan commented 7 years ago

Sure, that would work great.

Just for information I ran into the issue when I was using the dotnet cli template for fable-elmish-react. That template is using a project structure with the .fsproj-file in the root-directory and all .fs-files in a src-subfolder. So when opening any .fs-file in the src-folder it never would be able to load the .fsproj-file.

enricosada commented 7 years ago

@kjnilsson the search of fsproj is now supported fsac side (ref https://github.com/fsharp/FsAutoComplete/pull/191 ) and support also sln files.

So should help implement this feature (just run workspacepeek at startup). Vim need to iterate projects and call project. This will be improved by https://github.com/fsharp/FsAutoComplete/issues/192 later, doing whole init fsac side