lsp-bridge -- 速度最快的语法补全插件

请教一下,lsp-bridge 目前的状态是:只支持 corfu,不支持 company,支持终端,但要自己配 acm,终端下不支持 posframe ,是这样吗

lsp-bridge不需要corfu,company

acm不需要配置,开箱即用

posframe只能在终端下跑。

第一点,意思是,我裸的 emacs,加载 lap-bridge 后(配置好 clangd ),预期是直接能补全、语法提示的吗 第二点,不需要配置是指,单独 require acm 啥的(看他 readme)后,就能 work 呗 第三点,这个暂时没搞清楚,先不管了

anyway,我从零试试

你按照README的操作一遍就知道了。

有办法限制不同补全后端的补全数量吗? 现在lsp的补全有时候太多了 readme只看到了yas的数目限制

1 个赞

如果用spacemacs的话,添加了lsp-bridge, 还需要在layer中添加c/c++这些layer吗?company这些包也需要主动移除是吧,我这边会同时出现两个补全弹窗

lsp-bridge只需要自己,其他所有弹出补全的配置都可以删除了。

同源问题:关于lispy-mode,还需要加入这条,才能解决lispy退格(比如lispy-delete-backward-char)造成的闪的问题

(add-to-list 'acm-continue-commands "\\`lispy-")

不知道哪位大佬能测试并PR一下:修改 (defcustom acm-continue-commands '(… … … )) 成新列表:

(defcustom acm-continue-commands
  ;; nil is undefined command
  '(nil ignore universal-argument universal-argument-more digit-argument
        self-insert-command org-self-insert-command
        ;; Avoid flashing completion menu when backward delete char
        grammatical-edit-backward-delete backward-delete-char-untabify
        python-indent-dedent-line-backspace delete-backward-char hungry-delete-backward
        "\\`acm-" "\\`scroll-other-window" "\\`special-lispy-" "\\`lispy-")
  "Continue ACM completion after executing these commands."
  :type '(repeat (choice regexp symbol))
  :group 'acm)

加了

1 个赞

感谢猫大!zsbd

1 个赞

像Neovim (https://github.com/aznhe21/actions-preview.nvim) 学习, Code Action 的时候显示Code Action 对应的Diff, 方便快速挑选合适的修复方案。

感谢 @kongds 大佬的补丁!

直接

(add-hook 'java-mode-hook #'lsp-bridge-mode)

虽然 java-mode-hook 里有

 (lambda () (setq-local lsp-bridge-get-single-lang-server-by-project 'lsp-bridge-get-jdtls-server-by-project))

但是配置的 lsp-bridge-jdtls-jvm-args 不起作用,需要

(add-hook 'java-mode-hook (lambda ()
                            (setq-local lsp-bridge-get-single-lang-server-by-project 'lsp-bridge-get-jdtls-server-by-project)
                            (lsp-bridge-mode 1)))

不知道为什么,难道是 java-mode-hook 的没有按顺序执行

怎么把 mode-line 上的这个提示关掉?

image

lsp-bridge--mode-line-format 设置为nil,还是会有一对[]

==========

我把源码中的这个注释掉就没了。

(add-to-list 'mode-line-misc-info
             `(lsp-bridge-mode (" [" lsp-bridge--mode-line-format "] ")))

可以不改源码做到吗?

加个选项,提PR

diff --git a/lsp-bridge.el b/lsp-bridge.el
index 8369782..d716c00 100644
--- a/lsp-bridge.el
+++ b/lsp-bridge.el
@@ -223,6 +223,11 @@ Setting this to nil or 0 will turn off the indicator."
   :type 'float
   :group 'lsp-bridge)
 
+(defcustom lsp-bridge-mode-line t
+  "Whether display LSP-bridge's server info in mode-line ."
+  :type 'boolean
+  :group 'lsp-bridge)
+
 (defface lsp-bridge-font-lock-flash
   '((t (:inherit highlight)))
   "Face to flash the current line."
@@ -1429,6 +1434,10 @@ So we build this macro to restore postion after code format."
 
   (advice-add #'acm-hide :after #'lsp-bridge--completion-hide-advisor)
 
+  (when lsp-bridge-mode-line
+    (add-to-list 'mode-line-misc-info
+                 `(lsp-bridge-mode (" [" lsp-bridge--mode-line-format "] "))))
+
   ;; Flag `lsp-bridge-is-starting' make sure only call `lsp-bridge-start-process' once.
   (unless lsp-bridge-is-starting
     (lsp-bridge-start-process)))
@@ -2165,9 +2174,6 @@ SymbolKind (defined in the LSP)."
   (when lsp-bridge-server
     (propertize (format "lsp-bridge:%s" lsp-bridge-server-port) 'face mode-face)))
 
-(add-to-list 'mode-line-misc-info
-             `(lsp-bridge-mode (" [" lsp-bridge--mode-line-format "] ")))
-
 (provide 'lsp-bridge)
 
 ;;; lsp-bridge.el ends her

大佬改下,我这边网有问题,仓库clone不下来,就不发PR了。

合并了, 感谢。

公司一个项目,有个python 文件4000+ 行,用lsp-bridge,lsp部分的补全要等2秒才能出来,有可能啥原因呀。在2000行的 python 文件里面补全挺流畅的。

vscode 用相同版本的pyright 1.1.206 补全同样的大文件,lsp的补全能秒出。

emacs 29, emacs 28.2, emacs -Q 都测了。

cpu profiler

       12949  69% - timer-event-handler
       12941  69%  - apply
        9676  51%   - mode-line-idle--timer-callback
        9676  51%    - if
        9676  51%     - progn
        9676  51%      - save-current-buffer
        9676  51%       - let
        9624  51%        - if
        9624  51%         - progn
        9624  51%          - let
        9605  51%           - redisplay
         243   1%            + redisplay_internal (C function)
          22   0%            + timer-event-handler
          52   0%        + let
        2915  15%   - lsp-bridge-deferred-worker
        2915  15%    - if
        2915  15%     - progn
        2913  15%      - let*
        2913  15%       - condition-case
        2913  15%        - setq
        2913  15%         - lsp-bridge-deferred-exec-task
        2913  15%          - let
        2911  15%           - cond
        2911  15%            - let
        2911  15%             - condition-case
        2911  15%              + let
         174   0%   + acm-template-candidate-update
          47   0%   + #<lambda 0x1e6588a>
          30   0%   + savehist-autosave
          22   0%   + sis--auto-refresh-timer-function
          16   0%   + #<compiled -0x2af045cf07f1de5>
          15   0%   + sis--auto-refresh-timer-restart
          12   0%   + show-paren-function
          10   0%     #<compiled 0x12c7d70b27aff8ba>
           8   0%     highlight-indent-guides--try-update-line-cache
           4   0%   + highlight-parentheses--highlight
           2   0%   + sis--respect-post-cmd-timer-fn
           2   0%     posframe-hidehandler-daemon-function
           2   0%  + timer-inc-time
        1911  10% + redisplay_internal (C function)
        1726   9% + command-execute
        1225   6% + lsp-bridge-monitor-post-command
         721   3% + ...
          40   0% + #<lambda 0x1e1e018c5db9c7d>
          16   0% + #<lambda 0x1e1e018c5db9c7d>
           6   0% + evil--jump-hook
           6   0% + evil-repeat-pre-hook
           4   0% + highlight-parentheses--initiate-highlight
           4   0%   internal-default-process-filter
           4   0% + jit-lock--antiblink-post-command
           4   0% + winner-save-old-configurations
           4   0% + gcmh-register-idle-gc
           2   0%   evil--jump-handle-buffer-crossing
           2   0% + yas--post-command-handler
           2   0%   flycheck-pos-tip-hide-messages
           2   0%   tooltip-hide
           2   0%   undo-auto--add-boundary
           2   0% + acm--pre-command
           2   0% + evil-repeat-post-hook
           2   0% + evil-visual-post-command

是不是打开了日志选项?