From 4a75cd350c4070ea4ea1ee8f70dfcb93c2cc2bb3 Mon Sep 17 00:00:00 2001 From: Hugo Thunnissen Date: Thu, 17 Aug 2023 11:51:26 +0200 Subject: [PATCH] Insert closing parenthesis when function does not take any arguments --- phpinspect-completion.el | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/phpinspect-completion.el b/phpinspect-completion.el index 4692750..5f4e5ae 100644 --- a/phpinspect-completion.el +++ b/phpinspect-completion.el @@ -35,6 +35,9 @@ (cl-defstruct (phpinspect--completion (:constructor phpinspect--construct-completion)) "Contains a possible completion value with all it's attributes." + (target nil + :documentation + "The object that this completion is aimed at/completing towards") (value nil :type string) (meta nil :type string) (annotation nil :type string) @@ -244,6 +247,7 @@ Returns list of `phpinspect--completion'." :annotation (concat " " (phpinspect--type-bare-name (phpinspect--function-return-type completion-candidate))) + :target completion-candidate :kind 'function)) (cl-defmethod phpinspect--make-completion @@ -253,6 +257,7 @@ Returns list of `phpinspect--completion'." :meta (phpinspect--format-type-name (or (phpinspect--variable-type completion-candidate) phpinspect--null-type)) + :target completion-candidate :annotation (concat " " (phpinspect--type-bare-name (or (phpinspect--variable-type completion-candidate) @@ -286,12 +291,15 @@ Returns list of `phpinspect--completion'." (nreverse affixated))) :exit-function (lambda (comp-name state) + (let ((comp (phpinspect--completion-list-get-metadata + phpinspect--last-completion-list + comp-name))) (when (and (eq 'finished state) - (eq 'function (phpinspect--completion-kind - (phpinspect--completion-list-get-metadata - phpinspect--last-completion-list - comp-name)))) - (insert "("))) + (eq 'function (phpinspect--completion-kind comp))) + (insert "(") + (when (= 0 (length (phpinspect--function-arguments + (phpinspect--completion-target comp)))) + (insert ")"))))) :company-kind (lambda (comp-name) (phpinspect--completion-kind (phpinspect--completion-list-get-metadata