Skip to content

Commit

Permalink
Add min length options for some backend.
Browse files Browse the repository at this point in the history
  • Loading branch information
manateelazycat committed Apr 24, 2023
1 parent 9004306 commit a435464
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 5 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 个
Expand Down
10 changes: 8 additions & 2 deletions acm/acm-backend-codeium.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 _)
Expand Down
8 changes: 7 additions & 1 deletion acm/acm-backend-elisp.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))))
Expand Down
8 changes: 7 additions & 1 deletion acm/acm-backend-search-file-words.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions acm/acm-backend-yas.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a435464

Please sign in to comment.