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: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Features:
- [reference-finder] Goto type: goto the type of the symbol under the cursor #892 - @dantleech
- [worse-reflection] Enable cache lifetime (important for long running
processes) (#929) - @dantleech
- [vim-plugin] Detect the current workspace directory (#923) - @przepompownia
- [language-server] Included in the core - @dantleech
- [indexer] Indexer included in the core - @dantleech
- [rpc] Add docblock prose to hover
Expand Down
39 changes: 1 addition & 38 deletions autoload/phpactor.vim
Original file line number Diff line number Diff line change
Expand Up @@ -459,50 +459,13 @@ endfunction
" RPC -->-->-->-->-->--
"""""""""""""""""""""""

function! s:searchDirectoryUpwardForRootPatterns(initialDirectory, workspaceRootPatterns, fallbackDirectory)
if index(g:phpactorGlobalRootPatterns, '/') < 0
call add(g:phpactorGlobalRootPatterns, '/')
endif

let l:directory = a:initialDirectory

while index(g:phpactorGlobalRootPatterns, l:directory) < 0
if s:directoryMatchesToPatterns(l:directory, a:workspaceRootPatterns)
return l:directory
endif

let l:directory = fnamemodify(l:directory, ':h')
endwhile

if index(g:phpactorGlobalRootPatterns, l:directory) >= 0
let l:directory = a:fallbackDirectory
endif

return l:directory
endfunction

function s:directoryMatchesToPatterns(directory, patterns) abort
for l:pattern in a:patterns
if (filereadable(a:directory .'/'. l:pattern))
return v:true
endif
endfor

return v:false
endfunction

function! phpactor#rpc(action, arguments)
" Remove any existing output in the message window
execute ':redraw'

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

let l:workspaceDir = empty(g:phpactorProjectRootPatterns) ? g:phpactorInitialCwd : s:searchDirectoryUpwardForRootPatterns(
\ fnamemodify(phpactor#_path(), ':h'),
\ g:phpactorProjectRootPatterns,
\ g:phpactorInitialCwd
\)

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

let result = system(l:cmd, json_encode(request))
Expand Down
7 changes: 0 additions & 7 deletions doc/phpactor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,6 @@ 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:phpactorProjectRootPatterns*
The list of files that determine workspace root directory if contained within

*g:phpactorGlobalRootPatterns*
The list of directories that should not be considered as workspace root
directory (in addition to '/' which is always considered)

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

Expand Down
10 changes: 0 additions & 10 deletions plugin/phpactor.vim
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,6 @@ 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)

""
" The list of files that determine workspace root directory
" if contained within
let g:phpactorProjectRootPatterns = get(g:, 'phpactorProjectRootPatterns', [])

""
" The list of directories that should not be considered as workspace root directory
" (in addition to '/' which is always considered)
let g:phpactorGlobalRootPatterns = get(g:, 'phpactorGlobalRootPatterns', ['/', '/home'])

" Config }}}

" Commands {{{
Expand Down