Skip to content

Commit 5d03cef

Browse files
author
Tom Oram
committed
First working version
1 parent bede8fa commit 5d03cef

File tree

5 files changed

+157
-41
lines changed

5 files changed

+157
-41
lines changed

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2013 Tom Oram
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
PHP Refactoring Support for VIM
2+
===============================
3+
4+
PHP Refactoring support for VIM using [php-refactorings-browser https://github.com/QafooLabs/php-refactoring-browser]
5+
6+
Installation
7+
------------
8+
9+
### Using Vundle
10+
Add `Bundle 'tomphp/vim-php-refactoring'` to your `.vimrc` file and then:
11+
* either run `:BundleInstall` within vim
12+
* or run `vim +BundleInstall +qall` from your shell
13+
14+
### Configuring
15+
16+
You also need to Download `refactor.phar` from
17+
https://github.com/QafooLabs/php-refactoring-browser and add
18+
19+
`let g:php_refactor_command='php /path/to/refactor.phar'`
20+
21+
to your `.vimrc` file.
22+
23+
Usage
24+
-----
25+
26+
When inside a PHP file the following mappings work
27+
28+
### EXTRACT METHOD
29+
Go into visual mode and select the code you want to extract to a new
30+
method the press <Leader>rem
31+
32+
You will be prompted for the name of the new method.
33+
34+
### RENAME LOCAL VARIABLE
35+
In normal mode move the cursor so it's inside the name of the variable
36+
which you want to rename. Press <Leader>rlv
37+
38+
You will be prompted for the new name of the variable.
39+
40+
### LOCAL VARIABLE TO INSTANCE VARIABLE
41+
In normal mode move the cursor so it's inside the name of the variable
42+
which you want to rename. Press <Leader>rli
43+
44+
### OPTIMIZE USE
45+
Simple press <Leader>rou to run the optimize use refactoring.

doc/phprefactor.txt

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
*phprefactor.txt* refactoring tools for PHP
2+
3+
PHP REFACTORING SUPPORT FOR VIM
4+
(requires https://github.com/QafooLabs/php-refactoring-browser)
5+
6+
================================================================================
7+
CONTENTS *PhpRefactorContents*
8+
9+
1. Setup ............................. |PhpRefactorSetup|
10+
2. Usage ............................. |PhpRefactorUsage|
11+
3. Mappings .......................... |PhpRefactorMappings|
12+
4. License ........................... |PhpRefactorLicense|
13+
5. Contributing ...................... |PhpRefactorContrib|
14+
15+
================================================================================
16+
SETUP *PhpRefactorSetup*
17+
18+
Before you can use this plugin you will need to download php-refactoring-browser
19+
from https://github.com/QafooLabs/php-refactoring-browser
20+
21+
Next you will need to put refactor.phar some where safe and add the following
22+
config to your .vimrc
23+
24+
let g:php_refactor_command='php /path/to/refactor.phar'
25+
26+
This plugin also requires the patch command so I'm not sure if it will work on
27+
Windows.
28+
29+
================================================================================
30+
USAGE *PhpRefactorUsage*
31+
32+
Once this application is installed you can simply use the |PhpRefactorMappings|
33+
mappings in PHP files to perform the various refactorings.
34+
35+
================================================================================
36+
MAPPINGS *PhpRefactorMappings*
37+
38+
- EXTRACT METHOD
39+
Go into visual mode and select the code you want to extract to a new
40+
method the press <Leader>rem
41+
42+
You will be prompted for the name of the new method.
43+
44+
- RENAME LOCAL VARIABLE
45+
In normal mode move the cursor so it's inside the name of the variable
46+
which you want to rename. Press <Leader>rlv
47+
48+
You will be prompted for the new name of the variable.
49+
50+
- LOCAL VARIABLE TO INSTANCE VARIABLE
51+
In normal mode move the cursor so it's inside the name of the variable
52+
which you want to rename. Press <Leader>rli
53+
54+
- OPTIMIZE USE
55+
Simple press <Leader>rou to run the optimize use refactoring.
56+
57+
================================================================================
58+
LICENSE *PhpRefactorLicense*
59+
60+
The MIT License (MIT)
61+
62+
Copyright (c) 2013 Tom Oram
63+
64+
Permission is hereby granted, free of charge, to any person obtaining a copy of
65+
this software and associated documentation files (the "Software"), to deal in
66+
the Software without restriction, including without limitation the rights to
67+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
68+
the Software, and to permit persons to whom the Software is furnished to do so,
69+
subject to the following conditions:
70+
71+
The above copyright notice and this permission notice shall be included in all
72+
copies or substantial portions of the Software.
73+
74+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
75+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
76+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
77+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
78+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
79+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
80+
81+
================================================================================
82+
CONTRIBUTING *PhpRefactorContrib*
83+
84+
To contribute to this plugin simply fork the GitHub repository at
85+
http://github.com/tomphp/vim-php-refactoring
86+
87+
To contribute to the refactoring engine fork the GitHub repository
88+
https://github.com/QafooLabs/php-refactoring-browser

doc/plugin.txt

Lines changed: 0 additions & 37 deletions
This file was deleted.

ftplugin/php.vim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
vnoremap <expr> <Leader>rem PhpRefactorExtractMethod()
2-
noremap <expr> <Leader>rlv PhpRefactorRenameLocalVariable()
3-
noremap <expr> <Leader>rli PhpRefactorLocalVariableToInstanceVariable()
4-
noremap <expr> <Leader>rou PhpRefactorOptimizeUse()
1+
vnoremap <buffer> <expr> <Leader>rem PhpRefactorExtractMethod()
2+
noremap <buffer> <expr> <Leader>rlv PhpRefactorRenameLocalVariable()
3+
noremap <buffer> <expr> <Leader>rli PhpRefactorLocalVariableToInstanceVariable()
4+
noremap <buffer> <expr> <Leader>rou PhpRefactorOptimizeUse()

0 commit comments

Comments
 (0)