Giter Club home page Giter Club logo

vim-php's Introduction

vim-php

An intuitive plugin to import/expand classes, traits and interfaces, finally!

2018-10-07: This repository still active, feel free to open issues or send pull request

Preview

Install

Install using your favorite plugin manager, like Vundle:

Plugin 'sahibalejandro/vim-php'

CTags

You need Universal Ctags to generate CTags for classes, traits and interfaces. Here you can find it: https://github.com/universal-ctags/ctags

Once you have installed Universal Ctags just run this command:

ctags --recurse --languages=php --php-kinds=ctif

You need at least the following kinds: cti, which corresponds to class, trait and interface.

Commands

PHPImportClass

This command will add the use Foo\Bar statement for the class/trait/interface under cursor.

PHPExpandFQCN

This command will expand the FQCN for the class/trait/interface under cursor.

PHPExpandFQCNAbsolute

This command will expand the FQCN with a leading backslash for the class/trait/interface under cursor.

Configuration

Just add this to your .vimrc file:

augroup VIM_PHP
    autocmd!
    autocmd FileType php nnoremap <Leader>u :PHPImportClass<cr>
    autocmd FileType php nnoremap <Leader>e :PHPExpandFQCNAbsolute<cr>
    autocmd FileType php nnoremap <Leader>E :PHPExpandFQCN<cr>
augroup END

Change the mappings to your needs.

Ordering use statements

By default when you import a class, all of the use statements will be sorted by length, if you want to sort them alphabetically set g:vim_php_use_sort to alpha in your .vimrc file:

let g:vim_php_use_sort='alpha'

Note that g:vim_php_use_sort='length' is the default. If you use any other value rather than length or alpha then the new use statements will be added after the last one, which means: no sorting.

vim-php's People

Contributors

sahibalejandro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

phux archoncap

vim-php's Issues

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.