[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/cape 38802ada22 007/146: Add kinds
From: |
ELPA Syncer |
Subject: |
[elpa] externals/cape 38802ada22 007/146: Add kinds |
Date: |
Sun, 9 Jan 2022 20:57:37 -0500 (EST) |
branch: externals/cape
commit 38802ada2219bb98d688a3fcad272dc08f0e0bc2
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Add kinds
---
cape.el | 65 +++++++++++++++++++++++++++++++++++++----------------------------
1 file changed, 37 insertions(+), 28 deletions(-)
diff --git a/cape.el b/cape.el
index 5305e2d3aa..527bf81796 100644
--- a/cape.el
+++ b/cape.el
@@ -289,26 +289,32 @@
"Alist of major modes and keywords."
:type 'alist)
-(defun cape--complete-in-region (thing table &rest extra)
+(defun cape--complete-in-region (thing table extra)
"Complete THING at point given completion TABLE and EXTRA properties."
(let ((bounds (or (bounds-of-thing-at-point thing) (cons (point) (point))))
(completion-extra-properties extra))
(completion-in-region (car bounds) (cdr bounds) table)))
+(defvar cape--file-properties
+ (list :annotation-function (lambda (s) (if (string-suffix-p "/" s) " Folder"
" File"))
+ :company-kind (lambda (s) (if (string-suffix-p "/" s) 'folder 'file))))
+
;;;###autoload
(defun cape-file-capf ()
"File name completion-at-point-function."
(when-let (bounds (bounds-of-thing-at-point 'filename))
- (list (car bounds) (cdr bounds)
- #'read-file-name-internal
- :exclusive 'no
- :annotation-function (lambda (_) " File"))))
+ `(,(car bounds) ,(cdr bounds) ,#'read-file-name-internal
+ :exclusive no ,@cape--file-properties)))
;;;###autoload
(defun cape-file ()
"Complete file name at point."
(interactive)
- (cape--complete-in-region 'filename #'read-file-name-internal))
+ (cape--complete-in-region 'filename #'read-file-name-internal
cape--file-properties))
+
+(defvar cape--dabbrev-properties
+ (list :annotation-function (lambda (_) " Dabbrev")
+ :company-kind (lambda (_) 'text)))
;;;###autoload
(defun cape-dabbrev-capf ()
@@ -335,12 +341,14 @@
(let ((beg (progn (search-backward abbrev) (point)))
(end (progn (search-forward abbrev) (point))))
(unless (string-match-p "\n" (buffer-substring beg end))
- (list beg end words
- :exclusive 'no
- :annotation-function (lambda (_) " Dabbrev"))))))))))
+ `(,beg ,end ,words :exclusive no
,@cape--dabbrev-properties)))))))))
(autoload 'ispell-lookup-words "ispell")
+(defvar cape--ispell-properties
+ (list :annotation-function (lambda (_) " Ispell")
+ :company-kind (lambda (_) 'text)))
+
;;;###autoload
(defun cape-ispell-capf ()
"Ispell completion-at-point-function."
@@ -351,9 +359,7 @@
(ispell-lookup-words
(format "*%s*"
(buffer-substring-no-properties (car
bounds) (cdr bounds))))))))
- (list (car bounds) (cdr bounds) table
- :exclusive 'no
- :annotation-function (lambda (_) " Ispell"))))
+ `(,(car bounds) ,(cdr bounds) ,table :exclusive no
,@cape--ispell-properties)))
;;;###autoload
(defun cape-ispell ()
@@ -362,6 +368,10 @@
(let ((completion-at-point-functions (list #'cape-ispell-capf)))
(completion-at-point)))
+(defvar cape--dict-properties
+ (list :annotation-function (lambda (_) " Dict")
+ :company-kind (lambda (_) 'text)))
+
(defvar cape--dict-words nil)
(defun cape--dict-words ()
"Return list of dictionary words."
@@ -376,34 +386,30 @@
(defun cape-dict-capf ()
"Dictionary completion-at-point-function."
(when-let (bounds (bounds-of-thing-at-point 'word))
- (list (car bounds) (cdr bounds) (cape--dict-words)
- :exclusive 'no
- :annotation-function (lambda (_) " Dict"))))
+ `(,(car bounds) ,(cdr bounds) ,(cape--dict-words) :exclusive no
,@cape--dict-properties)))
;;;###autoload
(defun cape-dict ()
"Complete word at point."
(interactive)
- (cape--complete-in-region 'word (cape--dict-words)))
+ (cape--complete-in-region 'word (cape--dict-words) cape--dict-properties))
(defun cape--abbrev-completions ()
"Return all abbreviations."
(delete "" (nconc (all-completions "" global-abbrev-table)
(all-completions "" local-abbrev-table))))
-(defun cape--abbrev-expand (&rest _)
- "Expand abbreviation before point."
- (expand-abbrev))
+(defvar cape--abbrev-properties
+ (list :annotation-function (lambda (_) " Abbrev")
+ :exit-function (lambda (&rest _) (expand-abbrev))
+ :company-kind (lambda (_) 'snippet)))
;;;###autoload
(defun cape-abbrev-capf ()
"Abbrev completion-at-point-function."
(when-let ((bounds (bounds-of-thing-at-point 'symbol))
(abbrevs (cape--abbrev-completions)))
- (list (car bounds) (cdr bounds) abbrevs
- :exclusive 'no
- :exit-function #'cape--abbrev-expand
- :annotation-function (lambda (_) " Abbrev"))))
+ `(,(car bounds) ,(cdr bounds) ,abbrevs :exclusive no
,@cape--abbrev-properties)))
;;;###autoload
(defun cape-abbrev ()
@@ -411,21 +417,23 @@
(interactive)
(cape--complete-in-region 'symbol (or (cape--abbrev-completions)
(user-error "No abbreviations"))
- :exit-function #'cape--abbrev-expand))
+ cape--abbrev-properties))
(defun cape--keywords ()
"Return keywords for current major mode."
(when-let (kw (alist-get major-mode cape-keywords))
(if (symbolp (cadr kw)) (alist-get (cadr kw) cape-keywords) kw)))
+(defvar cape--keyword-properties
+ (list :annotation-function (lambda (_) " Keyword")
+ :company-kind (lambda (_) 'keyword)))
+
;;;###autoload
(defun cape-keyword-capf ()
"Dictionary completion-at-point-function."
(when-let ((bounds (bounds-of-thing-at-point 'symbol))
(keywords (cape--keywords)))
- (list (car bounds) (cdr bounds) keywords
- :exclusive 'no
- :annotation-function (lambda (_) " Keyword"))))
+ `(,(car bounds) ,(cdr bounds) ,keywords :exclusive no
,@cape--keyword-properties)))
;;;###autoload
(defun cape-keyword ()
@@ -433,7 +441,8 @@
(interactive)
(cape--complete-in-region 'symbol
(or (cape--keywords)
- (user-error "No keywords for %s" major-mode))))
+ (user-error "No keywords for %s" major-mode))
+ cape--keyword-properties))
(provide 'cape)
;;; cape.el ends here
- [elpa] externals/cape 6c124b6cfd 015/146: README: Add some justification for the name :), (continued)
- [elpa] externals/cape 6c124b6cfd 015/146: README: Add some justification for the name :), ELPA Syncer, 2022/01/09
- [elpa] externals/cape 63ded5fde4 028/146: Improve cape-company-to-capf, ELPA Syncer, 2022/01/09
- [elpa] externals/cape f270456b5d 041/146: Improve cape-dabbrev-capf, ELPA Syncer, 2022/01/09
- [elpa] externals/cape a8e10cf7ae 014/146: Update README, ELPA Syncer, 2022/01/09
- [elpa] externals/cape d6b13d3055 027/146: Fix no-cache call, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 0e60999893 032/146: cape-ispell: Fix caching, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 7325c5002f 035/146: Update README, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 0a374042c9 003/146: README: Update configuration, ELPA Syncer, 2022/01/09
- [elpa] externals/cape d7c765d057 004/146: Add cape-keyword and cape-keyword-capf (Fix #3), ELPA Syncer, 2022/01/09
- [elpa] externals/cape 1aaca0fd74 008/146: Expand comment, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 38802ada22 007/146: Add kinds,
ELPA Syncer <=
- [elpa] externals/cape b1f57d79ba 009/146: Improve ispell, ELPA Syncer, 2022/01/09
- [elpa] externals/cape ae136b6ba4 010/146: Improve dabbrev lazy loading, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 0cc116b29c 012/146: Implement company adapter (See #1), ELPA Syncer, 2022/01/09
- [elpa] externals/cape 845f3483f1 019/146: company-merge-capfs: Add support for :company-prefix-length, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 31acb66152 021/146: Update README, ELPA Syncer, 2022/01/09
- [elpa] externals/cape adb54fc562 020/146: Add missing autoload, ELPA Syncer, 2022/01/09
- [elpa] externals/cape d098cc3cba 023/146: Update README, ELPA Syncer, 2022/01/09
- [elpa] externals/cape ff5b19afc0 025/146: Add missing omit-nulls, ELPA Syncer, 2022/01/09
- [elpa] externals/cape a54a512030 030/146: cape-merge-capfs: Compute candidates later, ELPA Syncer, 2022/01/09
- [elpa] externals/cape 0bdc6ae05c 034/146: README: Mention cape-capf-buster, ELPA Syncer, 2022/01/09