Skip to content

Commit 7ca20bb

Browse files
authored
Merge pull request #312 from supermomonga/auto-complete-show-kind-feature
Show candidate kind in auto-complete popup
2 parents 59aa5ac + 405ad7c commit 7ca20bb

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

omnisharp-auto-complete-actions.el

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,9 @@ and complete members."
216216
. ,(omnisharp--t-or-json-false
217217
omnisharp-auto-complete-want-importable-types))
218218

219-
(WordToComplete . ,(thing-at-point 'symbol)))
219+
(WordToComplete . ,(thing-at-point 'symbol))
220+
221+
(WantKind . t))
220222

221223
(omnisharp--get-request-object)))
222224

@@ -672,15 +674,45 @@ is a more sophisticated matching framework than what popup.el offers."
672674
(when required-namespace-import
673675
(omnisharp--insert-namespace-import required-namespace-import)))))
674676

677+
(defun omnisharp--convert-auto-complete-kind-to-popup-symbol-value (kind)
678+
(pcase kind
679+
;; auto-complete's recommended rules
680+
;;; Symbol
681+
("Keyword" "s")
682+
;;; Function, Method
683+
("Method" "f")
684+
("Function" "f")
685+
("Constructor" "f")
686+
;;; Variable
687+
("Field" "v")
688+
("Variable" "v")
689+
("Property" "v")
690+
;;; Constant
691+
;;; Abbreviation
692+
("Value" "a")
693+
;; original rules
694+
("Text" "")
695+
("Class" "t")
696+
("Interface" "i")
697+
("Enum" "e")
698+
("Module" "m")
699+
("Unit" "u")
700+
("Snippet" "")
701+
("Color" "")
702+
("File" "f")
703+
("Reference" "r")))
704+
675705
(defun omnisharp--convert-auto-complete-result-to-popup-format (json-result-alist)
676706
(mapcar
677707
(-lambda ((&alist 'DisplayText display-text
678708
'CompletionText completion-text
679709
'Description description
680710
'Snippet snippet
681-
'RequiredNamespaceImport require-ns-import))
711+
'RequiredNamespaceImport require-ns-import
712+
'Kind kind))
682713
(popup-make-item display-text
683714
:value (propertize completion-text 'Snippet snippet 'RequiredNamespaceImport require-ns-import)
715+
:symbol (omnisharp--convert-auto-complete-kind-to-popup-symbol-value kind)
684716
:document description))
685717
json-result-alist))
686718

test/unit-test.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@ expected output in that buffer"
251251
(RequiredNamespaceImport . nil)
252252
(DisplayText . "Verbosity Verbose - display text")
253253
(Description . ,description)
254-
(CompletionText . ,completion-text))])
254+
(CompletionText . ,completion-text)
255+
(Kind . "Verbose"))])
255256
(converted-popup-item
256257
(nth 0
257258
(omnisharp--convert-auto-complete-result-to-popup-format

0 commit comments

Comments
 (0)