From 6a05af5dc45b9ffb747237a949e409c6e41b1fab Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Sat, 27 Jul 2024 07:04:34 +0800 Subject: [PATCH] Add new option lsp-bridge-completion-in-string-file-types --- README.md | 2 +- README.zh-CN.md | 2 +- lsp-bridge.el | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2ad77cc81a..92bd71e381 100644 --- a/README.md +++ b/README.md @@ -280,7 +280,7 @@ lsp-bridge provides support for more than two language servers for many language - `lsp-bridge-find-def-fallback-function`: When LSP cannot find a definition, you can customize this function for candidate jumping, such as binding the citre function - `lsp-bridge-find-ref-fallback-function`: When LSP cannot find a reference, you can customize this function for candidate jumping, such as binding the citre function - `lsp-bridge-find-def-select-in-open-windows`: If this option is turned on, when searching for function definitions, already open windows will be selected instead of switching buffers. disable by default -- `lsp-bridge-enable-completion-in-string`: Enable completion pop-up within strings, default is off +- `lsp-bridge-enable-completion-in-string`: Enable completion pop-up within strings, disabled by default, if you only want to show completion popups in strings for certain languages, please customize the option `lsp-bridge-completion-in-string-file-types` - `lsp-bridge-enable-completion-in-minibuffer`: Enable pop-completion up in Minibuffer, disabled by default - `lsp-bridge-enable-diagnostics`: code diagnostic, enable by default - `lsp-bridge-enable-inlay-hint`: inlay hint, disable by default, this option is use for strong type language, such as, Rust diff --git a/README.zh-CN.md b/README.zh-CN.md index 9025217519..da482dbc40 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -279,7 +279,7 @@ lsp-bridge 针对许多语言都提供 2 个以上的语言服务器支持, - `lsp-bridge-find-def-fallback-function`: 当 LSP 没有找到定义时, 可以通过定制这个函数来进行候选跳转, 比如绑定 citre 函数 - `lsp-bridge-find-ref-fallback-function`: 当 LSP 没有找到引用时, 可以通过定制这个函数来进行候选跳转, 比如绑定 citre 函数 - `lsp-bridge-find-def-select-in-open-windows`: 当打开这个选项时, 查找定义命令会尽量选择已经打开窗口去跳转定义, 而不是在当前窗口切换 Buffer, 默认关闭 -- `lsp-bridge-enable-completion-in-string`: 支持在字符串中弹出补全, 默认关闭 +- `lsp-bridge-enable-completion-in-string`: 支持在字符串中弹出补全, 默认关闭, 如果你只想在某些语言的字符串中弹出补全, 请自定义选项 `lsp-bridge-completion-in-string-file-types` - `lsp-bridge-enable-completion-in-minibuffer`: 支持在 Minibuffer 中弹出补全, 默认关闭 - `lsp-bridge-enable-diagnostics`: 代码诊断, 默认打开 - `lsp-bridge-enable-inlay-hint`: 类型嵌入提示, 默认关闭, 这个选项对于那些严重依赖类型提示的语言比较有用, 比如 Rust diff --git a/lsp-bridge.el b/lsp-bridge.el index bbf33e0417..4cd2bd349d 100644 --- a/lsp-bridge.el +++ b/lsp-bridge.el @@ -304,6 +304,13 @@ After set `lsp-bridge-completion-obey-trigger-characters-p' to nil, you need use :safe #'booleanp :group 'lsp-bridge) +(defcustom lsp-bridge-completion-in-string-file-types '("vue" "dart") + "File types where completion in string is allowed. +This is a list of file extensions for which +LSP-Bridge will enable completion inside string literals." + :type '(repeat string) + :group 'lsp-bridge) + (defface lsp-bridge-font-lock-flash '((t (:inherit highlight))) "Face to flash the current line." @@ -1448,7 +1455,7 @@ So we build this macro to restore postion after code format." ;; For some languages, allow popup completion menu in string. (and (boundp 'acm-backend-lsp-filepath) acm-backend-lsp-filepath - (member (file-name-extension acm-backend-lsp-filepath) '("vue" "dart"))) + (member (file-name-extension acm-backend-lsp-filepath) lsp-bridge-completion-in-string-file-types)) ;; Other language not allowed popup completion in string, it's annoy (not (acm-in-string-p)) ;; Allow popup completion menu for string interpolation