Skip to content

Commit

Permalink
Default only enable backend candidate filtering.
Browse files Browse the repository at this point in the history
  • Loading branch information
manateelazycat committed May 5, 2024
1 parent 7f8428e commit 7caac7c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ lsp-bridge provides support for more than two language servers for many language
- `acm-enable-yas`: yasnippet completion, enable by default
- `acm-enable-citre`: Integration with [citre(ctags)](https://github.com/universal-ctags/citre). Enable this to add citre (ctags) backend (disabled by default)
- `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-candidate-match-function`: lsp-bridge frontend filter algorithm for candidates, options include `'regexp-quote`, `'orderless-flex`, `'orderless-literal`, `'orderless-prefixes`, `'orderless-regexp`, `'orderless-initialism`, default is `nil`, meaning the default only performs backend filtering (refer to `acm-backend-lsp-match-mode`), and does not perform frontend filtering. orderless-* started algorithms require additional installation of [orderless](https://github.com/oantolin/orderless)
- `acm-completion-backend-merge-order`: Customize the order of the completion backends, default order is: first part of mode candidate, first part of template candidates, tabnine/copilot/codeium, second part of template candidates, second part of mode candidates, set `acm-completion-mode-candidates-merge-order` customize mode candidates order
- `acm-completion-mode-candidates-merge-order`: Customize the order of the mode candidates, the display order for mode candidates, default order: Elisp、 LSP、 Jupyter、 Ctags、 Citre、 ROAM、 Word、 Telegra
- `acm-backend-lsp-candidate-min-length`: The minimum characters to trigger lsp completion, default is 0
Expand Down
6 changes: 3 additions & 3 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ lsp-bridge 开箱即用, 安装好语言对应的 [LSP 服务器](https://gith
- `lsp-bridge-peek-tree-next-node`: 选择浏览历史上下一级节点 (默认绑定到 `<right>` )
- `lsp-bridge-indent-left`: 根据 `lsp-bridge-formatting-indent-alist` 定义的缩进值, 向左缩进刚刚粘贴的文本
- `lsp-bridge-indent-right`: 根据 `lsp-bridge-formatting-indent-alist` 定义的缩进值, 向右缩进刚刚粘贴的文本
- `lsp-bridge-semantic-tokens-mode`: 开启或者关闭语义符号高亮, 自定义请参考[Semantic Tokens Wiki](https://github.com/manateelazycat/lsp-bridge/wiki/Semantic-Tokens-%5B%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87%E7%89%88%5D)
- `lsp-bridge-semantic-tokens-mode`: 开启或者关闭语义符号高亮, 自定义请参考 [Semantic Tokens Wiki](https://github.com/manateelazycat/lsp-bridge/wiki/Semantic-Tokens-%5B%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87%E7%89%88%5D)

## 自定义语言服务器配置

Expand Down Expand Up @@ -319,7 +319,7 @@ lsp-bridge 针对许多语言都提供 2 个以上的语言服务器支持,
- `acm-enable-yas`: yasnippet 补全, 默认打开
- `acm-enable-citre`: [citre(ctags)](https://github.com/universal-ctags/citre) 补全, 默认关闭
- `acm-doc-frame-max-lines`: 帮助窗口的最大行数, 默认是 20
- `acm-candidate-match-function`: 补全菜单匹配算法, orderless-\* 开头的算法需要额外安装 [orderless](https://github.com/oantolin/orderless)
- `acm-candidate-match-function`: lsp-bridge 前端对补全候选词的过滤算法, 选项有 `'regexp-quote`, `'orderless-flex`, `'orderless-literal`, `'orderless-prefixes`, `'orderless-regexp`, `'orderless-initialism`, 默认为 `nil`, 意味着默认只进行后端过滤(参考 `acm-backend-lsp-match-mode`), 不进行前端过滤, orderless-\* 开头的算法需要额外安装 [orderless](https://github.com/oantolin/orderless)
- `acm-completion-backend-merge-order`: 补全后端的显示顺序, 默认是按照模式补全前半部分、 模板补全前半部分、 TabNine/Copilot/Codeium、 模板补全后半部分、 模式补全后半部分的顺序显示, 你可以根据你的需求调整补全后端的显示顺序, 如果要自定义模式补全的顺序, 请自定义 `acm-completion-mode-candidates-merge-order`
- `acm-completion-mode-candidates-merge-order`: 模式补全的显示顺序, 默认是按照 Elisp、 LSP、 Jupyter、 Ctags、 Citre、 ROAM、 单词、 Telegra 的顺序显示, 你可以根据你的需求调整模式补全的显示顺序
- `acm-backend-lsp-candidate-min-length`: LSP 补全最小的触发字符数, 默认是 0
Expand All @@ -336,7 +336,7 @@ lsp-bridge 针对许多语言都提供 2 个以上的语言服务器支持,
- `acm-backend-yas-candidates-number`: yasnippet 显示个数, 默认 2 个
- `acm-backend-citre-keyword-complete`: 根据`acm-backend-citre-keywords-alist`定义的各个模式的关键字进行补全, 需要使能 citre 后才生效
- `acm-backend-search-sdcv-words-dictionary`: 用于单词补全的 StarDict 词典, 默认是 `kdic-ec-11w`, 可以自定义为其他 StarDict 词典, 如果你的系统存在词典 `/usr/share/stardict/dic/stardict-oxford-gb-formated-2.4.2/oxford-gb-formated.ifo`, 你需要设置这个选项为 `/usr/share/stardict/dic/stardict-oxford-gb-formated-2.4.2/oxford-gb-formated`, 不需要包括 `.ifo` 扩展
- `acm-backend-lsp-match-mode`: LSP 后端候选词过滤模式, 有 "prefix", "prefixCaseSensitive", "fuzzy" 三个选项, 默认是 "fuzzy"
- `acm-backend-lsp-match-mode`: lsp-bridge 后端对补全候选词的过滤算法, 选项有 "prefix", "prefixCaseSensitive", "fuzzy", 默认是 "fuzzy"
- `acm-backend-lsp-show-progress`: 是否显示 LSP Server 工作进度, 默认关闭
- `acm-enable-preview`: 开启 Tab-and-Go completion, 当改变当前候选时, 可以预览候选, 并且后续输入会选择预览候选, 默认关闭

Expand Down
26 changes: 15 additions & 11 deletions acm/acm.el
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,16 @@
:type 'boolean
:group 'acm)

(defcustom acm-candidate-match-function 'regexp-quote
(defcustom acm-candidate-match-function nil
"acm candidate match function."
:type '(choice (const regexp-quote)
(const orderless-literal)
(const orderless-prefixes)
(const orderless-flex)
(const orderless-regexp)
(const orderless-initialism))
:type '(choice
(const nil)
(const regexp-quote)
(const orderless-flex)
(const orderless-literal)
(const orderless-prefixes)
(const orderless-regexp)
(const orderless-initialism))
:group 'acm)

(defcustom acm-doc-frame-max-lines 20
Expand Down Expand Up @@ -409,10 +411,12 @@ So we use `minor-mode-overriding-map-alist' to override key, make sure all keys

(defun acm-candidate-fuzzy-search (keyword candidate)
"Fuzzy search candidate."
(let ((result (funcall acm-candidate-match-function (downcase keyword))))
(string-match-p (cond ((stringp result) result)
(t (rx-to-string result))) ;; If `rx'.
(downcase candidate))))
(if acm-candidate-match-function
(let ((result (funcall acm-candidate-match-function (downcase keyword))))
(string-match-p (cond ((stringp result) result)
(t (rx-to-string result))) ;; If `rx'.
(downcase candidate)))
t))

(defun acm-candidate-sort-by-prefix (keyword candidates)
"Priority display of the candidates of the prefix matching."
Expand Down

0 comments on commit 7caac7c

Please sign in to comment.