Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion company-phpactor.el
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,28 @@ 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)))
(mapcar
(lambda (suggestion)
(setq candidate (plist-get suggestion :name))
(put-text-property 0 1 'annotation (plist-get suggestion :info) candidate)
candidate)
suggestions)))
(defun company-phpactor--annotation (arg)
"test annotation."
(message (concat " " (get-text-property 0 'annotation arg))))

;;;###autoload
(defun company-phpactor (command &optional arg &rest ignored)
"`company-mode' completion backend for Phpactor."
(interactive (list 'interactive))
(cl-case command
(annotation (company-phpactor--annotation arg))
(interactive (company-begin-backend 'company-phpactor))
(prefix (company-phpactor--grab-symbol))
(candidates (all-completions (substring-no-properties arg) (mapcar #'(lambda (suggestion) (plist-get suggestion :name)) (company-phpactor--get-suggestions))))))
(candidates (all-completions arg (company-phpactor--get-candidates)))))
Copy link
Contributor Author

@kermorgant kermorgant Jul 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the impression calling all-completions is useless. Am I wrong about that ?
@MarTango I believe you pushed that, do you remember if there was some use for it ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, no worry. After reading the doc of all-completions, I understand it filters the candidates given in the second argument by ensuring each one begins with the first one. This seems to be redundant with what phpactor already does.


(provide 'company-phpactor)
;;; company-phpactor.el ends here