diff --git a/company-phpactor.el b/company-phpactor.el index c0c0557..76323e0 100644 --- a/company-phpactor.el +++ b/company-phpactor.el @@ -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))))) (provide 'company-phpactor) ;;; company-phpactor.el ends here