-
-
Notifications
You must be signed in to change notification settings - Fork 652
[fix #3017] Annotate company completion kinds #3024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,26 @@ backend, and ABBREVIATION is a short form of that type." | |
:group 'cider | ||
:package-version '(cider . "0.9.0")) | ||
|
||
(defconst cider-completion-kind-alist | ||
'(("class" class) | ||
("field" field) | ||
("function" function) | ||
("import" class) | ||
("keyword" keyword) | ||
("local" variable) | ||
("macro" macro) | ||
("method" method) | ||
("namespace" module) | ||
("protocol" enum) | ||
("protocol-function" enum-member) | ||
("record" struct) | ||
("special-form" keyword) | ||
("static-field" field) | ||
("static-method" interface) | ||
("type" parameter) | ||
("var" variable)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was going to change most of those afterwards anyways. E.g. I don't think that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are many nuances to consider and this has to be aligned with how clojure-mode works internally as well. That's why I think we can sort it out later. Just update the changelog and for now we're good to go. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Btw I've changed this to use Also triangle square and circle kinda seem like a good icon to represent macros, as this is really puzzling :D There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right. We basically mirror VS Code's type. Not to say we can't extend the list, but getting nice icons can be a problem. Anyway, check out https://github.com/emacs-mirror/emacs/blob/6ec3cf1ccb5380acc376e89140b8d3a7fa4e471a/lisp/progmodes/elisp-mode.el#L647-L655 Since there are no "real" keywords in Lisp, reusing this kind for macros and special forms seemed like a good idea. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Regarding local variables, we use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Clojure actually does have real keywords, and CIDER annotates those with Though the icon kinda suggests that this is language-level keyword, not data keyword, so maybe a different icon could be used for those. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this context I actually meant keywords in the sense of "built-ins"/"reserved words". That's how elisp-mode and clojure-mode work. Anyways, not a big deal. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @andreyorst These kind of keywords are present in Elisp as well. But that's not what is usually called a keyword in most programming languages (in Ruby, we call them "symbols", for example). And as someone who routinely works with several languages, I like to see annotations (and icons) have more universal meanings. |
||
"Icon mapping for company-mode.") | ||
|
||
(defcustom cider-completion-annotations-include-ns 'unqualified | ||
"Controls passing of namespaces to `cider-annotate-completion-function'. | ||
|
||
|
@@ -192,6 +212,12 @@ completion functionality." | |
(concat (when ns (format " (%s)" ns)) | ||
(when type (format " <%s>" type)))) | ||
|
||
(defun cider-company-symbol-kind (symbol) | ||
"Get SYMBOL kind for company-mode." | ||
(let ((type (get-text-property 0 'type symbol))) | ||
(or (cadr (assoc type cider-completion-kind-alist)) | ||
type))) | ||
|
||
(defun cider-annotate-symbol (symbol) | ||
"Return a string suitable for annotating SYMBOL. | ||
If SYMBOL has a text property `type` whose value is recognised, its | ||
|
@@ -213,6 +239,7 @@ performed by `cider-annotate-completion-function'." | |
(list (car bounds) (cdr bounds) | ||
(completion-table-dynamic #'cider-complete) | ||
:annotation-function #'cider-annotate-symbol | ||
:company-kind #'cider-company-symbol-kind | ||
:company-doc-buffer #'cider-create-doc-buffer | ||
:company-location #'cider-company-location | ||
:company-docsig #'cider-company-docsig)))) | ||
|
Uh oh!
There was an error while loading. Please reload this page.