-
Notifications
You must be signed in to change notification settings - Fork 12
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
Auto import class after completion #34
Conversation
@zonuexe I saw the following comment in the code about restoring position. Could you please share the link to the gofmt implementation ? |
|
@ejmr |
company-phpactor.el
Outdated
|
||
(defun company-phpactor--post-completion (arg) | ||
"test post completion." | ||
(if (string= (get-text-property 0 'type arg) "t") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to phpactor's author, this is going to be revisited, but for now, I think it's the best we can do.
@ejmr @zonuexe Thanks for the references I just "copied" a bunch of functions from the first link and only modified what seemed the most obvious to me, leaving all the magic details aside and got something working (proof) I'll push it in that shape for the moment although it certainly requires many things to finalize that. |
(prefix (company-phpactor--grab-symbol)) | ||
(candidates (all-completions (substring-no-properties arg) (mapcar #'(lambda (suggestion) (plist-get suggestion :name)) (company-phpactor--get-suggestions)))))) | ||
(save-restriction | ||
(widen) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this fixes issue #35
phpactor.el
Outdated
(interactive) | ||
(let ((tmpfile (make-temp-file "gofmt" nil ".go")) | ||
(patchbuf (get-buffer-create "*Gofmt patch*")) | ||
(errbuf (get-buffer-create "*Gofmt Errors*")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
buffer and file name to adapt
Hi @zonuexe I can't see what to change about this PR (at least at the time of writing this). I've not used it much since I got it working only today, but it's been fine so far. How about you, what do you think about maybe merging this, would something need to be adressed ? |
phpactor.el
Outdated
@@ -38,6 +38,10 @@ | |||
;; See https://phpactor.github.io/phpactor/configuration.html | |||
;; | |||
|
|||
;; Definitions adapted from go-mode.el(https://github.com/dominikh/go-mode.el) are : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kermorgant asked me, as go-mode's author, to sign off on the inclusion of these functions. If you wanted to abide by its license strictly, it'd require a copyright notice as well as the contents of the MIT license.
Seeing how these functions are trivial, however, and anyone implementing them from scratch would come up with identical code, I really don't care about the license and you're free to use them, with or without the reference to go-mode.
tl;dr: 👍
I have a few suggestions, none of which (except maybe the first) are so serious that I feel they should prevent merging.
|
e2f2080
to
bf14efa
Compare
Thanks for the review. I just addressed the first two comments but did not spot missing blank lines (could it be related to those "^L" characters ?). |
@kermorgant Postscript: I saw an email this morning (Japan time), but I have not read the contents yet. sorry. |
company-phpactor.el
Outdated
@@ -50,14 +50,38 @@ Here we create a temporary syntax table in order to add $ to symbols." | |||
(let ((response (phpactor--rpc "complete" (phpactor--command-argments :source :offset)))) | |||
(plist-get (plist-get (plist-get response :parameters) :value) :suggestions))) | |||
|
|||
(defun company-phpactor--get-candidates () | |||
"Build a list of candidates with text-properties extracted from phpactor's output." | |||
(let ((suggestions (company-phpactor--get-suggestions))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add candidate
as lexical variable.
diff --git a/company-phpactor.el b/company-phpactor.el
index 44514fb..90bf850 100644
--- a/company-phpactor.el
+++ b/company-phpactor.el
@@ -52,7 +52,7 @@ Here we create a temporary syntax table in order to add $ to symbols."
(defun company-phpactor--get-candidates ()
"Build a list of candidates with text-properties extracted from phpactor's output."
- (let ((suggestions (company-phpactor--get-suggestions)))
+ (let ((suggestions (company-phpactor--get-suggestions)) candidate)
(mapcar
(lambda (suggestion)
(setq candidate (plist-get suggestion :name))
@kermorgant I have invited you as a member of this organization. After removing |
Special-Thanks: Dominik Honnef (go-mode author) Feature description : After completion with company-phpactor, if the selected candidate is a class (see "info" key in phpactor's output), a proper "use" statement is added after the namespace declaration in case it was absent. In order to distinguish classes with the same name, fully qualified names are shown as annotations beside every completion candidate. What is changed : - completion candidates are given text properties with additionnal informations given by phpactor (info and type keys). - phpactor is called after the completion if the candidate had type 't' (class). - use of functions from go-mode.el to apply a patch on current buffer instead of replacing the whole buffer content in order to save the point. - also widen the buffer before completion, making completion also work during narrowing.
Feature description
After completion with company-phpactor, if the selected candidate is a class (see "info" key in phpactor's output), a proper "use" statement is added after the namespace declaration in case it was absent.
In order to distinguish classes with the same name, fully qualified names are shown as annotations beside every completion candidate.
What is changed :