Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
# Install the PHP dependencies
- composer install --optimize-autoloader --classmap-authoritative
- bin/phpactor --version
- sudo add-apt-repository --yes ppa:jonathonf/vim
- sudo apt-get update -y
- sudo apt-get install vim -fy
# Install the VIM testing framework
Expand Down
12 changes: 11 additions & 1 deletion autoload/phpactor.vim
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,15 @@ function! phpactor#_applyTextEdits(path, edits)
call setpos('.', postCursorPosition)
endfunction

function! phpactor#getRootDirectory() abort
let l:Strategy = get(b:, 'PhpactorRootDirectoryStrategy', g:PhpactorRootDirectoryStrategy)

if type(function('type')) != type(l:Strategy)
let l:Strategy = {-> g:phpactorInitialCwd}
endif

return l:Strategy()
endfunction

"""""""""""""""""""""""
" RPC -->-->-->-->-->--
Expand All @@ -465,7 +474,8 @@ function! phpactor#rpc(action, arguments)

let request = { "action": a:action, "parameters": a:arguments }

let l:workspaceDir = g:phpactorInitialCwd
let l:workspaceDir = phpactor#getRootDirectory()

let l:cmd = g:phpactorPhpBin . ' ' . g:phpactorbinpath . ' rpc --working-dir=' . l:workspaceDir

let result = system(l:cmd, json_encode(request))
Expand Down
6 changes: 6 additions & 0 deletions doc/phpactor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ is to use the VIM inputlist.
When jumping to a file location: if the target file open in a window, switch
to that window instead of switching buffers. The default is false.

*g:PhpactorRootDirectoryStrategy*
Each RPC call to phpactor comes with some workspace root directory. This
setting allows select a |Funcref| to the custom strategy that can assign this
directory. Notice the upper case of the first letter of this variable.
Currently no arguments is passed to the function.

==============================================================================
COMPLETION *phpactor-completion*

Expand Down
7 changes: 7 additions & 0 deletions plugin/phpactor.vim
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ let g:phpactorInputListStrategy = get(g:, 'phpactorInputListStrategy', 'phpactor
" to that window instead of switching buffers. The default is false.
let g:phpactorUseOpenWindows = get(g:, 'phpactorUseOpenWindows', v:false)

""
" Each RPC call to phpactor comes with some workspace root directory.
" This setting allows select a |Funcref| to the custom strategy that can assign this directory.
" Notice the upper case of the first letter of this variable.
" Currently no arguments is passed to the function.
let g:PhpactorRootDirectoryStrategy = get(g:, 'PhpactorRootDirectoryStrategy', {-> g:phpactorInitialCwd})

" Config }}}

" Commands {{{
Expand Down