Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Centralize restore script Nov 2, 2018
.vscode
client Linux (#20) Oct 18, 2018
sample Case insensitive package references (#26) Nov 2, 2018
scripts Auto-install Jan 27, 2019
spacemacs/fsharp2
src Support Xunit Fact & Theory tests (#47) Feb 16, 2019
syntaxes Update the syntax to latest version (#30) Dec 6, 2018
tests
videos
.gitignore Scratch.ts Jun 5, 2018
.vscodeignore
Icon512.png Add icon, set preview, publish Jun 3, 2018
LICENSE.md
NuGet.Config Add config suggested by @alfonsogarciacaro Aug 27, 2018
README.md
TODO.md
appveyor.yml
fsharp-language-server.sln
package-lock.json
package.json 0.1.24 Feb 2, 2019
tsconfig.json

README.md

F# Language Server

This project is an implementation of the language server protocol using the F# Compiler Service.

https://ci.appveyor.com/api/projects/status/github/fsprojects/fsharp-language-server?svg=true

Features

Hover

Hover

Autocomplete

Autocomplete

Method signature help

Signature help

Find symbols in document

Document symbols

Find symbols in workspace

Workspace symbols

Go-to-definition

Go to definition

Find references

Find references

Rename symbol

Rename symbol

Show errors on save

Show errors

Run & Debug tests

Debug test

Code structure

The language server protocol (LSP) is very similar to the API defined by the F# compiler service (FCS); most of the implementation is devoted to translating between the types used by FCS and the JSON representation of LSP.

  • client/extension.ts: Client-side VSCode launcher
  • sample: Example projects used by tests
  • scripts: Scripts for building and testing
  • src/LSP: Server-side implementation of language server protocol
  • src/ProjectCracker: Figures out F# compiler options using Buildalyzer and the MSBuild API.
  • src/FSharpLanguageServer: F# language server
  • tests/LSP.Tests
  • tests/ProjectCracker.Tests
  • tests/FSharpLanguageServer.Tests
  • videos: Animated GIFs on this page

Installation

VSCode

Install from the VSCode extension marketplace

Vim

Clone this repo to your system and build it:

npm install
dotnet build -c Release

Install LanguageClient-neovim

Update your vim config to point LanguageClient-neovim to the FSharp Language Server for fsharp filetypes:

let g:LanguageClient_serverCommands = {
    \ 'fsharp': ['dotnet', '/Users/name/code/fsharp-language-server/src/FSharpLanguageServer/bin/Release/netcoreapp2.0/target/FSharpLanguageServer.dll']
    \ }

Open an fsharp file, move the cursor, and call functions. Mappings are up to you:

  • Hover call LanguageClient#textDocument_hover()
  • Rename: call LanguageClient#textDocument_rename()
  • Definition: call LanguageClient#textDocument_definition()
  • etc...

Neovim with Deoplete completion:
VimDeoplete

(alternatively there is another vim language server plugin vim-lsp but this one hasn't been tried.

Emacs

Spacemacs

Clone this repo to your system and build it:

npm install

# Pick the appropriate target based upon your OS 
dotnet publish -c Release -r linux-x64 src/FSharpLanguageServer
dotnet publish -c Release -r osx.10.11-x64 src/FSharpLanguageServer
dotnet publish -c Release -r win10-x64 src/FSharpLanguageServer

Make sure that the FSharpLanguageServer (in src/FSharpLanguageServer/bin/Release/netcoreapp2.0/PLATFORM/publish) is in your PATH. Alternatively, you can set the path to the server executable manually within your .spacemacs user-config:

(setq fsharp2-lsp-executable "/path/to/FSharpLanguageServer")

Since the stock fsharp layer does not currently include LSP support, you will need to use the fsharp2 layer (a fork of fsharp) which does. To use fsharp2, copy the custom layer into your Spacemacs private layers directory. In order for this layer to work, you must be on the Spacemacs develop branch, since the LSP layer is not yet available in Spacemacs master.

cp -r spacemacs/fsharp2 ~/.emacs.d/private

You may also wish to suppress warnings from lsp-mode, because FSharpLanguageServer emits some notifications that lsp-mode does not support. Note that this configuration applies to all LSP languages, not just F#.

(add-to-list 'warning-suppress-types '(lsp-mode))

Finally, make sure that you have these layers enabled in your dotspacemacs-configuration-layers. You will need to remove the fsharp layer if you have it, since fsharp2 conflicts with it.

  • lsp
  • fsharp2
  • syntax-checking
  • auto-completion

EmacsLspMode

How is this project different than Ionide?

Ionide is a suite of F# plugins for VSCode; F# language server is analagous to the FSAC component. While FSAC is based on a custom JSON protocol; F#LS is based on the language server protocol standard.

The implementation is a thin wrapper around F# Compiler Service and is heavily focused on performance. For example, autocompleting in medium-sized file in F# Language Server (left) and Ionide (right):

Autocomplete warm

You can’t perform that action at this time.