Coder Social home page Coder Social logo

sserbin / phpcd.vim Goto Github PK

View Code? Open in Web Editor NEW

This project forked from taoso/phpcd.vim

0.0 1.0 0.0 1.99 MB

phpcd - PHP Completion Daemon for Vim/NeoVim

Home Page: https://github.com/lvht/phpcd.vim

License: Apache License 2.0

Vim Script 50.92% PHP 47.34% Python 0.81% Shell 0.94%

phpcd.vim's Introduction

phpcd - PHP Completion Daemon for Vim/NeoVim

asciicast

Introduction

PHPCD (PHP Completion Daemon) is another Vim omni complete engine for PHP.

PHPCD is based on phpcomplete.vim but is faster.

While phpcomplete.vim uses the tags file to fetch the context info, PHPCD uses PHP's Reflection mechanism to fetch the context info, and this is why PHPCD is faster. All the phpcomplete VimL code related the tags file has been droped and reimplemented.

PHPCD consists of two parts. On part is written in VimL (mainly based on phpcomplete.vim), and the other in PHP. The communication between the VimL part and the PHP part relies on NeoVim's MsgPack-RPC mechanism. This is why NeoVim is needed. Both NeoVim and Vim 7.4+ are supported now. Thanks to NoeVims's MsgPack-RPC and Vim's Channel.

Feature

  • Fast, Lightweight, Powerful
  • Correct restriction of static or standard methods based on context (show only static methods with :: and only standard with ->)
  • Real support for self::, static::, parent:: and $this-> with the aforementioned context restriction
  • Better class detection
    • Recognize /* @var $yourvar YourClass */ใ€ /* @var YourClass $yourvar */ type mark comments
    • Recognize $instance = new Class; class instantiations
    • Recognize $instance = Class::foo()->bar(); method call chain return type use bar's @return docblocks
    • Recognize $date = DateTime::createFromFormat(...) built-in class return types
    • Recognize type hinting in function prototypes
    • Recognize types in @param lines in function docblocks
    • Recognize array of objects via docblock like $foo[42]-> or for variables created in foreach
  • Displays docblock info in the preview for methods and properties
  • Support built-in class support with constants, methods and properties
  • Enhanced jump-to-definition on ctrl+]

Installation & Usage

System requirement

  1. PHP 5.3+
  2. PCNTL Extension
  3. Msgpack 0.5.7+(for NeoVim) Extension or JSON(for Vim 7.4+) Extension
  4. Composer Project

Install PHPCD

We recommend you use Vim-Plug to manage your vim plugins.

With Vim-Plug installed, put the following lines in your vimrc:

Plug 'lvht/phpcd.vim', { 'for': 'php', 'do': 'composer install' }

And then execute :PlugInstall in the command mode.

If you install phpcd manually, you need run composer install in the phpcd.vim root directory.

deoplete

If you using the deoplete, you can add the following lines to you init.vim

let g:deoplete#ignore_sources = get(g:, 'deoplete#ignore_sources', {})
let g:deoplete#ignore_sources.php = ['omni']

The phpcd will work with deoplete happily.

However if you are experiencing problems with deoplete you can disable the phpcd source.

let g:deoplete#ignore_sources = get(g:, 'deoplete#ignore_sources', {})
let g:deoplete#ignore_sources.php = ['phpcd', 'omni']

Usage

First, in the project directory, run composer install to install all the dependent packages and generate the autoload file. The composer is not required any more. However, if you want to let phpcd work with your project, you must to make a autoload file for your project.

If you use composer, composer will make the vendor/autoload.php. phpcd will use vendor/autoload.php automatically.

If your project does not use composer but have a path/to/autoload_file.php, you need to create a .phpcd.vim file in your project root path, and let it reads

let g:phpcd_autoload_path = 'path/to/autoload_file.php'

And phpcd will use the g:phpcd_autoload_path to load your class.

The default PHP command used to run PHP parts of daemon is simply php. You may override it by assigning g:phpcd_php_cli_executable another value in your vimrc, for example:

let g:phpcd_php_cli_executable = 'php7.0'

Use Ctrl+xCtrl+o to complete and use ctrl+] to go to the defination.

If you use neosnippet, you may like to set g:phpcd_disable_modifier to 0.

Good luck :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.