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
16 changes: 11 additions & 5 deletions autoload/phpactor.vim
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
" https://github.com/google/vimdoc. See
" https://phpactor.github.io/phpactor/developing.html#vim-help

let s:_phpactorCompletionMeta = {}
Comment thread
camilledejoye marked this conversation as resolved.
Resolved

function! phpactor#Update()
let current = getcwd()
execute 'cd ' . g:phpactorpath
Expand Down Expand Up @@ -53,7 +55,7 @@ function! phpactor#Complete(findstart, base)
let issues = result['issues']

let completions = []
let g:_phpactorCompletionMeta = {}
let s:_phpactorCompletionMeta = {}

if !empty(suggestions)
for suggestion in suggestions
Expand All @@ -66,7 +68,7 @@ function! phpactor#Complete(findstart, base)
\ 'icase': g:phpactorCompletionIgnoreCase
\ }
call add(completions, completion)
let g:_phpactorCompletionMeta[phpactor#_completionItemHash(completion)] = suggestion
let s:_phpactorCompletionMeta[phpactor#_completionItemHash(completion)] = suggestion
endfor
endif

Expand All @@ -87,16 +89,20 @@ endfunction

function! phpactor#_completeImportClass(completedItem)

if get(b:, 'phpactorOmniAutoClassImport', g:phpactorOmniAutoClassImport) != v:true
return
endif

if !has_key(a:completedItem, "word")
return
endif

let hash = phpactor#_completionItemHash(a:completedItem)
if !has_key(g:_phpactorCompletionMeta, hash)
if !has_key(s:_phpactorCompletionMeta, hash)
return
endif

let suggestion = g:_phpactorCompletionMeta[hash]
let suggestion = s:_phpactorCompletionMeta[hash]

if !empty(get(suggestion, "class_import", ""))
call phpactor#rpc("import_class", {
Expand All @@ -106,7 +112,7 @@ function! phpactor#_completeImportClass(completedItem)
\ "path": expand('%:p')})
endif

let g:_phpactorCompletionMeta = {}
let s:_phpactorCompletionMeta = {}

endfunction

Expand Down
59 changes: 4 additions & 55 deletions ftplugin/php.vim
Original file line number Diff line number Diff line change
@@ -1,58 +1,7 @@
if exists('g:phpactorLoaded')
finish
endif

let g:phpactorLoaded = 1
let g:phpactorpath = expand('<sfile>:p:h') . '/..'
let g:phpactorbinpath = g:phpactorpath. '/bin/phpactor'
let g:phpactorInitialCwd = getcwd()
let g:phpactorCompleteLabelTruncateLength=50
let g:_phpactorCompletionMeta = {}

""
" Path to the PHP binary used by Phpactor
let g:phpactorPhpBin = get(g:, 'phpactorPhpBin', 'php')

""
" The Phpactor branch to use when calling @command(PhpactorUpdate)
let g:phpactorBranch = get(g:, 'phpactorBranch', 'master')

""
" Automatically import classes when using VIM native omni-completion
let g:phpactorOmniAutoClassImport = get(g:, 'phpactorOmniAutoClassImport', v:true)

""
" Ignore case when suggestion completion results
let g:phpactorCompletionIgnoreCase = get(g:, 'phpactorCompletionIgnoreCase', 1)

""
" Function to use when populating a list of code references. The default
" is to use the VIM quick-fix list.
let g:phpactorQuickfixStrategy = get(g:, 'phpactorQuickfixStrategy', 'phpactor#quickfix#vim')

""
" Function to use when presenting a user with a choice of options. The default
" is to use the VIM inputlist.
let g:phpactorInputListStrategy = get(g:, 'phpactorInputListStrategy', 'phpactor#input#list#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.
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', ['composer.json', '.git', '.phpactor.json', '.phpactor.yml'])

""
" 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'])

if g:phpactorOmniAutoClassImport == v:true
autocmd CompleteDone *.php call phpactor#_completeImportClass(v:completed_item)
endif
augroup PhpactorInit
autocmd! * <buffer>
autocmd CompleteDone <buffer> call phpactor#_completeImportClass(v:completed_item)
augroup END


" vim: et ts=4 sw=4 fdm=marker
52 changes: 52 additions & 0 deletions plugin/phpactor.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
if exists('g:loaded_phpactor')
Comment thread
camilledejoye marked this conversation as resolved.
Resolved
finish
endif

let g:loaded_phpactor = 1
let g:phpactorpath = expand('<sfile>:p:h') . '/..'
let g:phpactorbinpath = g:phpactorpath. '/bin/phpactor'
let g:phpactorInitialCwd = getcwd()
let g:phpactorCompleteLabelTruncateLength=50

""
" Path to the PHP binary used by Phpactor
let g:phpactorPhpBin = get(g:, 'phpactorPhpBin', 'php')

""
" The Phpactor branch to use when calling @command(PhpactorUpdate)
let g:phpactorBranch = get(g:, 'phpactorBranch', 'master')

""
" Automatically import classes when using VIM native omni-completion
let g:phpactorOmniAutoClassImport = get(g:, 'phpactorOmniAutoClassImport', v:true)

""
" Ignore case when suggestion completion results
let g:phpactorCompletionIgnoreCase = get(g:, 'phpactorCompletionIgnoreCase', 1)

""
" Function to use when populating a list of code references. The default
" is to use the VIM quick-fix list.
let g:phpactorQuickfixStrategy = get(g:, 'phpactorQuickfixStrategy', 'phpactor#quickfix#vim')

""
" Function to use when presenting a user with a choice of options. The default
" is to use the VIM inputlist.
let g:phpactorInputListStrategy = get(g:, 'phpactorInputListStrategy', 'phpactor#input#list#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.
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', ['composer.json', '.git', '.phpactor.json', '.phpactor.yml'])

""
" 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'])

" vim: et ts=4 sw=4 fdm=marker