Skip to content

Commit

Permalink
Change Install function to accept a dictionary of options.
Browse files Browse the repository at this point in the history
  • Loading branch information
corbob committed Apr 19, 2019
1 parent 789007e commit a722bbd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Features include:
1. Add this to your `vimrc`/`Init.vim`
```vimL
Plug 'yatli/coc-powershell', {'do': { -> coc#powershell#install()} }
Plug 'yatli/coc-powershell', {'do': { -> coc#powershell#install({})} }
...
Plug 'neoclide/coc.nvim', {'tag': '*', 'do': { -> coc#util#install()}}
```
Expand Down
38 changes: 20 additions & 18 deletions autoload/coc/powershell.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,30 @@ let s:is_mac = !s:is_win && !has('win32unix')
\ && (has('mac') || has('macunix') || has('gui_macvim') ||
\ (!isdirectory('/proc') && executable('sw_vers')))
let s:is_vim = !has('nvim')
if(!exists("g:coc_powershell_prerelease"))
let g:coc_powershell_prerelease = ''
endif
let s:install_script = s:root.'/install.ps1'

let s:install_script = s:root.'/install.ps1 '.g:coc_powershell_prerelease

if(s:is_mac)
let s:install_script = 'pwsh '.s:install_script
endif

if(s:is_win)
let s:powershell_executable = "powershell"
if(executable("pwsh"))
let s:powershell_executable = "pwsh"
function! coc#powershell#install(options)
if(exists('a:options.flags'))
let s:flags = a:options.flags
else
let s:flags = ''
endif
if(exists('a:options.powershellExecutable'))
let s:powershell_executable = a:options.powershellExecutable
else
if(s:is_mac)
let s:powershell_executable = 'pwsh'
endif

let s:install_script = s:powershell_executable.' '.s:install_script
endif

function! coc#powershell#install()
if(s:is_win)
let s:powershell_executable = "powershell"
if(executable("pwsh"))
let s:powershell_executable = "pwsh"
endif
endif
endif
let cwd = getcwd()
exe 'lcd '.s:root
exe '!'.s:install_script
exe '!'.s:powershell_executable.' '.s:install_script.' '.s:flags
exe 'lcd '.cwd
endfunction

0 comments on commit a722bbd

Please sign in to comment.