Skip to content

Latest commit

 

History

History
297 lines (228 loc) · 6.4 KB

README.md

File metadata and controls

297 lines (228 loc) · 6.4 KB

MIT-LICENSE Gitter

alt text

deoplete-fsharp

deoplete.nvim source for F#
Using deopletefs that is command-line interface to the FSharp.Compiler.Service.
It's useful to write a small code in F# script file ( .fsx ) .

Requires

mono ( >= Mono 5.4.0 )
fsharp

Install

Vim

// download
$ git clone --depth 1 https://github.com/Shougo/deoplete.nvim
$ git clone --depth 1 https://github.com/callmekohei/deoplete-fsharp
$ git clone --depth 1 https://github.com/roxma/nvim-yarp
$ git clone --depth 1 https://github.com/roxma/vim-hug-neovim-rpc

// install
$ cd ./deoplete-fsharp/
$ bash install.bash ( or install.cmd )

// set runtimepath
$ vim .vimrc
    set runtimepath+=/path/to/deoplete
    set runtimepath+=/path/to/deoplete-fsharp
    set runtimepath+=/path/to/nvim-yarp
    set runtimepath+=/path/to/vim-hug-neovim-rpc

NeoVim

// download
$ git clone --depth 1 https://github.com/Shougo/deoplete.nvim
$ git clone --depth 1 https://github.com/callmekohei/deoplete-fsharp

// install
$ cd ./deoplete-fsharp/
$ bash install.bash ( or install.cmd )

// set runtimepath
$ vim .vimrc
    set runtimepath+=/path/to/deoplete
    set runtimepath+=/path/to/deoplete-fsharp

Example of deoplete setting

" .vimrc ( or init.vim )

autocmd MyAutoCmd VimEnter *.fsx,*.fs call s:foo()
function s:foo() abort
  call deoplete#custom#option({
    \   'auto_refresh_delay' : 20
    \ , 'min_pattern_length' : 999
    \ , 'ignore_case'        : v:true
    \ , 'refresh_always'     : v:false
    \ , 'ignore_sources' : {'fsharp':['member']}
  \ })
  call deoplete#enable()
endfunction

More info. for F# script file

01. Run

alt text

Requires

vim-quickrun
vimproc.vim

Install and build

// download
$ git clone --depth 1 https://github.com/thinca/vim-quickrun
$ git clone --depth 1 https://github.com/Shougo/vimproc.vim

// build
$ cd ./vimproc/
$ make

// set runtimepath
$ vim .vimrc
    set runtimepath+=/path/to/vim-quickrun
    set runtimepath+=/path/to/vimproc.vim

Example of vim-quickrun setting

" .vimrc ( or init.vim )
let g:quickrun_config = {}

let g:quickrun_config._ = {
    \  'runner'                          : 'vimproc'
    \ ,'runner/vimproc/updatetime'       : 60
    \ ,'hook/time/enable'                : 1
    \ ,'hook/time/format'                : "\n*** time : %g s ***"
    \ ,'hook/time/dest'                  : ''
    \ ,"outputter/buffer/split"          : 'vertical'
    \ ,'outputter/buffer/close_on_empty' : 1
\}

let g:quickrun_config.fsharp = {
    \  'command'                         : 'fsharpi --readline-'
    \ ,'runner'                          : 'concurrent_process'
    \ ,'runner/concurrent_process/load'  : '#load "%S";;'
    \ ,'runner/concurrent_process/prompt': '> '
\}

If you use window's Vim / Neovim

'command': 'mono "path\to\fsi.exe" --readline-'

Run F# script file

: w
: QuickRun

02. Test

alt text

Requires

Persimmon.Script

Install ( requires Paket )

// make foo folder and move to foo folder
$ mkdir foo/
$ cd foo/

// install
$ paket init
$ vim paket.dependencies
    generate_load_scripts: true
    source https://www.nuget.org/api/v2
    nuget persimmon.script
$ paket install

Test F# script file

: w
: QuickRun

Sample code

#load "./.paket/load/net471/main.group.fsx"

open Persimmon
open UseTestNameByReflection
open System.Reflection

/// write your test code here.
let ``a unit test`` = test {
  do! assertEquals 1 2
}

/// print out test report.
new Persimmon.ScriptContext()
|> FSI.collectAndRun( fun _ -> Assembly.GetExecutingAssembly() )

03. Debug

alt text

Requires

sdb
sdbplg
tigaDebugger

tigaDebugger is available with only Vim8 ( +python3, +terminal ).

Install

sdb

// download
$ git clone --depth 1 https://github.com/mono/sdb

// clone the submodules
$ cd ./sdb/
$ git submodule update --init --recursive

// build
$ make
$ make install

sdbplg

// download
$ git clone --depth 1 https://github.com/callmekohei/sdbplg

// build 
$ cd ./sdbplg/
$ bash build.bash

// put `.sdb.rc` file on `$HOME`
$ cp .sdb.rc $HOME/

// set path
$ vim $HOME/.bash_profile
    export SDB_PATH=/PATH/TO/sdbplg/bin/

tigaDebugger

// download
$ git clone --depth 1 https://github.com/callmekohei/tigaDebugger
$ git clone --depth 1 https://github.com/roxma/nvim-yarp
$ git clone --depth 1 https://github.com/roxma/vim-hug-neovim-rpc

// install neovim plugins
$ pip3 install neovim

// set runtimepath
$ vim .vimrc
    set runtimepath+=/path/to/tigaDebugger
    set runtimepath+=/path/to/nvim-yarp
    set runtimepath+=/path/to/vim-hug-neovim-rpc

Usage

// write fsharp code
$ vim foo.fsx

    let foo() =
        let mutable x = 1
        x <- 2
        x <- 3
        x

    foo ()
    |> stdout.WriteLine


// compile file
$ fsharpc -g --optimize- foo.fsx

// open file
$ vim foo.fsx

// start debug mode
: TigaSetDebugger sdb
: Tiga foo.exe

// set break point
: TigaCommand bp add at foo.fsx 3

// run
: TigaCommand r

// next
: TigaCommand n

// quit debug mode
: TigaQuit

tigaDebugger Shortcut Keys

Press To
ctrl b Add or delete Breakpoint
ctrl d Delete all breakpoints
ctrl r Run
ctrl k Kill (Break)
ctrl p Replace watch variable
ctrl y Add watch variable
ctrl t Delete watch variable
ctrl n Step over ( Next )
ctrl i Step In
ctrl u Step out ( Up )
ctrl c Continue