/Ionide-vim

F# Vim plugin based on FsAutoComplete and LSP protocol

Primary LanguageVim ScriptMIT LicenseMIT

Ionide-Vim

F# support for Vim/Neovim

Part of the Ionide plugin suite.

About Ionide-Vim

Development Status

Consider this to be beta since it's lacking features compared to Ionide-VSCode and not as battle-tested as that.

That being said, we maintainers use this plugin daily so it will someday become feature-rich and stable for sure.

Feel free to request features and/or file bug reports!

Requirements

  • Neovim or Vim 8.0+

    • Python support is not required as of now. This may or may not change in the future.
  • .NET Core SDK

    • Required to run FsAutoComplete.
    • Very useful for command-line development.
  • LanguageClient-neovim

    • Required to communicate with FsAutoComplete.
  • fzf (optional)

    • Optional dependency of LanguageClient-neovim.
    • Multi-entry selection UI.

Features

  • Syntax highlighting
  • Auto completions
  • Error highlighting
  • Tooltips
  • Go to Definition
  • Find all references
  • Highlighting usages
  • Rename
  • Show symbols in file
  • Find symbol in workspace
  • Show signature in status line

Getting Started

Refer to their INSTALL.md.

2. Install Ionide-vim

Installing with your plugin manager

Plug 'ionide/Ionide-vim', {
      \ 'do':  'make fsautocomplete',
      \}
call dein#add('ionide/Ionide-vim', {
    \ 'build': 'make fsautocomplete',
    \ })

Installing on Windows

Run install.cmd.

3. Setting up the language client

Once you installed, add the following to somewhere in your .vimrc:

let g:LanguageClient_serverCommands = {
  \ 'fsharp': g:fsharp#languageserver_command
  \ }

This will configure FSAC to be used from LanguageClient-neovim.

Usage

Opening either *.fs, *.fsi or *.fsx files should trigger syntax highlighting and other depending runtime files as well.

Commands

Refer to LanguageClient-neovim for features provided via Language Server Protocol.

To be added as requested for F#-specific features.

:FSharpLoadWorkspaceAuto

  • Search a workspace (sln or fsproj) and then load it.
  • Equivalent to FSharp.workspaceMode = sln in Ionide-VSCode.
  • Automatically called when you open F# files. Can be disabled in settings.
  • The deep level of directory hierarchy to search can also be configured in settings.

:FSharpParseProject <files>+

  • Load specified projects (sln or fsproj).

:FSharpReloadWorkspace

  • Reload all the projects currently loaded.
  • Automatically called when you save .fsproj files. Can be disabled in settings.

:FSharpUpdateFSAC

  • Download the latest build of FsAutoComplete to be used with Ionide-vim.

Settings

Refer to LanguageClient-neovim for features provided via Language Server Protocol.

To be added as requested for F#-specific features.

Enable/disable automatic calling of :FSharpLoadWorkspaceAuto on opening F# files (default: 1)

let g:fsharp#automatic_workspace_init = 1 " 0 to disable.

Set the deep level of directory hierarchy when searching for sln/fsprojs (default: 2)

let g:fsharp#workspace_mode_peek_deep_level = 2

Enable/disable automatic calling of :FSharpReloadWorkspace on saving fsproj (default: 1)

let g:fsharp#automatic_reload_workspace = 1 " 0 to disable.

Show type signature at cursor position (default: 1)

let g:fsharp#show_signature_on_cursor_move = 1 " 0 to disable.

Advanced Tips

Show tooltips on CursorHold

If you are using neovim 0.4.0 or later, floating windows will be used for tooltips and you might find it convenient to make them appear if the cursor does not move for several seconds.

if has('nvim') && exists('*nvim_open_win')
  augroup FSharpShowTooltip
    autocmd!
    autocmd CursorHold *.fs call fsharp#showTooltip()
  augroup END
endif

Note that you can set the delay time to show the tooltip by set updatetime=<ms>. The default delay is 4 seconds, which you may find too slow.

Maintainers

  • The primary maintainer for this repository is @cannorin.