Giter VIP home page Giter VIP logo

deoplete-fsharp's Introduction

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

deoplete-fsharp's People

Contributors

callmekohei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.