All Projects → joonty → Vim Phpqa

joonty / Vim Phpqa

Licence: mit
PHP QA tools for Vim

Labels

Projects that are alternatives of or similar to Vim Phpqa

Spf13 Vim
The ultimate vim distribution
Stars: ✭ 15,235 (+5046.96%)
Mutual labels:  viml
Vim Tomorrow Theme
Tomorrow Theme for Vim
Stars: ✭ 269 (-9.12%)
Mutual labels:  viml
Vim Stylus
Syntax Highlighting for Stylus
Stars: ✭ 277 (-6.42%)
Mutual labels:  viml
Vim Railscasts Theme
A vim color scheme based on the Railscasts Textmate theme.
Stars: ✭ 257 (-13.18%)
Mutual labels:  viml
Vim Language Server
VImScript language server, LSP for vim script
Stars: ✭ 264 (-10.81%)
Mutual labels:  viml
A.vim
Alternate Files quickly (.c --> .h etc)
Stars: ✭ 272 (-8.11%)
Mutual labels:  viml
Color Schemes
Color schemes I've used for an extended period of time and like
Stars: ✭ 244 (-17.57%)
Mutual labels:  viml
Rust.vim
Vim support for Rust file detection and syntax highlighting.
Stars: ✭ 288 (-2.7%)
Mutual labels:  viml
Jshint2.vim
Lightweight, customizable and functional Vim plugin for JSHint integration.
Stars: ✭ 265 (-10.47%)
Mutual labels:  viml
Vim Powerline
Moved to powerline/powerline.
Stars: ✭ 2,880 (+872.97%)
Mutual labels:  viml
File Line
Plugin for vim to enabling opening a file in a given line
Stars: ✭ 260 (-12.16%)
Mutual labels:  viml
Vim Smooth Scroll
Make scrolling in Vim more pleasant
Stars: ✭ 262 (-11.49%)
Mutual labels:  viml
Dotfiles
twerth
Stars: ✭ 274 (-7.43%)
Mutual labels:  viml
Piv
PHP Integration environment for Vim
Stars: ✭ 255 (-13.85%)
Mutual labels:  viml
Investigate.vim
A Vim plugin for looking up documentation
Stars: ✭ 282 (-4.73%)
Mutual labels:  viml
Fuzzyfinder
buffer/file/command/tag/etc explorer with fuzzy matching
Stars: ✭ 252 (-14.86%)
Mutual labels:  viml
Vim Hemisu
A Vim color scheme with dark and light variants
Stars: ✭ 271 (-8.45%)
Mutual labels:  viml
Blamer.nvim
A git blame plugin for neovim inspired by VS Code's GitLens plugin
Stars: ✭ 283 (-4.39%)
Mutual labels:  viml
Elm.vim
Vim plugin for the Elm programming language
Stars: ✭ 286 (-3.38%)
Mutual labels:  viml
Dotfiles
My config files
Stars: ✭ 276 (-6.76%)
Mutual labels:  viml

PHP QA Tools For Vim

This is a plugin for Vim that integrates PHP quality checking tools, to allow you to code to a particular standard and easily spot errors and violations.

It uses PHP linter to check for syntax errors, and integrates with PHP Code Sniffer and PHP Mess Detector to check for coding standard violations, and shows code coverage from clover XML files.

Quick Guide

The plugin is configured by default to automatically run the QA tools when a PHP file is saved. Therefore, save a file and the linter will run. If there is a syntax error, the offending line will be highlighted. Plus, a quickfix window opens to show the error and it's position in the file.

If there are no syntax errors, PHP Code Sniffer and Mess Detector will run. These will require some configuration to fit your needs, which you can read about under the "Configuration" heading. The output of these two commands are combined, and the file is highlighted with the occurences. Again, a quickfix window opens, showing the violations and allowing you to navigate through them.

You can toggle markers with the following commands (in command mode):

<Leader>qa	" Show/hide code sniffer and mess detector violations
<Leader>qc	" Show/hide code coverage markers

What's the <Leader> key? It's likely to be either \ or ,, but you can set it from the command line or in your .vimrc file using:

let mapleader="@"

or whatever you want it to be.

You can also run each command separately on demand:

  • :Php - check for syntax errors
  • :Phpcs - run code sniffer
  • :Phpmd - run mess detector (will ask for a rule XML file if not set)
  • :Phpcc - show code coverage (will ask for a clover XML file if not set)

Code Coverage

If you generate clover code coverage reports with your tests, you can toggle markers to show which lines are covered and which aren't. You can run the command once using Phpcc as shown above, or you can configure it to load the markers every time you open a new file - see the configuration section for more information.

You can also toggle code coverage (to stop it automatically running on opening a file) with:

<Leader>qc

Installation

Installation is easy-peasy if you're using Vundle. Just add this to your .vimrc file:

Bundle 'joonty/vim-phpqa.git'

and run vim +BundleInstall +qall from a terminal.

If you aren't using vundle, you will have to extract the files in each folder to the correct folder in .vim/.

Note: your Vim installation must be compiled with signs for this plugin to work. If you want to use code coverage support you will need to have Vim compiled with Python.

Configuration

Each command has it's own configuration settings, which allow you to get the functionality you want.

PHP, Mess Detector and Codesniffer

PHP mess detector needs a ruleset XML file (see the mess detector website for more information) to run, which you will be prompted for the first time the command runs. However, it's much easier to just specify it in your .vimrc file:

let g:phpqa_messdetector_ruleset = "/path/to/phpmd.xml"

For PHP code sniffer, you can pass arguments to the command line binary (run phpcs --help to see a list). For example:

" Set the codesniffer args
let g:phpqa_codesniffer_args = "--standard=Zend"

However, don't set the --report= argument, as it won't work!

For all the commands, you can override the executable:

" PHP executable (default = "php")
let g:phpqa_php_cmd='/path/to/php'

" PHP Code Sniffer binary (default = "phpcs")
let g:phpqa_codesniffer_cmd='/path/to/phpcs'

" PHP Mess Detector binary (default = "phpmd")
let g:phpqa_messdetector_cmd='/path/to/phpmd'

However, you don't need to do this if the commands php, phpcs and phpmd are can be found in your $PATH environment variable.

And you can stop them running automatically:

" Don't run messdetector on save (default = 1)
let g:phpqa_messdetector_autorun = 0

" Don't run codesniffer on save (default = 1)
let g:phpqa_codesniffer_autorun = 0

" Show code coverage on load (default = 0)
let g:phpqa_codecoverage_autorun = 1

By default, the location list window will open when mess detector/codesniffer violations are found. You can stop this happening by setting this option:

" Stop the location list opening automatically
let g:phpqa_open_loc = 0

Code Coverage Configuration

For code coverage, you can specify a clover XML file to stop the prompt appearing each time, and choose to only show markers for lines that aren't covered - by default both covered and uncovered code have markers. Not showing covered line markers is likely to speed things up noticeably when moving between files.

" Clover code coverage XML file
let g:phpqa_codecoverage_file = "/path/to/clover.xml"
" Show markers for lines that ARE covered by tests (default = 1)
let g:phpqa_codecoverage_showcovered = 0

Acknowlegements

This plugin originally reused and modified a lot of the code from the Vim QuickHigh plugin, written by Brian Medley. Although this plugin no longer uses any of that code, my thanks goes to Brian for the work that's gone into that script.

License

This plugin is released under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].