dsawardekar / wordpress.vim

Vim Plugin for WordPress Development

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WordPress.vim

Vim Plugin for WordPress Development

Features

  • Auto-Completion for the WordPress API
  • WordPress Hooks Integration
  • WP-CLI Integration
  • Jump to Definition in WordPress Core
  • UltiSnips Snippets
  • Syntax Highlighting for WordPress PHP files.
  • Markdown Syntax Highlighting for readme.txt
  • PHPCS Syntax Checker integrated with WordPress Coding Standards
  • Search in Codex
  • Integration with WpSeek API.
  • Readme.txt Auto Validation.

Auto-Completion

WordPress.vim extends phpcomplete.vim to provide Auto-Completions for WordPress PHP files. If you have phpcomplete.vim installed no additional configuration is required.

The demo below shows Auto-Completion of the WP_Query class and other API functions.

Auto Completion

See :h wordpress-auto-completion for more.

WordPress Hooks Integration

WordPress.vim has close integration with the WordPress action and filter hooks. This feature uses ctags and is further enhanced with the presence of CtrlP.vim.

The demo below shows navigation to a few hooks with the ex commands :Waction and :Wfilter and their CtrlP variants, :CtrlPaction and :CtrlPfilter.

WordPress Hooks Integration

See :h wordpress-hooks-integration for more.

WP-CLI Integration

WordPress.vim is closely integrated with WP-CLI. You can easily run WP-CLI commands without leaving Vim. It maps the wp {command} to Vim's Ex commands of the form :W{command}.

The demo below shows :Wscaffold plugin in action. Also seen are the :Weval and :Wplugin commands.

WP-CLI Plugin Scaffold

See :h wordpress-wp-cli for more.

Jump to Definition in Core

Jump to Core takes you to the implementation of a function in Core. You can easily move around the code base and return once you've figured out what you need.

The demo below starts out in a theme then jumps to different Core functions and finally returns back to the starting point.

Jump To Core

See :h wordpress-jump-to-core for more.

UltiSnips Snippets

WordPress.vim comes with a few useful snippets to speed up common WordPress development tasks. Snippets require the UltiSnips snippets engine plugin to be installed.

A Snippet is like an interactive Web Form. Once you enter a Snippet you are put at the first placeholder. As you start typing the placeholder changes and also affects any dependent placeholders. You can cycle back and forth between placeholders and Escape out when done.

The demo below shows the theme header snippet in action.

themeheader snippet

See :h wordpress-snippets for more.

Syntax Highlighting

WordPress.vim extends the default PHP syntax highlighting with support for the WordPress API. Importantly it highlights the use of any deprecated function as Errors.

Note the highlighting of the deprecated is_taxonomy function.

Deprecate is_taxonomy

Additionally the readme.txt found in WordPress files is highlighted as Markdown.

See :h wordpress-syntax-highlighting for more.

Search in Codex

The :Wcodexsearch Ex command provides searching for keywords on the Codex. When arguments are omitted it uses the current Visual selection or the word under the cursor to query for.

For faster searches, You can map this to a key sequence like, <leader>co with,

:nnoremap <leader>co :Wcodexsearch<CR>

WpSeek.com Integration

WordPress.vim integrates with the WpSeek API. This allows searching using the wpseek api directly from within Vim.

The demo below shows the :Wsimilar Ex command in action.

Wsimilar demo

see :h wordpress-wpseek-integration for more.

Getting Started

The repository includes a minimal Vimrc for trying out WordPress.vim without affecting your existing Vim configuration. Plugin management is done with Vundle.

First backup your existing vimrc.

$ mv ~/.vimrc ~/.vimrc_backup

Then download the minimal vimrc to a temporary directory like /tmp/wordpress_vim.

$ mkdir -p /tmp/wordpress_vim
$ wget -O /tmp/wordpress_vim/vimrc https://raw.githubusercontent.com/dsawardekar/wordpress.vim/develop/examples/minimal_vimrc.vim

Link the tmp vimrc to your $HOME vimrc.

$ ln -s /tmp/wordpress_vim/vimrc ~/.vimrc

Now start Vim.

The first time the vimrc will download Vundle to the /tmp/wordpress_vim directory and then proceed to install the required plugins using Vundle. Plugins will be installed in the subdirectory /tmp/wordpress_vim/bundle.

Installation may take a few minutes. Once completed you will have a custom vim configuration separate from your existing one.

To move to your old configuration simply link your backup vimrc back to the $HOME vimrc.

Installation

1. With Vundle

Plugin 'dsawardekar/wordpress.vim'

2. With NeoBundle

NeoBundle 'dsawardekar/wordpress.vim'

3. With Pathogen

git clone https://github.com/dsawardekar/wordpress.vim ~/.vim/bundle/wordpress.vim

System Requirements

WordPress.vim requires Vim 7.3p97+ with Python support.

WordPress.vim uses Progressive Enhancement to enable/disable features. This means that the features that depend on other plugins/external tools are only enabled if their presence is detected. A missing requirement will not affect the behaviour of the rest of the plugin.

It is highly recommended to install the following plugins to get the best experience.

Additionally the following tools enhance WordPress.vim.

  • WP-CLI - Enables :W ex commands & automatic WordPress path lookup.
  • Exuberant CTags - Enables the Jump to Core Definition feature

To install ctags,

  • On Ubuntu, use apt-get install exuberant-ctags
  • On Mac, use brew install ctags

Thanks

WordPress.vim builds on top a number of other excellent Projects. Many Thanks in particular to,

  • Shawn Biddle - for phpcomplete.vim
  • Cristi Burcă - for WP-CLI
  • Luke Gruber - for Riml
  • Oliver Schlöbe - for the WpSeek API
  • Sudar Muthu - for the Syntastic Integration.

Contributing

WordPress.vim needs the help of the WordPress community to keep improving. Please consider joining this effort by providing new snippets, new features or bug reports.

If you find that a feature is missing or find a bug, please contact me or and add an issue to the issues tracker.

For further details on setting up a development environment for WordPress.vim and the implementation of the plugin see CONTRIBUTING.md.

TODO

  • WordPress Hook Integration DONE
  • Find current word in Codex DONE
  • Highlight Constants DONE
  • Improve snippets
  • Integrate with the wpseek.com API DONE
  • Improve Javascript Support
  • Figure out how to run WP-CLI shell commands. DONE
  • WPSE integration.

License

MIT License. Copyright © 2014 Darshan Sawardekar.

About

Vim Plugin for WordPress Development

License:MIT License


Languages

Language:Vim Script 86.2%Language:Ruby 12.6%Language:Python 0.9%Language:HTML 0.2%Language:PHP 0.0%Language:CSS 0.0%