fsharp / emacs-fsharp-mode

F# Emacs mode
Apache License 2.0
208 stars 61 forks source link

Script files(.fsx) not working #231

Open FsharperOnTheRun opened 4 years ago

FsharperOnTheRun commented 4 years ago

Description

No completion, type signature on F# script files(.fsx). Code files(.fs) works as expected.

Repro steps

  1. Step A

open a simple script file, Foo.fsx:

let x = 10
x.ToString()
x.T
  1. Step B
    • M-x eglot
    • highlight x, ToString
    • try complete x.T

Expected behavior

Actual behavior

"flymake:Wait" on mode line never goes away.

And Error:

[...]
client-request (id:28) Sat Dec  7 16:17:15 2019:
(:jsonrpc "2.0" :id 28 :method "textDocument/completion" :params
      (:textDocument
       (:uri "file:///home/me/Test/fsharp/core-3.0.101/hello-world/Foo.fsx")
       :position
       (:line 5 :character 3)
       :context
       (:triggerKind 1)))

server-reply (id:28) ERROR Sat Dec  7 16:17:15 2019:
(:jsonrpc "2.0" :id 28 :error
      (:code -32603 :message "no type check results"))

internal (id:24) Sat Dec  7 16:17:25 2019:
(:timed-out :textDocument/signatureHelp :id 24 :params
        (:textDocument
         (:uri "file:///home/me/Test/fsharp/core-3.0.101/hello-world/Foo.fsx")
         :position
         (:line 5 :character 3)))

Known workarounds

Stick with .fs and never touch .fsx? :(

Related information

juergenhoetzel commented 4 years ago

Thanks for the detailed report. I can confirm. It's most likely related to this ionide issue: [FSAC Runtime = netcore does not work with fsx

948](https://github.com/ionide/ionide-vscode-fsharp/issues/948)

juergenhoetzel commented 4 years ago

4.2.0 - No auto complete or typechecking in FSX files

*EGLOT (hello/fsharp-mode) stderr* shows:

[Checker] ParseAndCheckFileInProject - /home/juergen/shared/fsharp/hello/foo.fsx completed with errors [unknown (1,1)-(1,1) parameter error Assembly reference 'mscorlib.dll' was not found or is invalid]
juergenhoetzel commented 4 years ago

Documented a workaround in the troubleshooting section: https://github.com/fsharp/emacs-fsharp-mode/#no-autocompletion-in-fsx-files

FsharperOnTheRun commented 4 years ago

Thanks for the reply. Gonna use F# for a project and came back try emacs again :)

The workaround recommended did not work for me, so I tried referencing mscorlib as well and it worked.

Ubuntu 19.10 3.1.100 [/home/me/.dotnet/sdk] via dotnet-install.sh

When I don't reference mscorlib, nothing works with errors like "[...]Cached typecheck results not yet available[...]" and timeouts

When I include mscorlib without netstandard.dll then it goes bonkers:

let x = "hello world"

(:jsonrpc "2.0" :id 146 :result (:contents [(:language "fsharp" :value "val x : PrintfFormat<'?20171,'?20169,'?20170,'?20171,unit>") "" "Full name: Hello.x" "Assembly: hello"]))

let y = 1

(:jsonrpc "2.0" :id 152 :result (:contents [(:language "fsharp" :value "val y : '?20164") "" "Full name: Hello.y" "Assembly: hello"]))

A few attempts

:x: does not work:

#r "/home/me/.dotnet/sdk/3.1.100/ref/netstandard.dll"

:x: does not work:

#r "mscorlib.dll"
#r "netstandard.dll"

:heavy_check_mark: works:

#r "/home/me/.dotnet/sdk/3.1.100/ref/mscorlib.dll"
#r "/home/me/.dotnet/sdk/3.1.100/ref/netstandard.dll"

:heavy_check_mark: works:

#r "/home/me/.dotnet/sdk/3.1.100/ref/mscorlib.dll"
#r "netstandard.dll"

:heavy_check_mark: works:

#I "/home/me/.dotnet/sdk/3.1.100/ref/"
#r "mscorlib.dll"
#r "netstandard.dll"

:heavy_check_mark: works with older sdk(2.1.801) as well:

#I "/home/me/.dotnet/sdk/2.1.801/ref/"
#r "mscorlib.dll"
#r "netstandard.dll"

I think I will use paket load-scripts and prepend this snippet manually. Generated load scripts are not going to the repo anyway.

Also, i think the README.md has a typo, it should be 'eglot-fsharp and not 'fsharp-eglot

(require 'eglot-fsharp)
vbmithr commented 4 years ago

Same here


(:jsonrpc "2.0" :id 41 :error
          (:code -32603 :message "Could not find parameter locations"))
[internal] (id:41) ERROR Mon Nov 16 00:27:43 2020:
(:message "error ignored, status set (Could not find parameter locations)" :id 41 :error -32603)
[server-reply] (id:43) ERROR Mon Nov 16 00:27:43 2020:
(:jsonrpc "2.0" :id 43 :error
          (:code -32603 :message "No symbol information found"))
[internal] (id:43) ERROR Mon Nov 16 00:27:43 2020:
(:message "error ignored, status set (No symbol information found)" :id 43 :error -32603)
[server-reply] (id:42) ERROR Mon Nov 16 00:27:43 2020:
(:jsonrpc "2.0" :id 42 :error
          (:code -32603 :message "No tooltip information"))
[internal] (id:42) ERROR Mon Nov 16 00:27:43 2020:
(:message "error ignored, status set (No tooltip information)" :id 42 :error -32603)```

I'm using latest .NET 5
Above workarounds do not work for me.