Skip to content

Commit

Permalink
Merge pull request #312 from supermomonga/auto-complete-show-kind-fea…
Browse files Browse the repository at this point in the history
…ture

Show candidate kind in auto-complete popup
  • Loading branch information
razzmatazz authored Jun 1, 2017
2 parents 59aa5ac + 405ad7c commit 7ca20bb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
36 changes: 34 additions & 2 deletions omnisharp-auto-complete-actions.el
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ and complete members."
. ,(omnisharp--t-or-json-false
omnisharp-auto-complete-want-importable-types))

(WordToComplete . ,(thing-at-point 'symbol)))
(WordToComplete . ,(thing-at-point 'symbol))

(WantKind . t))

(omnisharp--get-request-object)))

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

(defun omnisharp--convert-auto-complete-kind-to-popup-symbol-value (kind)
(pcase kind
;; auto-complete's recommended rules
;;; Symbol
("Keyword" "s")
;;; Function, Method
("Method" "f")
("Function" "f")
("Constructor" "f")
;;; Variable
("Field" "v")
("Variable" "v")
("Property" "v")
;;; Constant
;;; Abbreviation
("Value" "a")
;; original rules
("Text" "")
("Class" "t")
("Interface" "i")
("Enum" "e")
("Module" "m")
("Unit" "u")
("Snippet" "")
("Color" "")
("File" "f")
("Reference" "r")))

(defun omnisharp--convert-auto-complete-result-to-popup-format (json-result-alist)
(mapcar
(-lambda ((&alist 'DisplayText display-text
'CompletionText completion-text
'Description description
'Snippet snippet
'RequiredNamespaceImport require-ns-import))
'RequiredNamespaceImport require-ns-import
'Kind kind))
(popup-make-item display-text
:value (propertize completion-text 'Snippet snippet 'RequiredNamespaceImport require-ns-import)
:symbol (omnisharp--convert-auto-complete-kind-to-popup-symbol-value kind)
:document description))
json-result-alist))

Expand Down
3 changes: 2 additions & 1 deletion test/unit-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ expected output in that buffer"
(RequiredNamespaceImport . nil)
(DisplayText . "Verbosity Verbose - display text")
(Description . ,description)
(CompletionText . ,completion-text))])
(CompletionText . ,completion-text)
(Kind . "Verbose"))])
(converted-popup-item
(nth 0
(omnisharp--convert-auto-complete-result-to-popup-format
Expand Down

0 comments on commit 7ca20bb

Please sign in to comment.