我正在 emacs 中编辑一个 C++ 项目,同时打开了 c++-ts-mode 和 eglot(clangd),我注意到当我输入完
{}
并点击 enter
时,就会发生这样的情况
我的配置是:
(use-package cc-mode
:init
(add-to-list 'auto-mode-alist '("\\.isa\\'" . c++-mode))
:config
(setq c-basic-offset 4)
(c-set-offset 'case-label '+)
)
(use-package c-ts-mode
:init
(add-to-list 'auto-mode-alist '("\\.isa\\'" . c++-ts-mode))
:config
(setq c-ts-mode-indent-offset 4)
(setq c-ts-mode-indent-style 'linux)
)
(use-package eglot
;; :hook ((c-ts-mode c++-ts-mode) . eglot-ensure)
:bind
("C-c l" . hydra-eglot/body)
:config
(setq eglot-events-buffer-size 0
eglot-connect-timeout 10
eglot-autoshutdown t
;; use global completion styles
completion-category-defaults nil)
(defhydra hydra-eglot (:color blue :columns 3)
"Eglot Menu"
("f" eglot-format "Format selection")
("b" eglot-format-buffer "Format buffer")
("r" eglot-rename "Rename symbol at point")
("d" eglot-find-declaration "Find declaration")
("i" eglot-find-implementation "Find implementation")
("t" eglot-find-typeDefinition "Find type definition")
("s" eglot-shutdown "Shutdown eglot server")
("c" consult-eglot-symbols "Consult Eglot Symbols")
("q" nil "Quit" :color blue))
)
我能做些什么来解决这个问题吗?谢谢你。
最后我通过禁止某些 lsp 函数来修复它,如下所示:
(use-package eglot
:custom
(eglot-ignored-server-capabilities '(:documentOnTypeFormattingProvider))
我猜这个bug是因为lsp和treesit的功能重叠造成的。
有没有办法禁用禁止树木功能?