Skip to content

Commit 9b233c6

Browse files
committed
fixed readme and renamed vimdoc file
1 parent a9d5f81 commit 9b233c6

12 files changed

Lines changed: 146 additions & 121 deletions

File tree

README.md

Lines changed: 58 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,88 @@
1-
phpcomplete-composer(WIP)
1+
Padawan.vim for php
22
====================
33

4-
This plugin is a fork of [phpcomplete-extended by M2mdas](https://github.com/m2mdas/phpcomplete-extended) with completely rebuilt index generation part. New index generator based on [nikic/PHP-Parser](https://github.com/nikic/PHP-Parser).
4+
Smart php intelligent code completion plugin. It tries to be
5+
a [Jedi](https://github.com/davidhalter/jedi-vim), but currently
6+
it's only a padawan.
7+
8+
This plugin is a fork of
9+
[phpcomplete-extended by M2mdas](https://github.com/m2mdas/phpcomplete-extended)
10+
with completely rewritten index generation part.
11+
New index generator based on [nikic/PHP-Parser](https://github.com/nikic/PHP-Parser).
12+
13+
Currently it's under development and does not support some of the original
14+
plugin features.
515

616
Plugin
717
======
818

9-
phpcomplete-extended is a fast, extensible, context aware autocomplete plugin
10-
for PHP composer projects. Initially it reads autoload classmap of a composer
11-
project, parses doc-comments of each class and creates index from them. After
12-
that it auto updates index as you type thanks to
19+
Padawan.vim reads autoload classmap of a composer
20+
project, parses doc-comments and functions declarations of each class and creates index
21+
from them. After that it auto updates index as you type thanks to
1322
[vimproc.vim](https://github.com/Shougo/vimproc.vim) plugin. Besides
14-
autocomplete this plugin have several code inspection features,
23+
autocomplete this plugin have several code inspection features:
1524

16-
* Includes full core PHP documentation
1725
* See documentation of current word, be it class name, method or property. It is
1826
context aware.
1927
* Go to definition of a symbol. Also context aware.
2028
* Automatically add use statement of current completed word. Also added plugin
2129
command of this action.
22-
* If [unite.vim](https://github.com/Shougo/unite.vim/) plugin installed following sources are available,
23-
* `phpcomplete/files` : Lists PHP files of the project.
24-
* `phpcomplete/vendors` : Lists vendor directories
25-
* `phpcomplete/extends` : Lists classes that extends the class guessed from
26-
the current cursor word.
27-
* `phpcomplete/implements` : Lists classes that implements the class guessed
28-
from the current cursor word.
29-
30-
Demo videos (click on the image to goto youtube)
31-
-----------------------------------------------
30+
31+
Demo videos (click on the image to goto youtube) by M2mdas
32+
----------------------------------------------------------
3233
## Autocomplete demo video:
3334

3435
[![ScreenShot](http://img.youtube.com/vi/yZYFKslqkC8/maxresdefault.jpg)](http://www.youtube.com/watch?v=yZYFKslqkC8)
3536

36-
## Unite sources demo video:
37-
38-
[![ScreenShot](http://i1.ytimg.com/vi/Wd5G7QA3OFw/maxresdefault.jpg)](http://www.youtube.com/watch?v=Wd5G7QA3OFw)
3937

4038
Installation
4139
-------------
4240

43-
The plugin depends on following plugins,
41+
The plugin depends on following plugins:
4442

43+
* php 5.4+
4544
* [vimproc.vim](https://github.com/Shougo/vimproc.vim) : Asynchronous library for vim. Required for auto-update index. C
4645
compiler is needed to build the plugiin. For windows install cygwin or
4746
msys to get the compiler.
48-
* [unite.vim](https://github.com/Shougo/unite.vim/): Optional, but enables some good features.
4947

5048
Plugin managers are recommended for installing these plugins. Installation instructions for
5149
various plugin managers are given bellow.
5250

5351
## Pathogen
54-
52+
53+
You should manually install vimproc.vim!
5554
Issue following commands.
5655

5756
```sh
58-
git clone https://github.com/Shougo/vimproc.vim.git ~/.vim/bundle/vimproc.vim
59-
cd ~/.vim/bundle/vimproc.vim
60-
make
61-
cd ..
62-
git clone https://github.com/Shougo/unite.vim.git ~/.vim/bundle/unit.vim
63-
git clone https://github.com/m2mdas/phpcomplete-extended.git ~/.vim/bundle/phpcomplete-extended
57+
git clone https://github.com/mkusher/padawan.vim ~/.vim/bundle/padawan.vim
6458
```
6559

6660
## NeoBundle (preferred)
61+
62+
You should manually install vimproc.vim!
6763
Put these lines in `.vimrc` and issue `source %` command
6864

6965
```vim
70-
NeoBundle 'Shougo/vimproc', {
71-
\ 'build' : {
72-
\ 'windows' : 'make -f make_mingw32.mak',
73-
\ 'cygwin' : 'make -f make_cygwin.mak',
74-
\ 'mac' : 'make -f make_mac.mak',
75-
\ 'unix' : 'make -f make_unix.mak',
76-
\ },
77-
\ }
78-
NeoBundle 'Shougo/unite.vim'
79-
NeoBundle 'm2mdas/phpcomplete-extended'
66+
NeoBundle 'mkusher/padawan.vim', { 'build': {'unix': 'php /path/to/composer.phar install'} }
8067
"your other plugins
8168
NeoBundleCheck
8269
```
8370

84-
If C compiler found for respective environment, `neobundle` will automatically
85-
compile the library.
71+
You should have composer.phar installed.
8672

8773
## Vundle
8874

75+
You should manually install vimproc.vim!
8976
Put following lines in `.vimrc` and issue `:BundleInstall` command.
9077
```vim
91-
Bundle 'Shougo/vimproc'
92-
Bundle 'Shougo/unite.vim'
93-
Bundle 'm2mdas/phpcomplete-extended'
78+
Bundle 'mkusher/padawan.vim'
9479
"your other plugins
9580
"....
9681
```
9782

98-
After installation goto `vimproc` folder and issue `make` command from command
99-
line. C compiler must be installed.
83+
After installation goto `padawan.vim` folder and run
84+
`php /path/to/composer.phar install` command from command
85+
line. You should have composer installed.
10086

10187
Walk through of the plugin
10288
-------------------------
@@ -115,7 +101,8 @@ composer.phar dumpautoload --optimize` command. By default composer command is
115101
set to `php composer.phar`. The command can be changed by setting
116102
`g:phpcomplete_index_composer_command` global variable.
117103

118-
The plugin is dependent on `@var`, `@param`, `@return` doc-comments to give proper context aware
104+
The plugin is dependent on `@var`, `@param`, `@return` doc-comments and class
105+
declarations to give proper context aware
119106
autocomplete. So documenting your class will help tremendously. It does not
120107
analyse full class. Just parses the variable declaration to get the relevant
121108
tokens. Does not provide autocomplete suggestion if there is error in code.
@@ -147,20 +134,31 @@ Minimal configuration for supertab support,
147134
## [YouCompleteMe](https://github.com/Valloric/YouCompleteMe)
148135

149136
If `omnifunc` set the omni completer of `YouCompleteMe` should get the completion
150-
candidates. I haven't tested it though.
137+
candidates. You should check semantic trigers for php.
138+
139+
Why not original plugin
140+
-----------------------
151141

152-
Extensions
153-
---------
142+
The M2mdas's plugin is pretty good, but have some core bugs due to
143+
self-written parser:
154144

155-
Phpcomplete Extended pluign exposes api hooks so that it can be possible to
156-
provide framework specific autocomplete suggestion. For example facades in
157-
laravel, DIC services in Symfony2 etc. The plugin api divided in two part, `PHP`
158-
and `vim`. PHP part is responsible for creating index related to the framework,
159-
and vim part is responsible for providing autocomplete menu entries based on the
160-
index. For reference see
161-
[phpcomplete-extended-symfony](https://github.com/m2mdas/phpcomplete-extended-symfony)
162-
and
163-
[phpcomplete-extended-laravlel](https://github.com/m2mdas/phpcomplete-extended-laravel) plugins.
145+
* It does not support files with 2 or more classes in it
146+
* It fails on parsing RabbitMQ classes
147+
148+
So, I decided to rewrite index generation part.
149+
150+
Roadmap
151+
-------
152+
153+
As of now this plugin sucks, but I'm working hard on it and these features are
154+
now in progress:
155+
156+
* Fix bugs with symbol type detection
157+
* Fix plugin user interface
158+
* Add doc-comment parsing
159+
* Add class inheritance indexing
160+
* Add plugins support
161+
* Add symfony2 plugin
164162

165163
License
166164
-------
@@ -175,4 +173,3 @@ This plugin would not be possible without the works of
175173
[shawncplus](https://github.com/shawncplus/),
176174
[tpope](https://github.com/tpope/), [vim-jp](https://github.com/vim-jp),
177175
[thinca](https://github.com/thinca) and many others.
178-

autoload/phpcomplete_extended.vim

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ function! s:getFQCNFromTokens(parsedTokens, currentFQCN, isThis) "{{{
334334

335335
let isPrevTokenArray = 0
336336

337-
if currentFQCN =~ '\[\]$' && len(parsedTokens)
337+
if currentFQCN =~ '\[\]$' && len(parsedTokens)
338338
\ && has_key(parsedTokens[0], 'isArrayElement')
339339
let currentFQCN = matchstr(currentFQCN, '\zs.*\ze\[\]$')
340340
let isPrevTokenArray = 1
@@ -345,16 +345,16 @@ function! s:getFQCNFromTokens(parsedTokens, currentFQCN, isThis) "{{{
345345
let insideBraceText = token['insideBraceText']
346346
let isArrayElement = has_key(token, 'isArrayElement')? 1 :0
347347
let currentClassData = phpcomplete_extended#getClassData(currentFQCN)
348-
348+
349349
let pluginFQCN = s:get_plugin_fqcn(currentFQCN,token)
350350

351351
if insideBraceText[0] == "("
352352
let currentFQCN = ""
353353
elseif pluginFQCN != ""
354354
let currentFQCN = pluginFQCN
355-
elseif isArrayElement
355+
elseif isArrayElement
356356
let isPrevTokenArray = 0
357-
if phpcomplete_extended#isClassOfType(currentFQCN, 'ArrayAccess')
357+
if phpcomplete_extended#isClassOfType(currentFQCN, 'ArrayAccess')
358358
\ && has_key(currentClassData['methods']['all'], 'offsetGet')
359359
let offsetType = currentClassData['methods']['all']['offsetGet']['return']
360360
if empty(offsetType)
@@ -854,7 +854,7 @@ function! phpcomplete_extended#parsereverse(cursorLine, cursorLineNumber) "{{{
854854
let parsedTokens = phpcomplete_extended#parser#reverseParse(cursorLine, [])
855855

856856

857-
if empty(parsedTokens)
857+
if empty(parsedTokens)
858858
\ || (len(parsedTokens) && has_key(parsedTokens[0], 'start') && parsedTokens[0].start == 0)
859859
let linesTillFunc = s:getLinesTilFunc(a:cursorLineNumber)
860860
let joinedLines = join(reverse(linesTillFunc),"")
@@ -1199,7 +1199,7 @@ function! s:setClassData(fqcn, file, classData) "{{{
11991199
endfunction "}}}
12001200

12011201
function! s:makeCacheDir() "{{{
1202-
let cache_dir = phpcomplete_extended#util#substitute_path_separator(fnamemodify(getcwd(), ':p:h').'/.phpcomplete_extended')
1202+
let cache_dir = phpcomplete_extended#util#substitute_path_separator(fnamemodify(getcwd(), ':p:h').'/.padawan.vim')
12031203
if !isdirectory(cache_dir)
12041204
call mkdir(cache_dir)
12051205
endif
@@ -1210,7 +1210,7 @@ function! phpcomplete_extended#saveIndexCache() " {{{
12101210
return
12111211
endif
12121212

1213-
let cache_dir = phpcomplete_extended#util#substitute_path_separator(fnamemodify(getcwd(), ':p:h').'/.phpcomplete_extended')
1213+
let cache_dir = phpcomplete_extended#util#substitute_path_separator(fnamemodify(getcwd(), ':p:h').'/.padawan.vim')
12141214
let index_cache_file = phpcomplete_extended#util#substitute_path_separator(fnamemodify(cache_dir, ':p:h')."/index_cache")
12151215
let content = []
12161216
if exists('g:phpcomplete_index_cache')
@@ -1224,7 +1224,7 @@ function! s:getCacheFile() " {{{
12241224
if !phpcomplete_extended#is_phpcomplete_extended_project()
12251225
return
12261226
endif
1227-
let index_cache_file = phpcomplete_extended#util#substitute_path_separator(fnamemodify(getcwd(), ':p:h')."/.phpcomplete_extended/index_cache")
1227+
let index_cache_file = phpcomplete_extended#util#substitute_path_separator(fnamemodify(getcwd(), ':p:h')."/.padawan.vim/index_cache")
12281228
return index_cache_file
12291229
endfunction
12301230
" }}}
@@ -1277,20 +1277,9 @@ function! s:loadIndex() " {{{
12771277
return
12781278
endif
12791279

1280-
let index_file = phpcomplete_extended#util#substitute_path_separator(getcwd().'/.phpcomplete_extended/phpcomplete_index')
1280+
let index_file = phpcomplete_extended#util#substitute_path_separator(getcwd().'/.padawan.vim/phpcomplete_index')
12811281
let plugin_index_file = s:getPluginIndexFileName()
12821282

1283-
if !filereadable(index_file)
1284-
let initial_message = "Composer project detected, Do you want to create index?"
1285-
let ret = phpcomplete_extended#util#input_yesno(initial_message)
1286-
if !ret
1287-
call add(s:disabled_projects, getcwd())
1288-
return
1289-
endif
1290-
echo "\n\n"
1291-
call phpcomplete_extended#generateIndex()
1292-
endif
1293-
12941283
if !g:phpcomplete_index_loaded
12951284
call phpcomplete_extended#util#print_message("Loading Index")
12961285
if filereadable(plugin_index_file)
@@ -1393,7 +1382,7 @@ endfunction
13931382

13941383
function! s:copyCoreIndex() "{{{
13951384
let src = phpcomplete_extended#util#substitute_path_separator(g:phpcomplete_extended_root_dir . "/bin/core_index")
1396-
let cache_dir = phpcomplete_extended#util#substitute_path_separator(fnamemodify(getcwd(), ':p:h').'/.phpcomplete_extended')
1385+
let cache_dir = phpcomplete_extended#util#substitute_path_separator(fnamemodify(getcwd(), ':p:h').'/.padawan.vim')
13971386
let dest = phpcomplete_extended#util#substitute_path_separator(cache_dir. "/core_index")
13981387
if empty(findfile(dest, cache_dir))
13991388
call phpcomplete_extended#util#copy(src, dest)
@@ -1404,7 +1393,7 @@ function! phpcomplete_extended#loadCoreIndex() "{{{
14041393
if exists('g:core_index_loaded') && g:core_index_loaded
14051394
return
14061395
endif
1407-
let cache_dir = phpcomplete_extended#util#substitute_path_separator(fnamemodify(getcwd(), ':p:h').'/.phpcomplete_extended')
1396+
let cache_dir = phpcomplete_extended#util#substitute_path_separator(fnamemodify(getcwd(), ':p:h').'/.padawan.vim')
14081397
let location = phpcomplete_extended#util#substitute_path_separator(cache_dir. "/core_index")
14091398

14101399
if !filereadable(location)
@@ -1502,12 +1491,12 @@ function! phpcomplete_extended#checkUpdates() "{{{
15021491
let s:update_info = {}
15031492
return
15041493
endif
1505-
let update_file = phpcomplete_extended#util#substitute_path_separator(fnamemodify(getcwd(), ':p:h').'/.phpcomplete_extended/'.s:update_info['update_file_name'])
1494+
let update_file = phpcomplete_extended#util#substitute_path_separator(fnamemodify(getcwd(), ':p:h').'/.padawan.vim/'.s:update_info['update_file_name'])
15061495

15071496
if filereadable(update_file)
15081497
try
15091498
let updateData = s:readIndex(update_file)
1510-
catch
1499+
catch
15111500
echoerr "Error occured while reading update index"
15121501
return
15131502
endtry
@@ -1533,7 +1522,7 @@ function! phpcomplete_extended#checkUpdates() "{{{
15331522
endfunction "}}}
15341523

15351524
function! s:getPluginIndexFileName() "{{{
1536-
return phpcomplete_extended#util#substitute_path_separator(fnamemodify(getcwd(), ':p:h').'/.phpcomplete_extended/plugin_index')
1525+
return phpcomplete_extended#util#substitute_path_separator(fnamemodify(getcwd(), ':p:h').'/.padawan.vim/plugin_index')
15371526
endfunction "}}}
15381527

15391528
function! s:readIndex(filename) "{{{
@@ -1664,7 +1653,7 @@ endfunction
16641653
"}}}
16651654

16661655
function! s:register_plugins() "{{{
1667-
let list = split(globpath(&runtimepath, 'autoload/phpcomplete_extended/*.vim'), "\n")
1656+
let list = split(globpath(&runtimepath, 'autoload/padawan/*.vim'), "\n")
16681657
let s:plugins = {}
16691658
let s:plugin_php_files = []
16701659
for script_file in list

bin/src/Command/AbstractCommand.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
namespace Command;
44

5+
use DI\Container;
6+
57
abstract class AbstractCommand implements CommandInterface{
68
protected $container;
79
public function __construct(){
8-
$this->container = new \DI\Container();
10+
$this->container = new Container();
11+
$a = new Container;
912
}
1013
public function get($serviceName){
1114
return $this->container->get($serviceName);

bin/src/Command/GenerateCommand.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,11 @@ public function run(array $arguments = []){
1010
$generator = $this->get("IndexGenerator");
1111

1212
$index = $generator->generateIndex($this->get("Index"));
13-
$index = $this->prepareIndex($index);
1413
$indexWriter = $this->get('IndexWriter');
1514

1615
$indexWriter->writeIndex($index);
1716
//$indexWriter->writeReport($generator->getInvalidClasses());
1817
}
19-
protected function prepareIndex($index){
20-
$jsonIndex = json_encode($index->toArray());
21-
$lastJsonError = json_last_error();
22-
if($lastJsonError != JSON_ERROR_NONE) {
23-
$this->printJsonError($lastJsonError);
24-
exit;
25-
}
26-
return $jsonIndex;
27-
}
2818
protected function printJsonError($errorCode)
2919
{
3020
switch (json_last_error()) {

bin/src/Entity/Index.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ public function setNamespaces(array $namespaces){
2222
$this->namespaces = $namespaces;
2323
}
2424
public function addNamespace($namespace){
25-
if(!in_array($namespace, $this->namespaces))
26-
$this->namespaces[] = $namespace;
25+
$this->namespaces[$namespace] = $namespace;
2726
}
2827

2928
public function getInterfaces(){

0 commit comments

Comments
 (0)