Skip to content

Commit

Permalink
Support fsiExtraParameters
Browse files Browse the repository at this point in the history
  • Loading branch information
cannorin committed Nov 25, 2019
1 parent e0e01bd commit dd47d24
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
8 changes: 8 additions & 0 deletions README.mkd
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,14 @@ let g:fsharp#fsi_command = "fsharpi"
let g:fsharp#use_sdk_scripts = 0 " for net462 FSI
~~~

##### Set 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.

~~~.vim
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.
Expand Down
17 changes: 14 additions & 3 deletions autoload/fsharp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ let s:config_keys_camel =
\ {'key': 'AutomaticWorkspaceInit', 'default': 1},
\ {'key': 'WorkspaceModePeekDeepLevel', 'default': 2},
\ {'key': 'ExcludeProjectDirectories', 'default': []},
\ {'key': 'KeywordsAutocomplete', 'default': 1},
\ {'key': 'keywordsAutocomplete', 'default': 1},
\ {'key': 'ExternalAutocomplete', 'default': 0},
\ {'key': 'Linter', 'default': 1},
\ {'key': 'UnionCaseStubGeneration', 'default': 1},
Expand All @@ -151,6 +151,8 @@ let s:config_keys_camel =
\ {'key': 'DisableInMemoryProjectReferences', 'default': 0},
\ {'key': 'LineLens', 'default': {'enabled': 'replaceCodeLens', 'prefix': '//'}},
\ {'key': 'UseSdkScripts', 'default': 1},
\ {'key': 'dotNetRoot'},
\ {'key': 'fsiExtraParameters', 'default': []},
\ ]
let s:config_keys = []

Expand Down Expand Up @@ -362,8 +364,17 @@ function! s:win_gotoid_safe(winid)
endif
endfunction

function! s:get_fsi_command()
let cmd = g:fsharp#fsi_command
for prm in g:fsharp#fsi_extra_parameters
let cmd = cmd . " " . prm
endfor
return cmd
endfunction

function! fsharp#openFsi(returnFocus)
if bufwinid(s:fsi_buffer) <= 0
let fsi_command = s:get_fsi_command()
" Neovim
if exists('*termopen') || exists('*term_start')
let current_win = win_getid()
Expand All @@ -378,7 +389,7 @@ function! fsharp#openFsi(returnFocus)
if a:returnFocus | call s:win_gotoid_safe(current_win) | endif
" open FSI: Neovim
elseif has('nvim')
let s:fsi_job = termopen(g:fsharp#fsi_command)
let s:fsi_job = termopen(fsi_command)
if s:fsi_job > 0
let s:fsi_buffer = bufnr("%")
else
Expand All @@ -393,7 +404,7 @@ function! fsharp#openFsi(returnFocus)
\ "curwin": 1,
\ "term_finish": "close"
\ }
let s:fsi_buffer = term_start(g:fsharp#fsi_command, options)
let s:fsi_buffer = term_start(fsi_command, options)
if s:fsi_buffer != 0
if exists('*term_setkill') | call term_setkill(s:fsi_buffer, "term") | endif
let s:fsi_job = term_getjob(s:fsi_buffer)
Expand Down

0 comments on commit dd47d24

Please sign in to comment.