fsharp / emacs-fsharp-mode

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

Eglot not working #320

Open mattgallagher92 opened 1 year ago

mattgallagher92 commented 1 year ago

Description

I'm trying to set up Emacs to use it as my full-time F# editor. I'm having trouble setting up eglot to enable basic IDE features like go to definition and find references.

I'm very much an Emacs noob, so it's likely that the problem is with what I'm doing.

Repro steps

  1. Use vanilla Emacs and add the following to your init file:

    (require 'package)
    
    (add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))
    (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
    
    (setq package-enable-at-startup nil)
    (package-initialize)
    
    (unless (package-installed-p 'use-package)
      (package-refresh-contents)
      (package-install 'use-package))
    
    (eval-when-compile
      (require 'use-package))
    
    (use-package fsharp-mode
      :defer t
      :ensure t)
    
    (use-package eglot-fsharp
      :ensure t)
  2. Scaffold a new SAFE app in ./safev4:

    dotnet new -i SAFE.Template::4.0.0
    dotnet new safe -o safev4
  3. Open ./safev4/Build.fs in Emacs

  4. Run M-x eglot

  5. Highlight the word run on line 61.

  6. Run M-x xref-find-definitions

Expected behavior

Emacs opens the file ./safev4/Helpers.fs, with the cursor on the r of let run... on line 86.

Actual behavior

Emacs prompts with "Visit tags table (default TAGS): [path to repo]". When I hit RET, Emacs shows the message "[path to repo]/TAGS" does not exist.

Known workarounds

None.

Related information

arialdomartini commented 1 year ago

Hi @mattgallagher92 By any chance, did you manage to solve this issue?

mattgallagher92 commented 1 year ago

Hey @arialdomartini

Unfortunately not. However, I plan to make another attempt at setting Emacs up as a capable F# IDE in the near future, and will post here if I get it working. Might be a few months though :sweat_smile:

arialdomartini commented 1 year ago

I managed to make it work today, with the precious help of @protesilaos, both on Windows and Linux. Feel free to contact me in private arialdo.martini@gmail.com, I'll be happy to help. Eventually I guess I will share a post with the steps I followed.

mattgallagher92 commented 1 year ago

Thanks!

At the moment, I'm using Doom Emacs with very little customisation for a few utilities, including Magit. However, I'm intending to replicate the features that I like in a custom Emacs configuration, and use that instead of Doom Emacs. The setup created in System Crafters' Emacs from Scratch YouTube playlist seems like it might be good.

I'll reach out once I've got that working, as I expect that will be a better starting point (possibly only because I'll better understand how to configure Emacs by that point :sweat_smile:)

davidbruce commented 11 months ago

@mattgallagher92

I'm on doom-emacs too and I just tried to switch over to Eglot and I wasn't able to get it working. lsp-mode just works out of the box for me though.

I made a very simple program to test it out:

open Suave
open Suave.Successful
printfn "Hello from F#"

let html = "Hello"
startWebServer defaultConfig (OK html)

The language server is constantly throwing errors:

[server-reply] (id:107) ERROR Sun Jul 30 14:25:39 2023:
(:jsonrpc "2.0" :id 107 :error
          (:code -32603 :message "No typecheck results for /Users/davidbruce/Git/projects/fsharp/MyFSharpApp/Program.fs"))

With lsp-mode it prompted me to download fsac, then prompted to me to set the root of the project and then I was immediately getting auto complete.

image

Also you can change the autocomplete delay of lsp-mode in config.el with the following:

(setq lsp-idle-delay 0.100)