fsharp / emacs-fsharp-mode

F# Emacs mode
Apache License 2.0
205 stars 62 forks source link

Draft of FsProj Enhancements #333

Open amcguier opened 1 year ago

amcguier commented 1 year ago

This PR is a (very) rough draft of some FsProj and eglot enhancements I've been playing with.

I'd love to get some general feedback on the approach and see what folks appetite would be for bringing something like this in.

Pain points this solves for my workflow

  1. Currently, when starting eglot in a multi-project workspace with a sln eglot uses the project integration and ends up finding the fsproj first, even if there's a sln file further up the directory tree, which means I end up running multiple copies of FsAutoComplete when editing client/server projects
  2. When editing an fsproj file with the dotnet command line tools or manually, eglot/FsAutoComplete don't pickup the change, requiring me to kill/restart eglot to get completions on new files
  3. Similar to '2.' when reordering files in an fsproj file during development I have to kill/restart eglot/FsAutoComplete for the changes to be detected

General layout of my approach, and some reasoning.

The solution file issue is straightforward, I've extended the project/sln search to first run a search for a sln file, and then to fallback to either an fsproj file if a sln file cannot be found see here

For adding/removing fs files is accomplished via pretty straightforward modifications to eglot-fsharp itself here. Renaming is similar, although in that case I save the buffer first, and then open the alternative file once the operation is completed.

The changing of the file order is a bit more complicated. I opted to create a new fsproj-mode because it simplifies the implementation of tabulated-list-mode, however this mode isn't intended to be accessed from an fsproj file, but rather launched from an fs file with eglot running, because otherwise getting the running eglot session (or joining one) seems tricky to manage. You can open the buffer for with the command fsproj-list-files and then use u/d to move/change the file order.