emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/company 4286972: company-clang: Experimental support fo


From: ELPA Syncer
Subject: [elpa] externals/company 4286972: company-clang: Experimental support for 'kind'
Date: Fri, 16 Apr 2021 18:57:09 -0400 (EDT)

branch: externals/company
commit 4286972775832e29434becc6c72e767319139a1c
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    company-clang: Experimental support for 'kind'
---
 company-clang.el | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/company-clang.el b/company-clang.el
index 183eb7a..9a38d86 100644
--- a/company-clang.el
+++ b/company-clang.el
@@ -388,6 +388,7 @@ passed via standard input."
     (candidates (cons :async
                       (lambda (cb) (company-clang--candidates arg cb))))
     (meta       (company-clang--meta arg))
+    (kind (company-clang--kind arg))
     (annotation (company-clang--annotation arg))
     (post-completion (let ((anno (company-clang--annotation arg)))
                        (when (and company-clang-insert-arguments anno)
@@ -397,5 +398,22 @@ passed via standard input."
                            (company-template-c-like-templatify
                             (concat arg anno))))))))
 
+(defun company-clang--kind (arg)
+  ;; XXX: Not very precise.
+  ;; E.g. it will say that an arg-less ObjC method is a variable (perhaps we
+  ;; could look around for brackets, etc, if there any actual users who's
+  ;; bothered by it).
+  ;; And we can't distinguish between local vars and struct fields.
+  ;; Or between keywords and macros.
+  (let ((meta (company-clang--meta arg)))
+    (cond
+     ((null meta) 'keyword)
+     ((string-match "(" meta)
+      (if (string-match-p (format "\\`%s *\\'" (regexp-quote arg))
+                          (substring meta 0 (match-beginning 0)))
+          'keyword ; Also macro, actually (no return type).
+        'function))
+     (t 'variable))))
+
 (provide 'company-clang)
 ;;; company-clang.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]