diff options
Diffstat (limited to 'autoload/fsharp.vim')
-rw-r--r-- | autoload/fsharp.vim | 102 |
1 files changed, 101 insertions, 1 deletions
diff --git a/autoload/fsharp.vim b/autoload/fsharp.vim index 8567a037..d18f2bbc 100644 --- a/autoload/fsharp.vim +++ b/autoload/fsharp.vim @@ -233,6 +233,107 @@ function! fsharp#updateServerConfig() call s:notify('workspace/didChangeConfiguration', settings) endfunction +function! fsharp#loadConfig() + if exists('s:config_is_loaded') + return + endif + + if !exists('g:fsharp#fsautocomplete_command') + let s:fsac = fnamemodify(s:script_root_dir . "fsac/fsautocomplete.dll", ":p") + + " check if FSAC exists + if empty(glob(s:fsac)) + echoerr "FSAC not found. :FSharpUpdateFSAC to download." + let &cpo = s:cpo_save + finish + endif + + let g:fsharp#fsautocomplete_command = + \ ['dotnet', s:fsac, + \ '--background-service-enabled' + \ ] + endif + if !exists('g:fsharp#use_recommended_server_config') + let g:fsharp#use_recommended_server_config = 1 + endif + call fsharp#getServerConfig() + if !exists('g:fsharp#automatic_workspace_init') + let g:fsharp#automatic_workspace_init = 1 + endif + if !exists('g:fsharp#automatic_reload_workspace') + let g:fsharp#automatic_reload_workspace = 1 + endif + if !exists('g:fsharp#show_signature_on_cursor_move') + let g:fsharp#show_signature_on_cursor_move = 1 + endif + if !exists('g:fsharp#fsi_command') + let g:fsharp#fsi_command = "dotnet fsi" + endif + if !exists('g:fsharp#fsi_keymap') + let g:fsharp#fsi_keymap = "vscode" + endif + if !exists('g:fsharp#fsi_window_command') + let g:fsharp#fsi_window_command = "botright 10new" + endif + if !exists('g:fsharp#fsi_focus_on_send') + let g:fsharp#fsi_focus_on_send = 0 + endif + if !exists('g:fsharp#backend') + if has('nvim-0.5') + if exists('g:LanguageClient_loaded') + let g:fsharp#backend = "languageclient-neovim" + else + let g:fsharp#backend = "nvim" + endif + else + let g:fsharp#backend = "languageclient-neovim" + endif + endif + + " backend configuration + if g:fsharp#backend == 'languageclient-neovim' + if !exists('g:LanguageClient_serverCommands') + let g:LanguageClient_serverCommands = {} + endif + if !has_key(g:LanguageClient_serverCommands, 'fsharp') + let g:LanguageClient_serverCommands.fsharp = { + \ 'name': 'fsautocomplete', + \ 'command': g:fsharp#fsautocomplete_command, + \ 'initializationOptions': {}, + \} + if g:fsharp#automatic_workspace_init + let g:LanguageClient_serverCommands.fsharp.initializationOptions = { + \ 'AutomaticWorkspaceInit': v:true, + \} + endif + endif + + if !exists('g:LanguageClient_rootMarkers') + let g:LanguageClient_rootMarkers = {} + endif + if !has_key(g:LanguageClient_rootMarkers, 'fsharp') + let g:LanguageClient_rootMarkers.fsharp = ['*.sln', '*.fsproj', '.git'] + endif + elseif g:fsharp#backend == 'nvim' + if !exists('g:fsharp#lsp_auto_setup') + let g:fsharp#lsp_auto_setup = 1 + endif + if !exists('g:fsharp#lsp_recommended_colorscheme') + let g:fsharp#lsp_recommended_colorscheme = 1 + endif + if !exists('g:fsharp#lsp_codelens') + let g:fsharp#lsp_codelens = 1 + endif + + else + if g:fsharp#backend != 'disable' + echoerr "[FSAC] Invalid backend: " . g:fsharp#backend + endif + endif + + let s:config_is_loaded = 1 +endfunction + " handlers for notifications @@ -617,7 +718,6 @@ function! fsharp#sendAllToFsi() return fsharp#sendFsi(text) endfunction - let &cpo = s:cpo_save unlet s:cpo_save |