ionide / Ionide-vim

F# Vim plugin based on FsAutoComplete and LSP protocol
MIT License
174 stars 21 forks source link

The latest FSAC is currently not working (on *nix systems?) #44

Closed cannorin closed 2 years ago

cannorin commented 2 years ago

UPDATE: This was fixed in the latest FSAC (0.49.2). Please update your FSAC with :FSharpUpdateFSAC, or if you are using one from .NET tools, dotnet tool update fsautocomplete.

Also, FSAC now encourages installing fsautocomplete as a local tool rather than a global tool.

let g:fsharp#fsautocomplete_command =
    \ [ 'fsautocomplete',  '--background-service-enabled'` ]

Ionide-vim is currently affected by an upstream bug https://github.com/fsharp/FsAutoComplete/issues/853, which originates from https://github.com/ionide/proj-info/issues/123.

This is causing Ionide-vim not to work. Here are the workarounds you can do to avoid this issue for the time being:

Workaround 1.

As described in https://github.com/fsharp/FsAutoComplete/issues/853, put export DOTNET_HOST_PATH="$(which dotnet)" to your rc file.

Workaround 2.

Install an older version of FSAC as a .NET tool:

dotnet tool install --version 0.48.2 fsautocomplete -g

(if you have already installed it before, replace install with update)

Then use the following to force Ionide-vim to use the one from .NET tool:

let g:fsharp#fsautocomplete_command =
    \ [ 'dotnet',
    \   'fsautocomplete',
    \   '--background-service-enabled'
    \ ]
OmanF commented 2 years ago

As I noted on #43, for me what worked was workaround 2. Will keep an eye on the fsautocomplete upstream to see when they fix the root cause.

Thank you for your great work!

baronfel commented 2 years ago

A fix for this should have been pushed in 0.49.2, please let me know if it works out for you!

klcarlton commented 2 years ago

@baronfel confirmed. After running :FSharpUpdateFSAC I no longer need to set DOTNET_HOST_PATH

cannorin commented 2 years ago

confirmed on my end too. I will update the description, then close this announcement tomorrow.

OmanF commented 2 years ago

@baronfel, @cannorin

Meta: OS: Linux Ubuntu 20.04 (WSL2) NeoVim: 0.6.0-Dev, nightly .Net SDK: 6.0.100

On the table below when it says "FSAC version - local", I made sure to uninstall FSAC globally, and vice-versa, so, at all times there was a single FSAC installed on the machine (either globally, or local to the folder).

My .zshrc has no clause regarding DOTNET-anything.

Content:

<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns="http://www.w3.org/TR/REC-html40">

  | 0.48.2 local | 0.48.2 global | 0.49.3 local | 0.49.3 global -- | -- | -- | -- | -- Nothing in config (presummably bundled FSAC) | FSAC starts after ~2 seconds delay; Even then autocomplete only shows LSP suggestion when there are 2 characters | No LSP client attaches!!! | Ionide attaches - does nothing! (No autocomplete, no error messages, etc.) | Ionide attaches - does nothing! (No autocomplete, no error messages, etc.) `dotnet` `fsautocomplete` `--backgroud-service-enabled` | FSAC starts after ~2 seconds delay; Even then autocomplete only shows LSP suggestion when there are 2 characters | Error 1 | Ionide attaches - does nothing! (No autocomplete, no error messages, etc.) | Error 1 `fsautocomplete --background-service-enabled` | `cmd ["fsautocomplete"] is not executable.` (Logical - there is no global FSAC) | `cmd ["fsautocomplete"] is not executable.` (ILLOGICAL - there IS a global FSAC installed!) | `cmd ["fsautocomplete"] is not executable.` (Logical - there is no global FSAC) | `cmd ["fsautocomplete"] is not executable.` (ILLOGICAL - there IS a global FSAC installed!)

 

Error 1: [ERROR][2021-11-20 14:25:00] .../vim/lsp/rpc.lua:412        "rpc"        "dotnet"        "stderr"        "Could not execute because the specified command or file was not found.\r\nPossible reasons for this include:\r\n  * You misspelled a built-in dotnet command.\r\n  * You intended to execute a .NET program, but dotnet-fsautocomplete does not exist.\r\n  * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.\n"

After reading this table, and the preceding thread, it simply acts to verify what you already know, which is that FSAC v0.49.* is at the moment incompatible with Ionide-vim , while v0.48.2 is.

The Error 1 are, when I think about it, very logical: I'm trying to run a local dotnet command, but the FSAC is installed globally, so, of course, it's an error.

tnishimura commented 2 years ago

Workaround 2 worked for me, using Vim 8.2 on 20.04. Without it, I get the exact symptoms as described by @OmanF, albeit with 0.49.5. Workaround 1 did not work for me.

tnishimura commented 2 years ago

Note for @OmanF and others running Ubuntu: Apparently fsautocomplete 0.49+ works fine if you only have one dotnet runtime installed -- i.e., uninstall all runtimes besides dotnet-runtime-6.0. I brought this up as a fsautocomplete issue.

cannorin commented 2 years ago

@tnishimura Thank you for taking time to look into this! I'm glad if you can send a patch (so that you are actually credited as a contributor), but I can do it instead if you don't have time for that.

tnishimura commented 2 years ago

@cannorin I'll ask you to do it 🙏 -- the only thing I can think of is prepending 'env', 'DOTNET_ROLL_FORWARD=LatestMajor' onto g:fsharp#fsautocomplete_command. Also my vimscript-fu is rather weak.

cannorin commented 2 years ago

Added a workaround for this issue. Can you check if it works for you?

OmanF commented 2 years ago

I just saw the implementation for #51, I tried it: works! Great and thank you very much!

Couple of issues I do have to point out:

  1. Due to FSAC requiring a global installation... it's worth making sure in the documentation, in bold, italics, underscore, blinking lights, whatever, that FSAC needs to be installed globally.
  2. I now get LSP auto-complete which is cool, but it triggers only after 2 characters after the ., i.e., List. won't work, List.ma will.
  3. Even when the auto-complete shows, if I type the entire word after the dot, that specific word will not show in the pop-up menu. What I mean is if I do List.map the pop-up will show map2, mapi, mapX... just not map.
  4. Regardless of this ticket, I remind of another ticket about the tooltip not showing any details about the function in the pop-up it stands over. The tooltip bubble is empty, showing, but empty.

All in all, great work, I can now edit F# in NeoVim to a goo degree! Thank you very much!

baronfel commented 2 years ago

A couple quick responses:

  1. worth noting that the FSAC install is not required to be global - dotnet tools can (and should IMO!) be installed locally to a project via dotnet new tool-manifest && dotnet tool install fsautocomplete. Then you can pin/manage the version without impacting your other projects, as you would any other dotnet tool (like fantomas for formatting).
  2. this is IIRC something that can be configured both on the LSP server (FSAC) and LSP client (neovim) sides. it would be worth looking at the raw LSP request/responses (most LSP clients will use the <LANGNAME>.trace.server settings key to control this logging) and see if List.map is being returned from FSAC itself, but swallowed on the neovim side in some way
  3. this bled into the answer for 2
  4. Same response here - if you can provide LSP request/response logs for the erroring tooltip that might help triage if the problem is on the FSAC side or the neovim integration side
cannorin commented 2 years ago

As @baronfel explained, FSAC need not be global. See the g:fsharp#fsautocomplete_command documentation in README (it actually explains how to use project-local FSAC).

Also I'm pretty sure 2. is my fault and can be fixed easily (I remember setting 2 as something like the minimal characters to trigger completion).

tnishimura commented 2 years ago

@cannorin Yes, the DOTNET_ROLL_FORWARD change is working as expected, at least on Vim. (I didn't know that you could just set a variable $DOTNET_ROLL_FORWARD to set env vars in vimscript...). Thank you!

cannorin commented 2 years ago

@OmanF

(I've already explained about 1. in the above message, so I'm skipping it)

  1. If you are using the example configuration with nvim-lspconfig and nvim-cmp, remove keyword_length = 2. If you are using deoplete, that seems to be the default behavior of deoplete and you would need to configure deoplete but not this plugin.

  2. I didn't reproduce it both in deoplete and nvim-cmp (with the example configurations). I think the problem comes somewhere from your .vimrc, so we would need to look at it...

  3. If you are using deoplete, deoplete-lsp is lacking the feature (https://github.com/ionide/Ionide-vim/issues/41), so you would need to switch to nvim-cmp. If you are already using nvim-cmp, we would need to look at your .vimrc to see what is happening, as I can't reproduce it with the example configuration.

OmanF commented 2 years ago

Thanks for your reply. I'm actually using coq_nvim as my completion engine, so I'll just try and see the docs about the 2-letter limit.

Otherwise, I've seen and implemented the local FSAutoComplete as per the readme and it works great. I can now use F# on NeoVim with the same enjoyment I use it on VSCode.

Thanks for a great job!