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

最新的代码下,在写vue时,如果一个字段是可选类型的,那么会导致补全混乱。

lsp-bridge-corfu-bug-2

已经修复了,请更新。

已更新!修复了! :smile:

If my colleague can be this effective in fixing bugs, life would be a lot easier lol.

请问一下对c不在同一个文件夹里对头文件补全的正确姿势是啥呀,用的json文件没有效果

看这个帖子的攻略 在ubuntu 16.04 中成功配置大佬开发的lsp-bridge插件来完成流畅自动完成C\C++代码的功能。 - #8,来自 manateelazycat

添加了 For Xref support 的代码后使用 xref 跳转到定义的时候会提示

xref--show-defs: Wrong type argument: listp, #s(lsp-bridge-deferred-object identity lsp-bridge-deferred-resignal lsp-bridge-deferred-default-cancel nil nil nil)

Backtrace 显示的是

Debugger entered--Lisp error: (wrong-type-argument listp #s(lsp-bridge-deferred-object :callback identity :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil))
  xref-show-definitions-buffer(#f(compiled-function () #<bytecode -0xe20b3fc1854b535>) ((window . #<window 9 on qwe.java>) (display-action) (auto-jump)))
  xref--show-defs(#f(compiled-function () #<bytecode -0xe20b3fc1854b535>) nil)
  xref--find-definitions(#s(lsp-bridge-deferred-object :callback identity :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil) nil)
  xref-find-definitions(#s(lsp-bridge-deferred-object :callback identity :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil))
  funcall-interactively(xref-find-definitions #s(lsp-bridge-deferred-object :callback identity :errorback lsp-bridge-deferred-resignal :cancel lsp-bridge-deferred-default-cancel :next nil :status nil :value nil))
  command-execute(xref-find-definitions)

只有我会这样吗?

好的,谢谢啦

lsp-bridge的xref功能感觉实现的不完备呀,建议直接用内置的命令来跳转和引用。

可以参考我的用法 lazycat-emacs/init-lsp-bridge.el at bd198e81b63c578e4b99acf7ce97e2cc135c5008 · manateelazycat/lazycat-emacs · GitHub

  • 语法高亮:用Emacs TreeSitter 来做 现在有支持使用TreeSitter进行语法高亮的包吗?

谢谢;

tree-sitter-hl-mode


(use-package corfu
  ;; Optional customizations
  ;; :custom
  ;; (corfu-cycle t)                ;; Enable cycling for `corfu-next/previous'
  ;; (corfu-auto t)                 ;; Enable auto completion
  ;; (corfu-separator ?\s)          ;; Orderless field separator
  ;; (corfu-quit-at-boundary nil)   ;; Never quit at completion boundary
  ;; (corfu-quit-no-match nil)      ;; Never quit, even if there is no match
  ;; (corfu-preview-current nil)    ;; Disable current candidate preview
  ;; (corfu-preselect-first nil)    ;; Disable candidate preselection
  ;; (corfu-on-exact-match nil)     ;; Configure handling of exact matches
  ;; (corfu-echo-documentation nil) ;; Disable documentation in the echo area
  ;; (corfu-scroll-margin 5)        ;; Use scroll margin

  ;; Enable Corfu only for certain modes.
  ;; :hook ((prog-mode . corfu-mode)
  ;;        (shell-mode . corfu-mode)
  ;;        (eshell-mode . corfu-mode))

  ;; Recommended: Enable Corfu globally.
  ;; This is recommended since Dabbrev can be used globally (M-/).
  ;; See also `corfu-excluded-modes'.
  :init
  (global-corfu-mode)
  (corfu-history-mode t)
  :config
  (use-package cape)
  (use-package lsp-bridge
    :ensure nil
    :quelpa (lsp-bridge :fetcher github :repo "manateelazycat/lsp-bridge")
    :hook ((after-init . lsp-bridge-mode))
    :init
    (require 'lsp-bridge)
    (require 'lsp-bridge-jdtls)
    (require 'corfu)
    (require 'corfu-info)
    (require 'corfu-history)
    (require 'lsp-bridge-icon)        ;; show icons for completion items, optional
    (require 'lsp-bridge-orderless)   ;; make lsp-bridge support fuzzy match, optional
    (global-lsp-bridge-mode)
    :config
    (setq lsp-bridge-enable-log nil)
    ;; 让corfu适应高分屏
    (when (> (frame-pixel-width) 3000) (custom-set-faces '(corfu-default ((t (:height 1.3))))))

    ;; 打开日志,开发者才需要
    ;; (setq lsp-bridge-enable-log t)

    ;; 默认用这三个补全后端
    (add-to-list 'completion-at-point-functions #'cape-symbol)
    (add-to-list 'completion-at-point-functions #'cape-file)
    (add-to-list 'completion-at-point-functions #'cape-dabbrev)

    (dolist (hook (list
                   'emacs-lisp-mode-hook
                   ))
      (add-hook hook (lambda ()
                       (setq-local corfu-auto t) ; Elisp文件自动弹出补全
                       )))

    ;; 通过Cape融合不同的补全后端,比如lsp-bridge、 tabnine、 file、 dabbrev.
    (defun lsp-bridge-mix-multi-backends ()
      (setq-local completion-category-defaults nil)
      (setq-local completion-at-point-functions
                  (list
                   (cape-capf-buster
                    (cape-super-capf
                     #'lsp-bridge-capf

                     ;; 我嫌弃TabNine太占用我的CPU了, 需要的同学注释下面这一行就好了
                     ;; #'tabnine-completion-at-point

                     ;; #'cape-file
                     ;; #'cape-dabbrev
                     )
                    'equal)
                   )))


    (dolist (hook lsp-bridge-default-mode-hooks)
      (add-hook hook (lambda ()
                       (setq-local corfu-auto nil) ; 编程文件关闭Corfu自动补全, 由lsp-bridge来手动触发补全
                       (lsp-bridge-mode 1)             ; 开启lsp-bridge
                       (lsp-bridge-mix-multi-backends) ; 通过Cape融合多个补全后端
                       )))

    ;; 融合 `lsp-bridge' `find-function' 以及 `dumb-jump' 的智能跳转
    (defun lsp-bridge-jump ()
      (interactive)
      (cond
       ((eq major-mode 'emacs-lisp-mode)
        (let ((symb (function-called-at-point)))
          (when symb
            (find-function symb))))
       (lsp-bridge-mode
        (lsp-bridge-find-def))
       (t
        (require 'dumb-jump)
        (dumb-jump-go))))

    (defun lsp-bridge-jump-back ()
      (interactive)
      (cond
       (lsp-bridge-mode
        (lsp-bridge-return-from-def))
       (t
        (require 'dumb-jump)
        (dumb-jump-back))))
    ))

我这样配置不生效, 找到原因了,没有把python脚本安装过去 。。。

需要把python脚本单独打包好。。。

这样原始使用的方式,管理起来好麻烦。。,先切回旧的方式了

1 个赞

怎么配置自动补全函数方法的参数?目前不能补全参数。。

还有就是golang变量名和类型连接在一起了 没法看。。。

补全参数你安装了yas了吗?

:joy: 我记得在哪里看了,说不用它了。。我就干掉了。。但是显示补全信息 参数名和类型连在一起了

那个corfu设置了最大宽度,你可以稍微调大一点

(when (> (frame-pixel-width) 3000) (custom-set-faces '(corfu-default ((t (:height 1.3))))))

你说的这个么?我删掉代码一样。。不管怎么修改都没变化

还有个问题,就是lsp-bridge启动后吧doom-modeline干掉了。

1 个赞

那是你配置问题,emacs -Q 对不测试一下,lsp-bridge不会干这种事。