Ⅰ. 插件描述
F# Vim plugin based on FsAutoComplete and LSP protocolⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'ionide/ionide-vim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'ionide/ionide-vim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'ionide/ionide-vim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/ionide/ionide-vim
Ⅳ. 文档说明
# Ionide-Vim
F# support for Vim/Neovim

Part of the Ionide plugin suite.
About Ionide-Vim
- A fork of fsharp/vim-fsharp.
- Uses LSP-mode of FsAutoComplete as a backend.
- Powered by autozimu/LanguageClient-neovim.
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.
- Required to run FsAutoComplete.
- Very useful for command-line development.
- Required to communicate with FsAutoComplete.
fzf (optional)
- Optional dependency of LanguageClient-neovim.
- Multi-entry selection UI.
Features
- Syntax highlighting
- Auto completions
- Error highlighting, error list, and quick fixes based on errors
- Tooltips
- Go to Definition
- Find all references
- Highlighting usages
- Rename
- Show symbols in file
- Find symbol in workspace
- Show signature in status line
- Integration with F# Interactive (new!)
- Integration with FSharpLint (additional hints and quick fixes) (new!)
Getting Started
1. Install LanguageClient-neovim
Refer to their INSTALL.md.
2. Install Ionide-vim
Installing with your plugin manager
vim-plug
Plug 'ionide/Ionide-vim', {
\ 'do': 'make fsautocomplete',
\}dein.vim
call dein#add('ionide/Ionide-vim', {
\ 'build': 'make fsautocomplete',
\ })Installing manually
Clone Ionide-vim to some runtimepath and run make fsautocomplete.
Installing on Windows
Run install.cmd.
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
- Searches a workspace (
slnorfsproj) and then load it. - Equivalent to
FSharp.workspaceMode = slnin 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>+
- Loads specified projects (
slnorfsproj).
:FSharpReloadWorkspace
- Reloads all the projects currently loaded.
- Automatically called when you save
.fsprojfiles. Can be disabled in settings.
:FSharpUpdateServerConfig
- Updates FSAC configuration.
- See FsAutoComplete Settings for details.
:FSharpUpdateFSAC
- Downloads the latest build of FsAutoComplete to be used with Ionide-vim.
Working with F# Interactive
Ionide-vim has an integration with F# Interactive.
FSI is displayed using the builtin :terminal feature introduced in Vim 8 / Neovim and can be used like in VSCode.
:FsiShow
- Shows a F# Interactive window.
:FsiEval <expr>
- Evaluates given expression in FSI.
:FsiEvalBuffer
- Sends the content of current file to FSI.
:FsiReset
- Resets the current FSI session.
Alt-Enter
- When in normal mode, sends the current line to FSI.
- When in visual mode, sends the selection to FSI.
- Sending code to FSI opens FSI window but the cursor does not focus to it. Unlike Neovim, Vim doesn't support asynchronous buffer updating so you have to input something (e.g. moving cursor) to see the result. You can change this behavior in settings.
Alt-@
- Toggles FSI window. FSI windows shown in different tabpages share the same FSI session.
- When opened, the cursor automatically focuses to the FSI window (unlike in
Alt-Enterby default).
You can customize the location of FSI, key mappings, etc. See the documentation below.
Settings
Refer to LanguageClient-neovim's recommended settings
for features provided via Language Server Protocol.
To be added as requested for F#-specific features.
FsAutoComplete Settings
Ionide-vim uses
snake_casefor the setting names.- For FSAC settings only,
CamelCasecan also be used (as it gets serialized to a F# record). - If both
snake_caseandCamelCaseare specified, thesnake_caseone will be preferred.
- For FSAC settings only,
- You can change the values at runtime and then notify the changes to FSAC by
:FSharpUpdateServerConfig. - Some of the settings may not work in Ionide-vim as it is lacking the corresponding feature of Ionide-VSCode.
If not specified, the recommended default values described on the FSAC's documentation will be used.
- If you are using a JSON configuration file though
g:LanguageClient_settingsPath, the recommended default values will override the settings loaded from it. - You can disable this by
let g:fsharp#use_recommended_server_config = 0.
- If you are using a JSON configuration file though
See the documentation of FSAC
for the complete list of available settings. Frequently used ones are:
Enable/disable automatic calling of :FSharpLoadWorkspaceAuto on opening F# files (default: enabled)
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 = 2Ignore specific directories when loading a workspace (default: empty)
let g:fsharp#exclude_project_directories = ['paket-files']Enable/disable linter and unused opens/declarations analyzer (default: all enabled)
You may want to bind LanguageClient#textDocument_codeAction() to some shortcut key. Refer to their docs.
" 0 to disable.
let g:fsharp#linter = 1
let g:fsharp#unused_opens_analyzer = 1
let g:fsharp#unused_declarations_analyzer = 1Editor Settings
Enable/disable automatic calling of :FSharpReloadWorkspace on saving fsproj (default: enabled)
let g:fsharp#automatic_reload_workspace = 1 " 0 to disable.Show type signature at cursor position (default: enabled)
let g:fsharp#show_signature_on_cursor_move = 1 " 0 to disable.F# Interactive Settings
Change the F# Interactive command to be used within Ionide-vim (default: dotnet fsi)
If you want to use a .NET Framework FSI instead of .NET Core one, set g:fsharp#use_sdk_scripts to 0.
See: https://github.com/fsharp/FsAutoComplete/pull/466#issue-324869672
let g:fsharp#fsi_command = "fsharpi"
let g:fsharp#use_sdk_scripts = 0 " for net462 FSISet additional runtime arguments passed to FSI (default: [] (empty))
Sets additional arguments of the FSI instance Ionide-vim spawns and changes the behavior of FSAC accordingly when editing fsx files.
let g:fsharp#fsi_extra_parameters = ['--langversion:preview']Customize how FSI window is opened (default: botright 10new)
It must create a new empty window and then focus to it.
See :help opening-window for details.
let g:fsharp#fsi_window_command = "botright vnew"Set if sending line/selection to FSI shoule make the cursor focus to FSI window (default: disabled)
If you are using Vim, you might want to enable this to see the result without inputting something.
let g:fsharp#fsi_focus_on_send = 1 " 0 to not to focus.Change the key mappings (default: vscode)
vscode: Default. Same as in Ionide-VSCode (Alt-Enterto send,Alt-@to toggle terminal).<M-CR>in Neovim /<ESC><CR>in Vim: Sends line/selection to FSI.<M-@>in Neovim /<ESC>@in Vim: Toggles FSI window.
vim-fsharp: Same as in fsharp/vim-fsharp. Note that<leader>is mapped to backslash by default. See:help mapleader.<leader>i: Sends line/selecion to FSI.<leader>e: Toggles FSI window.
custom: You must set bothg:fsharp#fsi_keymap_sendandg:fsharp#fsi_keymap_toggleby yourself.g:fsharp#fsi_keymap_send: Sends line/selection to FSI.g:fsharp#fsi_keymap_toggle: Toggles FSI window.
none: Disables mapping.
" custom mapping example
let g:fsharp#fsi_keymap = "custom"
let g:fsharp#fsi_keymap_send = "<C-e>"
let g:fsharp#fsi_keymap_toggle = "<C-@>"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,*.fsi,*.fsx call fsharp#showTooltip()
augroup END
endifNote 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.