F# on Emacs with Spacemacs

While F# is first-class citizen in Visual Studio, there’s also support for text editors:

There's also support for MonoDevelop and Xamarin Studio, which are IDEs. See the Cross-Platform Development with F# for more details.

Beyond Visual Studio

In my experience so far, getting F# to work outside Visual Studio requires quite an effort.

There are always a couple of steps to be done, and basic knowledge of the target text editor is also assumed.

A flexible, easy way, with Spacemacs

I learned Spacemacs in a tweet by Chris Bowdon. Spacemacs is essentially an Emacs configuration.


Emacs for Windows, is available. Unzip to a folder and run. - An .emacs.d folder is automatically created in ~/AppData/Roaming/, storing all Emacs settings.

Install Spacemacs

Open a Git Bash command prompt window:

# Backup any existing Emacs configuration.
mv ~/AppData/Roaming/.emacs.d ~/AppData/Roaming/.emacs.bak

# Clone Spacemacs in place of the old Emacs configuration.
git clone --recursive http://github.com/syl20bnr/spacemacs ~/AppData/Roaming/.emacs.d

Then, launch Emacs and Spacemacs will automatically load, installing all required packages. After that, Emacs must be restarted.

Enable F#

After opening Emacs, it should show ~/.spacemacs under Recent files. - Click on that file to open it.

Add F# as shown in the following diff-output:

diff --git a/.spacemacs b/.spacemacs
index d6cedae..a47936c 100644
--- a/.spacemacs
+++ b/.spacemacs
@@ -23,6 +23,7 @@
      ;; markdown
      ;; org
      ;; syntax-checking
+     fsharp
    ;; A list of packages and/or extensions that will not be install and loaded.
    dotspacemacs-excluded-packages '()

Then hit CTRL+C & CTRL+C, and the Spacemacs layer for F# will install itself.






The F# projects shown in the above screenshots are Qaiain and DiamondFsCheck.