-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request : integrate phpactor #451
Comments
Whoa nice find! |
@kermorgant Thanks for suggestion. |
ok, I found the page in http://phpactor.github.io/phpactor/ |
This looks like a great tool. Thank you for bringing it to the attention of people like myself who were completely unaware of it.
If you do not have the time, that is completely understandable. However, if you could feasibly set aside any small amount of time, then I personally believe the task of adding support for Phpactor could be an educational way to learn:
I always try to avoid speaking for other people, but I feel very confident in saying that @zonuexe would be happy to have you (or anyone else like @MarTango) contribute work for integrating Phpactor, even if you cannot fully complete the work yourself. Do not hesitate to submit your best effort on that task, even if it's incomplete or buggy. As I have said elsewhere, I am no longer an active contributor to PHP Mode; but lately I've begun to look over the project for about thirty to ninety minutes each weekend. I would be happy to use that time on weekends to review any code you submit for this feature, providing appropriate feedback to help you learn more about Emacs Lisp programming. My two cents: I agree with @MarTango that supporting Phpactor should be in a new package, at least temporarily; after it reaches an appropriate level of maturity---as the lead maintainer you are obviously to person to decide whenever Phpactor support reaches that level---then it may be worth including directly into PHP Mode itself. Not necessarily within |
As I was working on PHPStan and Flycheck work this week I have not decided on the interface with Phpactor yet, but I am reading Vim script and thinking about it gradually. |
I looked over the Vim script too. Some random thoughts:
|
By a happy coincidence, I decided to take a try last night and wrote my first emacs functions for class:copy and class:move. (defun php-class-copy ()
"Copy a class using phpactor"
(interactive)
(setq targetpath (read-file-name "Enter new file name:"))
(let ((default-directory (projectile-project-root)))
(start-process "phpactor"
(get-buffer-create "*phpactor*")
"phpactor"
"class:copy"
(buffer-file-name (window-buffer (minibuffer-selected-window)))
targetpath
)
)
)
(defun php-class-move ()
"Rename a class using phpactor"
(interactive)
(setq targetpath (read-file-name "Enter new file name:"))
(let ((default-directory (projectile-project-root)))
(start-process "phpactor"
(get-buffer-create "*phpactor*")
"phpactor"
"class:move"
(buffer-file-name (window-buffer (minibuffer-selected-window)))
targetpath
)
)
) They work when you call them for the currently openened buffer. Worked fine for me, but it assumes you have projectile and phpactor in the PATH. I'm not so happy with the phpactor buffer collectling logs without showing them I wonder if there are emacs core functions for copy and move that could be overridden so that dired, ranger or whatever would rely on them for php files. That was the way I imagined it first. |
@ejmr and thank you for your proposition of reviewing code if I could propose something. I can't promise anything as I could at best gather some limited time during weekends. On the other hand, if there is an "emacs area" that I could see myself working on, this is definitly the one. |
I'm considering attempting to translate the vimscript functions into emacs-lisp, as an exercise for myself to learn emacs-lisp. I don't have any experience writing emacs packages though, so I'm not sure about structure. (Also, I don't know vimscript, but from what I've seen it looks fairly easy to understand) |
Thanks for taking the initiave. Sometime during the week, if I can, I will write some notes about the code with some suggestions and friendly criticisms. This is a great reference for Vimscript in my opinion, which may be helpful for any attempt to port Phpactor's Vim support to Emacs Lisp. |
I started making |
@zonuexe Amazing! I may attempt to contribute, but my emacs-lisp ability is subpar. I have a question about some of the code which I don't understand (I tried googling but couldn't find an answer): ;;;###autoload
(progn
(defvar phpactor-executable nil
"Path to `phpactor' executable file.")
(make-variable-buffer-local 'phpactor-working-dir)
#'(lambda (v) (if (consp v)
(and (eq 'root (car v)) (stringp (cdr v)))
(null v) (stringp v))))
Sorry if this was the wrong place to post, I'm not sure if questions like this are supposed to be new issues, or private messages, or something else. Thanks! |
The magic comment creates an appropriate |
I believe questions such as the ones by @MarTango belong in the discussion for the relevant issues or pull-requests, to help educate and improve the skills of people contributing to PHP Mode or who are thinking about contributing. But if you believe it would create too much noise then I would have no issue with you moving these conversations elsewhere. Just my two cents opinion. |
emacs-php/php-mode#451 (comment) Co-authored-by: Martin Tang @MarTango
emacs-php/php-mode#451 (comment) Co-authored-by: Martin Tang @MarTango
@MarTango Thanks for your comments.
It is as the comment of @ejmr. This variable is accompanied by
This is just typo. Thanks to that point, I was fixed at emacs-php/phpactor.el@64a12da .
This is wrong code, too. I was fixed at emacs-php/phpactor.el@55dede0 . This is also a safe-local-variable checker, but I was in a hurry yesterday night, so I did not notice that this was not an accurate formula. The original code does not affect anything, it is not a special expression for autoload. |
@ejmr #451 (comment) I think so, too. @MarTango |
What are the advantages/disadvantages of phpactor over php-language-server? I'm under the impression that php-language-server has a higher memory footprint, but I'm not sure if that's true. |
👋 hi, I'm the maintainer of Phpactor
PHP language server, is a server - last time I checked it sits there and builds up an in-memory index of all your PHP files in real-time (using co-routines so it can still serve requests). Phpactor is not a server, it spins up for each request. Language server should have a larger memory footprint and a warm-up period but will be a bit more comprehensive when locating classes and function. When used with composer, Phpactor will be blind to multiple class declarations in the same file. For a simple completion request it has a memory usage of around 11MB. Currently Phpactor is only aware of the in-built PHP functions, but hopefully support for user functions will come soon. PHP Language Server implements the Language Server protocol, Phpactor implements it's own RPC protocol (LSP support might be added in the future). Phpactor also has many other features outside of completion and jumping to definitions, which you could use alongside the PHP Language Server if you wanted. Other than that, I havn't really used the PHP Language Server, so can't comment more on it, but looks like a great project. |
Thank you, first for creating Phpactor, and second for the information you've provided. It is my understanding that you are the principle (sole?) author of Phpactor's Vim plugin; is that correct? If so, could you please describe any challenges involved in creating the plugin, along with any limitations you may have found? I believe any such information would be greatly useful to the developers here who want to make Phpactor easy to use for programmers using GNU Emacs. Thank you in advanced for any insight you can share. |
The plugin itself is pretty straight-forward, most of the complication is in dispatching the RPC response to actions (e.g. Some things that might be relevant:
This functionality is provided by VIMs
VIM has the concept of a "quick fix" list which can be populated with file paths and locations, when you search for references in Phpactor (through the plugins
Phpactor has an "extract method" feature, which operates on a selection of code, but currently the context menu doesn't handle selections, so it must be mapped to a shortcut and executed explicitly. This is really a problem that could be solved in Phpactor, but it's different from the normal context menu which operates an an offset rather than a selection. Those are the things I can think of now, feel free to ask any questions :) |
Hi,
I've very recently discovered the phpactor tool (completion and refactoring tool) : http://phpactor.github.io/phpactor/ (edit)
There are probably several interesting features that could be used, but looking for non overlapping ones, I'd love to have "class move" and "class copy" with automatic update of namespace (and name if copy).
But maybe this has more to do with dired that php-mode ?
Sadly, I lack both the elisp knowledge and time to figure that out by myself...
Regards and thanks for all the work here !
Mikael
The text was updated successfully, but these errors were encountered: