From a43546468320601c366de269f57b6518fe78b15c Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Mon, 24 Apr 2023 12:44:47 +0800 Subject: [PATCH] Add min length options for some backend. --- README.md | 6 +++++- README.zh-CN.md | 4 ++++ acm/acm-backend-codeium.el | 10 ++++++++-- acm/acm-backend-elisp.el | 8 +++++++- acm/acm-backend-search-file-words.el | 8 +++++++- acm/acm-backend-yas.el | 6 ++++++ 6 files changed, 37 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f7fa082a63..45ca52a490 100644 --- a/README.md +++ b/README.md @@ -177,7 +177,11 @@ If the completion menu does not appear, log in to the remote server and check th - `acm-doc-frame-max-lines`: Max line number of help documentation, default is 20 - `acm-candidate-match-function`: The complete menu matching algorithm, the algorithm prefix of orderless-\* needs to be installed additional [orderless](https://github.com/oantolin/orderless) - `acm-completion-backend-merge-order`: Display order of completion backends. By default, multiple completion backends are merged in the order of LSP, Templates, and TabNine, and then the remaining templates and LSP completion options are displayed. You can adjust the order of completion back-end merging according to your needs -- `acm-backend-lsp-candidate-min-length`: The minimum characters to trigger completion, default is 0 +- `acm-backend-lsp-candidate-min-length`: The minimum characters to trigger lsp completion, default is 0 +- `acm-backend-elisp-candidate-min-length`: The minimum characters to trigger elisp completion, default is 0 +- `acm-backend-yas-candidate-min-length`: The minimum characters to trigger yasnippet completion, default is 0 +- `acm-backend-search-file-words-candidate-min-length`: The minimum characters to trigger search file words completion, default is 0 +- `acm-backend-codeium-candidate-min-length`: The minimum characters to trigger codeium completion, default is 0 - `acm-backend-lsp-enable-auto-import`: automatic insert import code, enable by default - `acm-backend-lsp-candidate-max-length`: Maximum length of LSP candidate, some language, such as Java, argument list is very long, you can increase the value of this option to see clear argument list - `acm-backend-yas-candidates-number`: yasnippet display number,2 by default diff --git a/README.zh-CN.md b/README.zh-CN.md index eb25675864..317f819775 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -177,6 +177,10 @@ lsp-bridge 也可以对远程服务器的文件进行代码语法补全,效果 - `acm-candidate-match-function`: 补全菜单匹配算法, orderless-\* 开头的算法需要额外安装 [orderless](https://github.com/oantolin/orderless) - `acm-completion-backend-merge-order`: 补全后端的显示顺序, 默认是按照 LSP、 模板、 TabNine 顺序合并多个补全后端后, 再显示剩下的模板和 LSP 补全选项, 你可以根据你的需求调整补全后端合并顺序 - `acm-backend-lsp-candidate-min-length`: LSP 补全最小的触发字符数, 默认是 0 +- `acm-backend-elisp-candidate-min-length`: Elisp 补全最小的触发字符数, 默认是 0 +- `acm-backend-yas-candidate-min-length`: YaSnippet 补全最小的触发字符数, 默认是 0 +- `acm-backend-search-file-words-candidate-min-length`: Search Words 补全最小的触发字符数, 默认是 0 +- `acm-backend-codeium-candidate-min-length`: Codeium 补全最小的触发字符数, 默认是 0 - `acm-backend-lsp-enable-auto-import`: 支持自动导入, 默认打开 - `acm-backend-lsp-candidate-max-length`: LSP 候选词最大长度, 一些语言参数较长, 可以适当增加这个选项的值以看清楚参数列表 - `acm-backend-yas-candidates-number`: yasnippet 显示个数,默认 2 个 diff --git a/acm/acm-backend-codeium.el b/acm/acm-backend-codeium.el index 528ae537f1..0fcd7fdcbd 100644 --- a/acm/acm-backend-codeium.el +++ b/acm/acm-backend-codeium.el @@ -13,6 +13,11 @@ :type 'boolean :group 'acm-backend-codeium) +(defcustom acm-backend-codeium-candidate-min-length 0 + "Minimal length of candidate." + :type 'integer + :group 'acm-backend-codeium) + (defcustom acm-backend-codeium-candidates-number 10 "Maximal number of codeium candidate of menu." :type 'integer @@ -138,8 +143,9 @@ (fsharp-mode . 59) (lisp-data-mode . 60))) -(defun acm-backend-codeium-candidates (_) - (when acm-backend-codeium-items +(defun acm-backend-codeium-candidates (keyword) + (when (and acm-backend-codeium-items + (>= (length keyword) acm-backend-codeium-candidate-min-length)) acm-backend-codeium-items)) (defun acm-backend-codeium-candidate-expand (candidate-info _) diff --git a/acm/acm-backend-elisp.el b/acm/acm-backend-elisp.el index 1ee0eded2f..eafacea6c1 100644 --- a/acm/acm-backend-elisp.el +++ b/acm/acm-backend-elisp.el @@ -88,6 +88,11 @@ "Elisp backend for acm." :group 'acm) +(defcustom acm-backend-elisp-candidate-min-length 0 + "Minimal length of candidate." + :type 'integer + :group 'acm-backend-elisp) + (defcustom acm-backend-elisp-search-max-number 300 "The maximum number of search candidates." :type 'integer @@ -106,7 +111,8 @@ (defvar acm-backend-elisp-symbols-update-size 0) (defun acm-backend-elisp-candidates (keyword) - (when (and (acm-is-elisp-mode-p)) + (when (and (acm-is-elisp-mode-p) + (>= (length keyword) acm-backend-elisp-candidate-min-length)) (mapcar (lambda (elisp-symbol) (let ((symbol-type (acm-backend-elisp-symbol-type (intern elisp-symbol)))) diff --git a/acm/acm-backend-search-file-words.el b/acm/acm-backend-search-file-words.el index aeaf96ff4e..c6a01d55fc 100644 --- a/acm/acm-backend-search-file-words.el +++ b/acm/acm-backend-search-file-words.el @@ -88,6 +88,11 @@ "Backend fo completion words in other buffer." :group 'acm) +(defcustom acm-backend-search-file-words-candidate-min-length 0 + "Minimal length of candidate." + :type 'integer + :group 'acm-backend-search-file-words) + (defcustom acm-enable-search-file-words t "Popup search words completions when this option is turn on." :type 'boolean @@ -96,7 +101,8 @@ (defvar-local acm-backend-search-file-words-items nil) (defun acm-backend-search-file-words-candidates (keyword) - (when acm-enable-search-file-words + (when (and acm-enable-search-file-words + (>= (length keyword) acm-backend-search-file-words-candidate-min-length)) (mapcar (lambda (candidate-label) (list :key candidate-label diff --git a/acm/acm-backend-yas.el b/acm/acm-backend-yas.el index 8d5ea4b0dc..eefb3cf11f 100644 --- a/acm/acm-backend-yas.el +++ b/acm/acm-backend-yas.el @@ -94,6 +94,11 @@ :type 'boolean :group 'acm-backend-yas) +(defcustom acm-backend-yas-candidate-min-length 0 + "Minimal length of candidate." + :type 'integer + :group 'acm-backend-yas) + (defcustom acm-backend-yas-candidates-number 2 "Maximal number of yas candidate of menu." :type 'integer @@ -165,6 +170,7 @@ Default matching use snippet filename." (defun acm-backend-yas-candidates (keyword) (when (and acm-enable-yas + (>= (length keyword) acm-backend-yas-candidate-min-length) (not (string-empty-p keyword))) (when (or acm-backend-yas--cache-expire-p (null acm-backend-yas--cache)