• Stars
    star
    413
  • Rank 104,801 (Top 3 %)
  • Language
    F#
  • License
    Other
  • Created over 9 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

F# language server using Language Server Protocol

FsAutoComplete

NuGet version (FsAutoComplete)

The FsAutoComplete project (FSAC) provides a backend service for rich editing or intellisense features for editors.

It can be hosted using the Language Server Protocol.

Currently it is used by:

It's based on:

Building and testing

Requirements:

  • .NET SDK, see global.json for the exact version. Minimum: >= 6.0, Recommended: >= 7.0
  1. Restore dotnet tools to install local Paket dotnet tool restore
  2. Build FSAC with dotnet run --project build
  3. Optionally specify a target with the -t parameter: dotnet run --project build -t ....
  • To build release fsautocomplete binaries in ~/bin directory, use the LocalRelease target
  • To build, run all tests and create packages, use the All target

DevContainer

The repository additionally provides DevContainer definition that can be used with VSCode's Remote Containers extension - use it to get stable development environment

Gitpod.io

This repository is prepared to use Gitpod for a web-based VSCode-style IDE. Click the button below to begin!

Gitpod Ready-to-Code

Releasing

  • Update CHANGELOG.md with the release notes from the current release in the Unreleased section. Use section headings like Added, Fixed, etc from keepachangelog.com.
  • For individual section items in the Changelog, use headings like BUGFIX, FEATURE, and ENHANCEMENT followed by a link to the PR with the PR title.
  • Run the Promote FAKE target via the Promote target to create the appropriate release version from the current Unreleased section and stamp the date, as well as create a commit and tag for this promotion
  • push this commit and tag to main
  • the CI pipeline will publish a release from the tag.

OpenTelemetry

FsAutocomplete is using System.Diagnostics.Activity to create traces.

To export traces, run Jaeger

docker run -d --name jaeger \
  -e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \
  -e COLLECTOR_OTLP_ENABLED=true \
  -p 6831:6831/udp \
  -p 6832:6832/udp \
  -p 5778:5778 \
  -p 16686:16686 \
  -p 4317:4317 \
  -p 4318:4318 \
  -p 14250:14250 \
  -p 14268:14268 \
  -p 14269:14269 \
  -p 9411:9411 \
  jaegertracing/all-in-one:latest

Then configure your environment

OTEL_EXPORTER_OTLP_ENDPOINT = "http://localhost:4317"

Start FsAutocomplete (either by code . or dotnet fsautocomplete)

Do some actions like opening documents, saving, getting tooltips, etc.

Then open http://localhost:16686/ to inspect traces.

Communication protocol

FsAutoComplete supports LSP as a communication protocol.

Supported LSP endpoints

  • initialize
  • textDocument/didOpen
  • textDocument/didChange
  • textDocument/didSave
  • textDocument/hover
  • textDocument/completion & completionItem/resolve
  • textDocument/rename
  • textDocument/definition
  • textDocument/typeDefinition
  • textDocument/implementation
  • textDocument/codeAction:
    • Remove unused open
    • Resolve namespace/module
    • Replace unused symbol with _
    • Fix typo based on error message
    • Remove redundant qualifier
    • Add missing new keyword for IDisposable
    • Generate cases for all DU case in pattern matching
    • Generate empty interface implementation
    • Fixes suggested by FSharpLint
  • textDocument/codeLens & codeLens/resolve:
    • signature Code Lenses
    • reference number Code Lenses
  • textDocument/formatting - powered by fantomas
  • textDocument/references
  • textDocument/documentHighlight
  • textDocument/signatureHelp
  • textDocument/documentSymbol
  • textDocument/inlayHint
  • textDocument/inlineValue
  • workspace/didChangeWatchedFiles
  • workspace/didChangeConfiguration
  • workspace/symbol

Custom endpoints

Custom endpoints are using (for messages body) PlainNotification type and string format serialized with exactly same serialization format as old JSON protocol

  • fsharp/signature - accepts TextDocumentPositionParams, returns signature of symbol at given position as a formatted string
  • fsharp/signatureData - accepts TextDocumentPositionParams, returns signature of symbol at given position as DTO
  • fsharp/lineLens - accepts ProjectParms (Project filed contain F# file path), returns locations where LineLenses should be displayed
  • fsharp/compilerLocation - no input, returns paths to FCS, FSI and MsBuild
  • fsharp/compile - accepts ProjectParms, tries to compile project, returns list of errors and exit status code
  • fsharp/workspacePeek - accepts WorkspacePeekRequest, returns list of possible workspaces (resolved solution files, or list of projects if there are no solution files)
  • fsharp/workspaceLoad - accepts WorkspaceLoadParms, loads given list of projects in the background, partial result notified by fsharp/notifyWorkspace notification
  • fsharp/project - accepts ProjectParms, loads given project
  • fsharp/fsdn - accepts ProjectParms (Project filed contain query string), query FSDN and returns list of functions
  • fsharp/f1Help - accepts TextDocumentPositionParams, returns URL to MSDN documentation for symbol at given position
  • fsharp/documentation - accepts TextDocumentPositionParams, returns documentation data about symbol at given position, used for InfoPanel
  • fsharp/documentationSymbol - accepts DocumentationForSymbolReuqest, returns documentation data about given symbol from given assembly, used for InfoPanel
  • fsproj/moveFileUp - accepts DotnetFileRequest, move the file down of 1 line in the project file
  • fsproj/moveFileDown - accepts DotnetFileRequest, move the file up of 1 line in the project file
  • fsproj/addFileAbove - accepts DotnetFile2Request, create the file if needed and add it above the reference file in the project if not already present
  • fsproj/addFileBelow - accepts DotnetFile2Request, create the file if needed and add it below the reference file in the project if not already present
  • fsproj/addFile - accepts DotnetFileRequest, create the file if needed and add it to the project if not already present
  • fsproj/addExistingFile - accepts DotnetFileRequest, add existing file to a project if not already present
  • fsproj/removeFile - accepts DotnetFileRequest, remove the file from the project
  • fsproj/renameFile - accepts DotnetRenameFileRequest, rename the file from the project

Supported LSP notifications

  • window/showMessage
  • window/logMessage
  • textDocument/publishDiagnostics

Custom notifications

  • fsharp/notifyWorkspace - notification for workspace/solution/project loading events
  • fsharp/notifyWorkspacePeek - notification for initial workspace peek

Additional startup options

  • --state-directory dir - a workspace-specific directory for keeping language server states.
  • --verbose - passing this flag enables additional logging being printed out in stderr
  • DOTNET_ROOT - setting this environment variable will set the dotnet SDK root, which is used when finding references for FSX scripts.

Initialization options

Options that should be send as initializationOptions as part of initialize request.

  • AutomaticWorkspaceInit - setting it to true will start Workspace Loading without need to run fsharp/workspacePeek and fsharp/workspaceLoad commands. It will always choose top workspace from the found list - all projects in workspace if 0 .sln files are found, .sln file if 1 .sln file was found, .sln file with most projects if multiple .sln files were found. It's designed to be used in clients that doesn't allow to create custom UI for selecting workspaces.

Settings

  • FSharp.keywordsAutocomplete - provides keywords in autocomplete list, recommended default value: true

  • FSharp.ExternalAutocomplete - provides autocomplete for symbols from not opened namespaces/modules, insert open on accept, recommended default value: false

  • FSharp.Linter - enables FSharpLint integration, provides additional warnings and code action fixes, recommended default value: true

  • FSharp.UnionCaseStubGeneration - enables code action to generate pattern matching cases, recommended default value: true

  • FSharp.UnionCaseStubGenerationBody - defines dummy body used by pattern matching generator, recommended default value: "failwith \"Not Implemented\""

  • FSharp.RecordStubGeneration - enables code action to generate record stub, recommended default value: true

  • FSharp.RecordStubGenerationBody - defines dummy body used by record stub generator, recommended default value: "failwith \"Not Implemented\""

  • FSharp.InterfaceStubGeneration - enables code action to generate interface stub, recommended default value: true

  • FSharp.InterfaceStubGenerationObjectIdentifier - defines object identifier used by interface stub generator,recommended default value: "this"

  • FSharp.InterfaceStubGenerationMethodBody - defines dummy body used by interface stub generator, recommended default value: "failwith \"Not Implemented\""

  • FSharp.UnusedOpensAnalyzer - enables unused open detections, recommended default value: true

  • FSharp.UnusedDeclarationsAnalyzer - enables unused symbol detection, recommended default value: true

  • FSharp.UseSdkScripts - enables the use of .Net Core SDKs for script file type-checking and evaluation, otherwise the .Net Framework reference lists will be used. Recommended default value: true. Current default value: true

  • FSharp.SimplifyNameAnalyzer - enables simplify name analyzer and remove redundant qualifier quick fix, recommended default value: false

  • FSharp.ResolveNamespaces - enables resolve namespace quick fix (add open if symbol is from not yet opened module/namespace), recommended default value: true

  • FSharp.EnableReferenceCodeLens - enables reference count code lenses, recommended default value: true if --background-service-enabled is used by default, false otherwise

  • FSharp.dotNetRoot - sets the root path for finding dotnet SDK references. Primarily used for FSX Scripts. Default value: operating-system dependent. On windows, C:\Program Files\dotnet; on Unix, /usr/local/share/dotnet

  • FSharp.fsiExtraParameters - an array of additional runtime arguments that are passed to FSI. These are used when typechecking scripts to ensure that typechecking has the same context as your FSI instances. An example would be to set the following parameters to enable Preview features (like opening static classes) for typechecking.

        "FSharp.fsiExtraParameters": ["--langversion:preview"]

Debug Settings

Settings to change internal behavior. Intended for debugging purposes and not for normal use.

  • FSharp.Debug.DontCheckRelatedFiles - usually checking a file involves checking related files too. This prevents this and limits file checking to just the current file.
    Default: false
  • FSharp.Debug.CheckFileDebouncerTimeout - Duration (in ms) of no user write activity (in practice: no LSP textDocument/didChange notification) before file checking gets triggered.
    Default: 250
  • FSharp.Debug.LogDurationBetweenCheckFiles: Logs duration between the start of to consecutive file checks.
    Default: false
  • FSharp.Debug.LogCheckFileDuration: Logs duration of file checking operation.
    Default: false

Troubleshooting

FileWatcher exceptions

You may see a stack trace finishing with System.IO.IOException: kqueue() error at init, error code = ’0’. This is due to a limitation in the number of file handles that the Mono file watchers can keep open. Restarting FsAutoComplete or the hosting editor should help. If not, try setting export MONO_MANAGED_WATCHER=disabled in your ~/.bash_profile. Note that on OSX, this setting will only take effect if you launch emacs from the terminal.

Maintainers

The maintainers of this repository are:

Previous maintainers:

More Repositories

1

ionide-vscode-fsharp

VS Code plugin for F# development
F#
858
star
2

Fornax

Scriptable static site generator using type safe F# DSL to define page templates.
F#
244
star
3

Forge

F# CLI tool for project, file, and solution management
F#
231
star
4

Ionide-vim

F# Vim plugin based on FsAutoComplete and LSP protocol
Vim Script
175
star
5

ionide-atom-fsharp

Set of Atom plugins for F# development
F#
174
star
6

tree-sitter-fsharp

F# grammar for treesitter
C
82
star
7

Waypoint

Opinionated solution template for building F# OSS libraries and tools.
F#
76
star
8

FSharp.Analyzers.SDK

Library for building custom analyzers for F# / FSAC
F#
74
star
9

proj-info

Parse and evaluate MsBuild project files
F#
64
star
10

FsAst

http://blog.ctaggart.com/2014/09/generating-f-code-using-its-ast.html
F#
48
star
11

LanguageServerProtocol

Library for building Language Server Protocol servers and clients in F#.
F#
45
star
12

ionide-vscode-paket

VS Code plugin for Paket
F#
40
star
13

fstoml

Lightweight TOML based F# project file
F#
36
star
14

ionide-fsgrammar

Shared Textmate Regex Style F# Language Grammar
F#
35
star
15

FSharp.EventHorizon

Experiment with F#, type holes, and type-directed search using F# Analyzers
F#
32
star
16

KeepAChangelog

Parser and MSBuild Targets for using Keep-A-Changelog-formatted Changelogs in your Build
F#
30
star
17

Falcon

FSI β™₯️ IDE
F#
20
star
18

ionide-vscode-mechanic

Mechanic plugin for VS Code
F#
17
star
19

DependencyManager.FsProj

Dependency Manager loading fsproj into FSI instance
F#
17
star
20

ionide-vscode-fake

VS Code plugin for FAKE
F#
17
star
21

ionide-vscode-helpers

Common helpers for VS Code plugins
F#
15
star
22

FsInteractiveService

F# interactive service API exposed via a lightweight HTTP server
F#
14
star
23

playground

Empty F# project that can be opened in Visual Studio Online or Gitpod
Dockerfile
13
star
24

ionide-atom-paket

Atom editor support for Paket.
F#
13
star
25

ionide-atom-fsi

F#
11
star
26

forge-templates

F# Project and Solution Templates for Forge
F#
8
star
27

Discover-Panel

Extension creating alternative UX for real-time API exploration in VSCode
TypeScript
8
star
28

ionide.github.io

Ionide.io page
CSS
6
star
29

ionide-analyzers

F#
6
star
30

ionide-atom-installer

JavaScript
5
star
31

dotnet-devcontainer

Basic Devcontainer example for C# + F# dev
Dockerfile
4
star
32

ionide-atom-fake

F#
3
star
33

LSIF-Reader

TypeScript library for reading LSIF files, and providing editor tooling based on them
TypeScript
3
star
34

ionide-atom-webview

F#
1
star